[extensions-web] review: Fold ChangeStatusLog into CodeReview
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] review: Fold ChangeStatusLog into CodeReview
- Date: Mon, 6 Aug 2012 21:27:41 +0000 (UTC)
commit e56b5057d8ba5ede878b5b3b8691a26bd158f4e1
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Aug 6 16:33:28 2012 -0300
review: Fold ChangeStatusLog into CodeReview
sweettooth/review/admin.py | 6 -
.../migrations/0007_remove_changestatuslog.py | 109 ++++++++++++++++++++
..._newstatus__add_field_codereview_new_status_.py | 106 +++++++++++++++++++
sweettooth/review/models.py | 13 +--
sweettooth/review/templates/review/review.html | 8 +-
sweettooth/review/views.py | 21 ++---
6 files changed, 229 insertions(+), 34 deletions(-)
---
diff --git a/sweettooth/review/migrations/0007_remove_changestatuslog.py b/sweettooth/review/migrations/0007_remove_changestatuslog.py
new file mode 100644
index 0000000..1881368
--- /dev/null
+++ b/sweettooth/review/migrations/0007_remove_changestatuslog.py
@@ -0,0 +1,109 @@
+# 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."
+ for obj in orm.CodeReview.objects.filter(changelog__isnull=False):
+ obj.new_status = obj.changelog.newstatus
+ obj.auto = obj.changelog.auto
+ obj.save()
+
+ def backwards(self, orm):
+ "Write your backwards methods here."
+
+
+ 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.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', [], {})
+ },
+ 'review.changestatuslog': {
+ 'Meta': {'object_name': 'ChangeStatusLog'},
+ 'auto': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'newstatus': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
+ 'version': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'status_log'", 'to': "orm['extensions.ExtensionVersion']"})
+ },
+ 'review.codereview': {
+ 'Meta': {'object_name': 'CodeReview'},
+ 'changelog': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['review.ChangeStatusLog']", 'unique': 'True', 'null': 'True'}),
+ 'comments': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'reviewer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
+ 'version': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'reviews'", 'to': "orm['extensions.ExtensionVersion']"})
+ }
+ }
+
+ complete_apps = ['review']
diff --git a/sweettooth/review/migrations/0008_auto__del_field_codereview_newstatus__add_field_codereview_new_status_.py b/sweettooth/review/migrations/0008_auto__del_field_codereview_newstatus__add_field_codereview_new_status_.py
new file mode 100644
index 0000000..ac893f6
--- /dev/null
+++ b/sweettooth/review/migrations/0008_auto__del_field_codereview_newstatus__add_field_codereview_new_status_.py
@@ -0,0 +1,106 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding field 'CodeReview.new_status'
+ db.add_column('review_codereview', 'new_status', self.gf('django.db.models.fields.PositiveIntegerField')(null=True), keep_default=False)
+
+ # Adding field 'CodeReview.auto'
+ db.add_column('review_codereview', 'auto', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False)
+
+
+ def backwards(self, orm):
+ # Deleting field 'CodeReview.new_status'
+ db.delete_column('review_codereview', 'new_status')
+
+ # Deleting field 'CodeReview.auto'
+ db.delete_column('review_codereview', 'auto')
+
+
+ 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.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', [], {})
+ },
+ 'review.codereview': {
+ 'Meta': {'object_name': 'CodeReview'},
+ 'auto': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'comments': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'new_status': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True'}),
+ 'reviewer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
+ 'version': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'reviews'", 'to': "orm['extensions.ExtensionVersion']"})
+ }
+ }
+
+ complete_apps = ['review']
diff --git a/sweettooth/review/models.py b/sweettooth/review/models.py
index c6b80a5..605b36c 100644
--- a/sweettooth/review/models.py
+++ b/sweettooth/review/models.py
@@ -18,19 +18,10 @@ class CodeReview(models.Model):
date = models.DateTimeField(auto_now_add=True)
comments = models.TextField(blank=True)
version = models.ForeignKey(ExtensionVersion, related_name="reviews")
- changelog = models.OneToOneField('ChangeStatusLog', null=True)
+ new_status = models.PositiveIntegerField(choices=STATUSES.items(), null=True)
+ auto = models.BooleanField(default=False)
class Meta:
permissions = (
("can-review-extensions", "Can review extensions"),
)
-
-class ChangeStatusLog(models.Model):
- user = models.ForeignKey(User)
- date = models.DateTimeField(auto_now_add=True)
- newstatus = models.PositiveIntegerField(choices=STATUSES.items())
- version = models.ForeignKey(ExtensionVersion, related_name="status_log")
- auto = models.BooleanField(default=False)
-
- def get_newstatus_class(self):
- return STATUSES[self.newstatus].lower()
diff --git a/sweettooth/review/templates/review/review.html b/sweettooth/review/templates/review/review.html
index f42d948..52dfaf5 100644
--- a/sweettooth/review/templates/review/review.html
+++ b/sweettooth/review/templates/review/review.html
@@ -92,10 +92,10 @@
{% for review in previous_reviews %}
<div class="review">
<a class="review-author" href="{% url auth-profile user=review.reviewer.username %}">{{ review.reviewer }}</a>
- {% if review.changelog %}
- <span class="extension-status {{ review.changelog.get_newstatus_class }}">
- {% if review.changelog.auto %}auto-{% endif%}
- {{ review.changelog.get_newstatus_display|lower }}
+ {% if review.new_status %}
+ <span class="extension-status {{ review.get_new_status_display|lower }}">
+ {% if review.auto %}auto-{% endif%}
+ {{ review.get_new_status_display|lower }}
</span>
{% else %}
posted a review
diff --git a/sweettooth/review/views.py b/sweettooth/review/views.py
index c6f41b1..17b438e 100644
--- a/sweettooth/review/views.py
+++ b/sweettooth/review/views.py
@@ -18,7 +18,7 @@ from django.template.loader import render_to_string
from django.views.decorators.http import require_POST
from review.diffutils import get_chunks
-from review.models import CodeReview, ChangeStatusLog, get_all_reviewers
+from review.models import CodeReview, get_all_reviewers
from extensions import models
from decorators import ajax_view, model_view
@@ -229,10 +229,6 @@ def submit_review_view(request, obj):
if not can_review:
return HttpResponseForbidden()
- review = CodeReview(version=version,
- reviewer=request.user,
- comments=request.POST.get('comments'))
-
messages.info(request, "Thank you for reviewing %s" % (extension.name,))
status_string = request.POST.get('status')
@@ -245,13 +241,15 @@ def submit_review_view(request, obj):
if not can_approve and obj.status == models.STATUS_WAITING:
newstatus = models.STATUS_UNREVIEWED
+ review = CodeReview(version=version,
+ reviewer=request.user,
+ comments=request.POST.get('comments'))
+
if newstatus is not None:
if newstatus == models.STATUS_ACTIVE and not can_approve:
return HttpResponseForbidden()
- review.changelog = ChangeStatusLog.objects.create(user=request.user,
- version=obj,
- newstatus=newstatus)
+ review.new_status = newstatus
obj.status = newstatus
obj.save()
@@ -374,14 +372,11 @@ def extension_submitted(sender, request, version, **kwargs):
changeset = get_file_changeset(old_zipfile, new_zipfile)
if old_zipfile is not None and should_auto_approve(changeset, version.extension):
- log = ChangeStatusLog.objects.create(user=request.user,
- version=version,
- newstatus=models.STATUS_ACTIVE,
- auto=True)
CodeReview.objects.create(version=version,
reviewer=request.user,
comments="",
- changelog=log)
+ new_status=models.STATUS_ACTIVE,
+ auto=True)
version.status = models.STATUS_ACTIVE
version.save()
send_email_auto_approved(request, version, changeset)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]