[extensions-web: 67/75] Reviews should not set a status immediately.
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web: 67/75] Reviews should not set a status immediately.
- Date: Fri, 23 Sep 2011 03:20:03 +0000 (UTC)
commit ed7b4714cb321774eff1b8914fd493962c476fe1
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Sep 22 16:03:45 2011 -0400
Reviews should not set a status immediately.
If we are treating reviews as being "developer comments", we have to separate
the mechanism of reviews out from the mechanism of approving, rejecting and
unapproving out.
sweettooth/review/migrations/0001_initial.py | 107 ++++++++++++++++++++
.../0002_auto__del_field_codereview_newstatus.py | 98 ++++++++++++++++++
sweettooth/review/models.py | 13 +--
.../review/templates/review/review_reviewer.html | 4 +-
sweettooth/review/views.py | 17 +---
5 files changed, 209 insertions(+), 30 deletions(-)
---
diff --git a/sweettooth/review/migrations/0001_initial.py b/sweettooth/review/migrations/0001_initial.py
new file mode 100644
index 0000000..60c2445
--- /dev/null
+++ b/sweettooth/review/migrations/0001_initial.py
@@ -0,0 +1,107 @@
+# 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 model 'CodeReview'
+ db.create_table('review_codereview', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('reviewer', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),
+ ('date', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
+ ('comments', self.gf('django.db.models.fields.TextField')()),
+ ('version', self.gf('django.db.models.fields.related.ForeignKey')(related_name='reviews', to=orm['extensions.ExtensionVersion'])),
+ ('newstatus', self.gf('django.db.models.fields.PositiveIntegerField')()),
+ ))
+ db.send_create_signal('review', ['CodeReview'])
+
+
+ def backwards(self, orm):
+
+ # Deleting model 'CodeReview'
+ db.delete_table('review_codereview')
+
+
+ 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', [], {}),
+ 'icon': ('django.db.models.fields.files.ImageField', [], {'default': "''", 'max_length': '100', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+ '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'}),
+ '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': '100'}),
+ 'status': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'version': ('django.db.models.fields.IntegerField', [], {'default': '0', 'max_length': '223'})
+ },
+ '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'},
+ 'comments': ('django.db.models.fields.TextField', [], {}),
+ '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', [], {}),
+ '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/0002_auto__del_field_codereview_newstatus.py b/sweettooth/review/migrations/0002_auto__del_field_codereview_newstatus.py
new file mode 100644
index 0000000..fdba87a
--- /dev/null
+++ b/sweettooth/review/migrations/0002_auto__del_field_codereview_newstatus.py
@@ -0,0 +1,98 @@
+# 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):
+
+ # Deleting field 'CodeReview.newstatus'
+ db.delete_column('review_codereview', 'newstatus')
+
+
+ def backwards(self, orm):
+
+ # User chose to not deal with backwards NULL issues for 'CodeReview.newstatus'
+ raise RuntimeError("Cannot reverse this migration. 'CodeReview.newstatus' and its values cannot be restored.")
+
+
+ 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', [], {}),
+ 'icon': ('django.db.models.fields.files.ImageField', [], {'default': "''", 'max_length': '100', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+ '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'}),
+ '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': '100'}),
+ 'status': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'version': ('django.db.models.fields.IntegerField', [], {'default': '0', 'max_length': '223'})
+ },
+ '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'},
+ 'comments': ('django.db.models.fields.TextField', [], {}),
+ '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/models.py b/sweettooth/review/models.py
index 498f54b..37b2aaa 100644
--- a/sweettooth/review/models.py
+++ b/sweettooth/review/models.py
@@ -3,7 +3,7 @@ from django.contrib.auth.models import User, Permission, Group
from django.db import models
from django.db.models import Q
-from extensions import models as extensions_models
+from extensions.models import ExtensionVersion
def get_all_reviewers():
perm = Permission.objects.get(codename="can-review-extensions")
@@ -17,16 +17,7 @@ class CodeReview(models.Model):
reviewer = models.ForeignKey(User)
date = models.DateTimeField(auto_now_add=True)
comments = models.TextField()
- version = models.ForeignKey(extensions_models.ExtensionVersion, related_name="reviews")
- newstatus = models.PositiveIntegerField(choices=extensions_models.STATUSES.items())
-
- @property
- def is_rejected(self):
- return self.newstatus == extensions_models.STATUS_REJECTED
-
- @property
- def is_active(self):
- return self.newstatus == extensions_models.STATUS_ACTIVE
+ version = models.ForeignKey(ExtensionVersion, related_name="reviews")
class Meta:
permissions = (
diff --git a/sweettooth/review/templates/review/review_reviewer.html b/sweettooth/review/templates/review/review_reviewer.html
index 8eca2d4..25291bf 100644
--- a/sweettooth/review/templates/review/review_reviewer.html
+++ b/sweettooth/review/templates/review/review_reviewer.html
@@ -6,9 +6,7 @@
<form id="review_form" action="{% url review-submit pk=version.pk %}" method="POST">
{% csrf_token %}
<textarea id="comments" name="comments"></textarea>
- <input type="radio" value="Accept" name="newstatus" id="accept"> <label for="accept">Accept</label>
- <input type="radio" value="Reject" name="newstatus" id="reject"> <label for="reject">Reject</label>
- <input type="submit" value="Review">
+ <input type="submit" value="Add review">
</form>
</div>
{% endblock %}
diff --git a/sweettooth/review/views.py b/sweettooth/review/views.py
index 4b7b72d..87311cb 100644
--- a/sweettooth/review/views.py
+++ b/sweettooth/review/views.py
@@ -73,28 +73,13 @@ class SubmitReviewView(SingleObjectMixin, View):
if self.object.status != models.STATUS_LOCKED:
return HttpResponseForbidden()
- newstatus = request.POST.get('newstatus')
- statuses = dict(Accept=models.STATUS_ACTIVE,
- Reject=models.STATUS_REJECTED)
-
- if newstatus not in statuses:
- return HttpResponseForbidden()
-
- self.object.status = statuses[newstatus]
- self.object.save()
-
review = CodeReview(version=self.object,
reviewer=request.user,
- comments=request.POST.get('comments'),
- newstatus=self.object.status)
+ comments=request.POST.get('comments'))
review.save()
models.reviewed.send(sender=self, version=self.object, review=review)
- verb_past_progressive = dict(Accept="accepted",
- Reject="rejected")[newstatus]
-
- messages.info(request, "The extension was successfully %s. Thanks!" % (verb_past_progressive,))
return redirect('review-list')
class ReviewVersionView(DetailView):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]