[extensions-web] Associate a ChangeStatusLog with a CodeReview
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] Associate a ChangeStatusLog with a CodeReview
- Date: Fri, 11 Nov 2011 21:00:45 +0000 (UTC)
commit 91121edc3ea118f40ce7da29ebadb620cf1fa0a2
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Nov 11 15:57:26 2011 -0500
Associate a ChangeStatusLog with a CodeReview
Show the associated status change in the review page as well
.../0004_auto__add_field_codereview_changelog.py | 107 ++++++++++++++++++++
sweettooth/review/models.py | 4 +
sweettooth/review/templates/review/review.html | 4 +
sweettooth/review/views.py | 5 +-
4 files changed, 119 insertions(+), 1 deletions(-)
---
diff --git a/sweettooth/review/migrations/0004_auto__add_field_codereview_changelog.py b/sweettooth/review/migrations/0004_auto__add_field_codereview_changelog.py
new file mode 100644
index 0000000..2aa1173
--- /dev/null
+++ b/sweettooth/review/migrations/0004_auto__add_field_codereview_changelog.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 field 'CodeReview.changelog'
+ db.add_column('review_codereview', 'changelog', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['review.ChangeStatusLog'], unique=True, null=True), keep_default=False)
+
+
+ def backwards(self, orm):
+
+ # Deleting field 'CodeReview.changelog'
+ db.delete_column('review_codereview', 'changelog_id')
+
+
+ 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': "'/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'}),
+ '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': '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'},
+ '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', [], {}),
+ '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 5e89c34..40eb9ab 100644
--- a/sweettooth/review/models.py
+++ b/sweettooth/review/models.py
@@ -18,6 +18,7 @@ class CodeReview(models.Model):
date = models.DateTimeField(auto_now_add=True)
comments = models.TextField()
version = models.ForeignKey(ExtensionVersion, related_name="reviews")
+ changelog = models.OneToOneField('ChangeStatusLog', null=True)
class Meta:
permissions = (
@@ -29,3 +30,6 @@ class ChangeStatusLog(models.Model):
date = models.DateTimeField(auto_now_add=True)
newstatus = models.PositiveIntegerField(choices=STATUSES.items())
version = models.ForeignKey(ExtensionVersion, related_name="status_log")
+
+ 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 da2bfe0..004eecf 100644
--- a/sweettooth/review/templates/review/review.html
+++ b/sweettooth/review/templates/review/review.html
@@ -63,7 +63,11 @@
{% 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="{{ review.changelog.get_newstatus_class }}">{{ review.changelog.get_newstatus_display|lower }}</span>
+ {% else %}
reviewed
+ {% endif %}
<abbr class="timestamp" title="{{ review.date|date:"c" }}">{{ review.date|date:"F j, Y" }}</abbr>
<blockquote>{{ review.comments }}</blockquote>
</div>
diff --git a/sweettooth/review/views.py b/sweettooth/review/views.py
index ec97cc6..c5e4748 100644
--- a/sweettooth/review/views.py
+++ b/sweettooth/review/views.py
@@ -103,7 +103,6 @@ def submit_review_view(request, obj):
review = CodeReview(version=version,
reviewer=request.user,
comments=request.POST.get('comments'))
- review.save()
messages.info(request, "Thank you for reviewing %s" % (extension.name,))
@@ -121,8 +120,12 @@ def submit_review_view(request, obj):
obj.status = newstatus
obj.save()
+ review.changelog = log
+
models.status_changed.send(sender=request, version=obj, log=log)
+ review.save()
+
models.reviewed.send(sender=request, request=request,
version=version, review=review)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]