[extensions-web: 32/75] Fix the upload when uploading an existing UUID for the same user.
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web: 32/75] Fix the upload when uploading an existing UUID for the same user.
- Date: Fri, 23 Sep 2011 03:17:07 +0000 (UTC)
commit a4fc061a8bf8b148b6c5546fc57866cf79f2e33c
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Sep 14 19:25:22 2011 -0400
Fix the upload when uploading an existing UUID for the same user.
sweettooth/extensions/tests.py | 26 ++++++++++++++++++++------
sweettooth/extensions/views.py | 2 +-
2 files changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/sweettooth/extensions/tests.py b/sweettooth/extensions/tests.py
index b86765f..8d0d0bc 100644
--- a/sweettooth/extensions/tests.py
+++ b/sweettooth/extensions/tests.py
@@ -54,18 +54,32 @@ class UploadTest(TestCase):
dict(source=f), follow=True)
extension = models.Extension.objects.get(uuid="test-extension gnome org")
- version = extension.versions.order_by("-version")[0]
-
- url = reverse('extensions-version-detail', kwargs=dict(pk=version.pk,
- ext_pk=extension.pk,
- slug=extension.slug))
- self.assertRedirects(response, url)
+ version1 = extension.versions.order_by("-version")[0]
+ self.assertEquals(version1.status, models.STATUS_NEW)
self.assertEquals(extension.creator, self.user)
self.assertEquals(extension.name, "Test Extension")
self.assertEquals(extension.description, "Simple test metadata")
self.assertEquals(extension.url, "http://test-metadata.gnome.org")
+ url = reverse('extensions-version-detail', kwargs=dict(pk=version1.pk,
+ ext_pk=extension.pk,
+ slug=extension.slug))
+ self.assertRedirects(response, url)
+
+ version1.status = models.STATUS_ACTIVE
+ version1.save()
+
+ # Try again, hoping to get a new version
+ with get_test_zipfile('SimpleExtension') as f:
+ response = client.post(reverse('extensions-upload-file'),
+ dict(source=f), follow=True)
+
+ version2 = extension.versions.order_by("-version")[0]
+ self.assertNotEquals(version1, version2)
+ self.assertEquals(version2.status, models.STATUS_NEW)
+ self.assertEquals(version2.version, version1.version+1)
+
def test_extra_metadata(self):
extension = models.Extension(creator=self.user)
version = models.ExtensionVersion()
diff --git a/sweettooth/extensions/views.py b/sweettooth/extensions/views.py
index 1daa26a..3fb2af0 100644
--- a/sweettooth/extensions/views.py
+++ b/sweettooth/extensions/views.py
@@ -240,7 +240,7 @@ def upload_file(request, pk):
# uuid -- or correct their mistake if they're the same user.
ext = existing.get()
if request.user == ext.creator:
- return redirect('extensions-upload-file', pk=ext.pk)
+ return upload_file(request, ext.pk)
else:
messages.error(request, "An extension with that UUID has already been added.")
return redirect('extensions-upload-file')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]