[extensions-web] extensions: Remove STATUS_NEW
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] extensions: Remove STATUS_NEW
- Date: Mon, 6 Aug 2012 21:27:26 +0000 (UTC)
commit 53a7d1c3011a62ad0cceba28b18f79b00637b9bb
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Aug 6 15:48:48 2012 -0300
extensions: Remove STATUS_NEW
Move it over to STATUS_UNREVIEWED
.../migrations/0018_new_to_unreviewed.py | 113 ++++++++++++++++++++
sweettooth/extensions/models.py | 5 +-
sweettooth/extensions/tests.py | 4 +-
sweettooth/review/views.py | 4 -
4 files changed, 117 insertions(+), 9 deletions(-)
---
diff --git a/sweettooth/extensions/migrations/0018_new_to_unreviewed.py b/sweettooth/extensions/migrations/0018_new_to_unreviewed.py
new file mode 100644
index 0000000..6669e36
--- /dev/null
+++ b/sweettooth/extensions/migrations/0018_new_to_unreviewed.py
@@ -0,0 +1,113 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import DataMigration
+from django.db import models
+
+class Migration(DataMigration):
+ def forwards(self, orm):
+ "Write your forwards methods here."
+ mapping = {
+ 0: 1, # STATUS_NEW => STATUS_REJECTED
+ 1: 0, # STATUS_UNREVIEWED
+ 2: 1, # STATUS_REJECTED
+ 3: 2, # STATUS_INACTIVE
+ 4: 3, # STATUS_ACTIVE
+ 5: 4, # STATUS_WAITING
+ }
+ for ver in orm.ExtensionVersion.objects.all():
+ ver.status = mapping[ver.status]
+ ver.save()
+
+ def backwards(self, orm):
+ "Write your backwards methods here."
+ mapping = {
+ 0: 1, # STATUS_UNREVIEWED
+ 1: 2, # STATUS_REJECTED
+ 2: 3, # STATUS_INACTIVE
+ 3: 4, # STATUS_ACTIVE
+ 4: 5, # STATUS_WAITING
+ }
+ for ver in orm.ExtensionVersion.objects.all():
+ ver.status = mapping[ver.status]
+ ver.save()
+
+ models = {
+ 'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'auth.permission': {
+ 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ 'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ 'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ 'extensions.extension': {
+ 'Meta': {'object_name': 'Extension'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'creator': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'downloads': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'icon': ('django.db.models.fields.files.ImageField', [], {'default': "'/static/images/plugin.png'", 'max_length': '100', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+ 'popularity': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'screenshot': ('sorl.thumbnail.fields.ImageField', [], {'max_length': '100', 'blank': 'True'}),
+ 'slug': ('autoslug.fields.AutoSlugField', [], {'unique_with': '()', 'max_length': '50', 'populate_from': 'None', 'db_index': 'True'}),
+ 'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
+ 'uuid': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '200', 'db_index': 'True'})
+ },
+ 'extensions.extensionpopularityitem': {
+ 'Meta': {'object_name': 'ExtensionPopularityItem'},
+ 'date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'extension': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'popularity_items'", 'to': "orm['extensions.Extension']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'offset': ('django.db.models.fields.IntegerField', [], {})
+ },
+ 'extensions.extensionversion': {
+ 'Meta': {'unique_together': "(('extension', 'version'),)", 'object_name': 'ExtensionVersion'},
+ 'extension': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'versions'", 'to': "orm['extensions.Extension']"}),
+ 'extra_json_fields': ('django.db.models.fields.TextField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'shell_versions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['extensions.ShellVersion']", 'symmetrical': 'False'}),
+ 'source': ('django.db.models.fields.files.FileField', [], {'max_length': '223'}),
+ 'status': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'version': ('django.db.models.fields.IntegerField', [], {'default': '0'})
+ },
+ 'extensions.shellversion': {
+ 'Meta': {'object_name': 'ShellVersion'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'major': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'minor': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'point': ('django.db.models.fields.IntegerField', [], {})
+ }
+ }
+
+ complete_apps = ['extensions']
diff --git a/sweettooth/extensions/models.py b/sweettooth/extensions/models.py
index f5c4d68..77e20bf 100644
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@ -15,12 +15,11 @@ import autoslug
import re
from sorl import thumbnail
-(STATUS_NEW, STATUS_UNREVIEWED,
+(STATUS_UNREVIEWED,
STATUS_REJECTED, STATUS_INACTIVE,
- STATUS_ACTIVE, STATUS_WAITING) = xrange(6)
+ STATUS_ACTIVE, STATUS_WAITING) = xrange(5)
STATUSES = {
- STATUS_NEW: u"New",
STATUS_UNREVIEWED: u"Unreviewed",
STATUS_REJECTED: u"Rejected",
STATUS_INACTIVE: u"Inactive",
diff --git a/sweettooth/extensions/tests.py b/sweettooth/extensions/tests.py
index 050dbbd..bba21ec 100644
--- a/sweettooth/extensions/tests.py
+++ b/sweettooth/extensions/tests.py
@@ -76,7 +76,7 @@ class ExtensionPropertiesTest(BasicUserTestCase, TestCase):
extension = models.Extension.objects.create_from_metadata(metadata, creator=self.user)
version = models.ExtensionVersion.objects.create(extension=extension,
- status=models.STATUS_NEW)
+ status=models.STATUS_UNREVIEWED)
version.parse_metadata_json(metadata)
self.assertEquals(version.shell_versions_json, '["3.2", "3.2.1"]')
@@ -285,7 +285,7 @@ class ExtensionVersionTest(BasicUserTestCase, TestCase):
self.assertEquals(v1.version, 1)
v2 = models.ExtensionVersion.objects.create(extension=extension,
- status=models.STATUS_NEW)
+ status=models.STATUS_UNREVIEWED)
self.assertEquals(v2.version, 2)
self.assertEquals(list(extension.visible_versions.order_by('version')), [v1])
diff --git a/sweettooth/review/views.py b/sweettooth/review/views.py
index 3d5d1be..bb45c17 100644
--- a/sweettooth/review/views.py
+++ b/sweettooth/review/views.py
@@ -216,10 +216,6 @@ def ajax_get_file_view(request, obj):
def download_zipfile(request, pk):
version = get_object_or_404(models.ExtensionVersion, pk=pk)
-
- if version.status == models.STATUS_NEW:
- return HttpResponseForbidden()
-
return redirect(version.source.url)
@require_POST
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]