[extensions-web: 71/75] Finish up error reporting.
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web: 71/75] Finish up error reporting.
- Date: Fri, 23 Sep 2011 03:20:24 +0000 (UTC)
commit d7290ea17a21c330617298c326cbb23e5aea3186
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Sep 22 17:46:43 2011 -0400
Finish up error reporting.
.../migrations/0005_auto__add_errorreport.py | 107 ++++++++++++++++++++
sweettooth/extensions/models.py | 20 ++++
.../templates/extensions/error-report.html | 13 ++-
sweettooth/extensions/urls.py | 4 +-
sweettooth/extensions/views.py | 36 +++++++
sweettooth/static/js/extensions.js | 17 ++-
6 files changed, 188 insertions(+), 9 deletions(-)
---
diff --git a/sweettooth/extensions/migrations/0005_auto__add_errorreport.py b/sweettooth/extensions/migrations/0005_auto__add_errorreport.py
new file mode 100644
index 0000000..5240b19
--- /dev/null
+++ b/sweettooth/extensions/migrations/0005_auto__add_errorreport.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 'ErrorReport'
+ db.create_table('extensions_errorreport', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('comment', self.gf('django.db.models.fields.TextField')(blank=True)),
+ ('errors', self.gf('django.db.models.fields.TextField')(blank=True)),
+ ('email', self.gf('django.db.models.fields.EmailField')(max_length=75, blank=True)),
+ ('user', self.gf('django.db.models.fields.related.ForeignKey')(related_name='+', blank=True, to=orm['auth.User'])),
+ ('version', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['extensions.ExtensionVersion'])),
+ ))
+ db.send_create_signal('extensions', ['ErrorReport'])
+
+
+ def backwards(self, orm):
+
+ # Deleting model 'ErrorReport'
+ db.delete_table('extensions_errorreport')
+
+
+ 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.errorreport': {
+ 'Meta': {'object_name': 'ErrorReport'},
+ 'comment': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'errors': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'blank': 'True', 'to': "orm['auth.User']"}),
+ 'version': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['extensions.ExtensionVersion']"})
+ },
+ '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', [], {})
+ }
+ }
+
+ complete_apps = ['extensions']
diff --git a/sweettooth/extensions/models.py b/sweettooth/extensions/models.py
index c96ba86..497d428 100644
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@ -246,6 +246,26 @@ class ExtensionVersion(models.Model):
self.save()
+class ErrorReport(models.Model):
+ comment = models.TextField(blank=True)
+ errors = models.TextField(blank=True)
+
+ # In the case that a user isn't logged in, they can supply an optional
+ # email address for the extension author to reply to.
+ email = models.EmailField(blank=True)
+
+ user = models.ForeignKey(auth.models.User, blank=True, related_name="+")
+
+ version = models.ForeignKey(ExtensionVersion)
+
+ @property
+ def user_email(self):
+ if self.user:
+ return self.user.email
+ else:
+ return self.email
+
submitted_for_review = Signal(providing_args=["version"])
reviewed = Signal(providing_args=["version", "review"])
status_changed = Signal(providing_args=["version", "log"])
+error_reported = Signal(providing_args=["version", "report"])
diff --git a/sweettooth/extensions/templates/extensions/error-report.html b/sweettooth/extensions/templates/extensions/error-report.html
index b68c720..d64dc27 100644
--- a/sweettooth/extensions/templates/extensions/error-report.html
+++ b/sweettooth/extensions/templates/extensions/error-report.html
@@ -6,19 +6,30 @@
<p>Please look through the information below and edit out
any private information.</p>
<form action="" method="POST" id="error_report">
+ {% csrf_token %}
<h3> Detected errors with this extension </h3>
+ <input type="hidden" name="has_errors" value="">
<textarea name="error" id="error_log"></textarea>
<h3> Additional comments for the author </h3>
<textarea name="comment" id="comment"></textarea>
+ {% if not request.user.is_authenticated %}
+ <h3> Email address </h3>
+ <p>You're not <a href="{% url auth-login %}">logged in</a>.
+ In order for the extension author to contact you, you need to provide an email address.
+ </p>
+
+ <input type="email" name="email" value="">
+ {% endif %}
+
<input type="submit" value="Report Errors">
</form>
{% endblock %}
{% block document-ready %}
require(['jquery', 'extensions'], function($) {
- $("#error_log").fillInErrors("{{ version.extension.uuid }}");
+ $("#error_report").fillInErrors("{{ version.extension.uuid }}");
});
{% endblock %}
diff --git a/sweettooth/extensions/urls.py b/sweettooth/extensions/urls.py
index 182be25..901369d 100644
--- a/sweettooth/extensions/urls.py
+++ b/sweettooth/extensions/urls.py
@@ -41,9 +41,7 @@ urlpatterns = patterns('',
url(r'^local/', TemplateView.as_view(template_name="extensions/local.html"), name='extensions-local'),
url(r'^error-report/(?P<pk>\d+)',
- DetailView.as_view(model=models.ExtensionVersion,
- context_object_name="version",
- template_name="extensions/error-report.html"), name='extensions-error'),
+ views.ReportErrorView.as_view(), name='extensions-error'),
url(r'^upload/', include(upload_patterns)),
url(r'^ajax/', include(ajax_patterns)),
diff --git a/sweettooth/extensions/views.py b/sweettooth/extensions/views.py
index 5f2ebde..9abdbf7 100644
--- a/sweettooth/extensions/views.py
+++ b/sweettooth/extensions/views.py
@@ -267,3 +267,39 @@ def upload_file(request, pk):
form = UploadForm()
return render(request, 'extensions/upload-file.html', dict(form=form))
+
+class ReportErrorView(DetailView):
+ queryset = models.ExtensionVersion.objects.filter(status__in=models.VISIBLE_STATUSES)
+ context_object_name = "version"
+ template_name = "extensions/error-report.html"
+
+ def post(self, request, *args, **kwargs):
+ self.object = self.get_object()
+
+ if request.POST['has_errors']:
+ errors = request.POST['error']
+ else:
+ errors = ""
+
+ comment = request.POST['comment']
+
+ if request.user.is_authenticated():
+ user, email = request.user, ""
+ else:
+ user, email = None, request.POST['email']
+
+ report = models.ErrorReport(version=self.object,
+ comment=comment,
+ errors=errors,
+ user=user,
+ email=email)
+ report.save()
+
+ models.error_reported.send(sender=self, version=self.object, report=report)
+
+ messages.info(request, "Thank you for your error report!")
+
+ return redirect('extensions-version-detail',
+ pk=self.object.pk,
+ ext_pk=self.object.extension.pk,
+ slug=self.object.extension.slug)
diff --git a/sweettooth/static/js/extensions.js b/sweettooth/static/js/extensions.js
index eb2f129..31e267b 100644
--- a/sweettooth/static/js/extensions.js
+++ b/sweettooth/static/js/extensions.js
@@ -198,12 +198,19 @@ function($, messages, dbusProxy) {
};
$.fn.fillInErrors = function (uuid) {
- var $textarea = $(this);
+ var $form = $(this);
+ var $textarea = $form.find('textarea[name=error]');
+ var $hidden = $form.find('input:hidden[name=has_errors]');
dbusProxy.GetErrors(uuid).done(function(errors) {
- if (errors && errors.length)
- $textarea.text(errors.join('\n\n'));
- else
- $textarea.text("Could not detect any errors").addClass('no-errors').attr('disabled', 'disabled');
+ if (errors && errors.length) {
+ $textarea.text(errors.join('\n\n')).
+ removeClass('no-errors').removeAttr('disabled');
+ $hidden.val('true');
+ } else {
+ $textarea.text("Could not detect any errors").
+ addClass('no-errors').attr('disabled', 'disabled');
+ $hidden.val('');
+ }
});
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]