[extensions-web: 42/75] Start work on error reporting.



commit 1f3eac549651d9eaaece8a5daa77bd6189fca5ca
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sat Sep 17 11:48:33 2011 -0400

    Start work on error reporting.

 .../extensions/templates/extensions/comments.html  |    9 +++-
 .../templates/extensions/error-report.html         |   23 ++++++++++
 sweettooth/extensions/urls.py                      |    7 +++-
 sweettooth/static/css/sweettooth.css               |   46 ++++++++++++++++++++
 sweettooth/static/images/face-angry.png            |  Bin 0 -> 2565 bytes
 sweettooth/static/images/face-smile.png            |  Bin 0 -> 2655 bytes
 sweettooth/static/js/extensions.js                 |   10 ++++
 7 files changed, 93 insertions(+), 2 deletions(-)
---
diff --git a/sweettooth/extensions/templates/extensions/comments.html b/sweettooth/extensions/templates/extensions/comments.html
index 84e1cbe..a26b088 100644
--- a/sweettooth/extensions/templates/extensions/comments.html
+++ b/sweettooth/extensions/templates/extensions/comments.html
@@ -4,7 +4,7 @@
   {% load gravatar %}
   {% load rating %}
   {% get_comment_list for extension as comments %}
-  {% for comment in comments %} 
+  {% for comment in comments %}
   <div class="comment">
     <img src="{% gravatar_url comment.user_email %}" class="gravatar">
     <div class="rating-author">
@@ -24,6 +24,13 @@
 <div id="new-comment-form">
   <div>
     <h4>Your opinion</h4>
+    <a href="{% url extensions-error pk=version.pk %}" class="report error">It didn't work!</a>
+    <p>
+      Errors should be reported through the error reporting tool &mdash; it
+      helps extension authors be known about bugs in their extension!
+    </p>
+
+    <span class="report rating">It worked, and...</span>
     {% render_comment_form for extension %}
   </div>
 </div>
diff --git a/sweettooth/extensions/templates/extensions/error-report.html b/sweettooth/extensions/templates/extensions/error-report.html
new file mode 100644
index 0000000..ecfe448
--- /dev/null
+++ b/sweettooth/extensions/templates/extensions/error-report.html
@@ -0,0 +1,23 @@
+{% extends "base.html" %}
+{% block title %}Report Error for "{{ version.extension.name }}" &mdash; {{ block.super }}{% endblock %}
+{% block body %}
+<h2><em>{{ version.extension.name }}</em> is malfunctioning?</h2>
+
+<p>Please look through the information below and edit out
+  any private information.</p>
+<form action="" method="POST" id="error_report">
+  <h3> Detected errors with this extension </h3>
+  <textarea name="error" id="error_log"></textarea>
+
+  <h3> Additional comments for the author </h3>
+  <textarea name="comment" id="comment"></textarea>
+
+  <input type="submit" value="Report Errors">
+</form>
+{% endblock %}
+
+{% block document-ready %}
+require(['jquery', 'extensions'], function($) {
+    $("#error_log").fillInErrors("{{ version.extension.uuid }}");
+});
+{% endblock %}
diff --git a/sweettooth/extensions/urls.py b/sweettooth/extensions/urls.py
index e677a4f..fb5c72b 100644
--- a/sweettooth/extensions/urls.py
+++ b/sweettooth/extensions/urls.py
@@ -1,6 +1,6 @@
 
 from django.conf.urls.defaults import patterns, include, url
-from django.views.generic import ListView, TemplateView
+from django.views.generic import ListView, TemplateView, DetailView
 
 from extensions import views, models
 
@@ -43,4 +43,9 @@ urlpatterns = patterns('',
     url(r'', include(shell_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'),
 )
diff --git a/sweettooth/static/css/sweettooth.css b/sweettooth/static/css/sweettooth.css
index e26688d..9c2314d 100644
--- a/sweettooth/static/css/sweettooth.css
+++ b/sweettooth/static/css/sweettooth.css
@@ -245,6 +245,52 @@ li.extension {
     padding: 0 1em;
 }
 
+.extension .report {
+    display: block;
+    height: 32px;
+    padding-left: 36px;
+    font-size: 16pt;
+    background-repeat: no-repeat;
+    margin-top: 1em;
+}
+
+.extension .report.error {
+    background-image: url(../images/face-angry.png);
+}
+
+.extension .report + p {
+    padding-left: 16px;
+    line-height: 1.7em;
+}
+
+.extension .report.rating {
+    background-image: url(../images/face-smile.png);
+}
+
+#error_report input {
+    float: right;
+}
+
+#error_report textarea {
+    display: block;
+    width: 97%;
+    resize: vertical;
+    height: 300px;
+    min-height: 80px;
+    padding: 0.5em;
+    margin: 1em;
+}
+
+#error_report textarea.no-errors {
+    color: #888;
+    font: inherit;
+    text-align: center;
+    height: 1.6em;
+    min-height: 1.6em;
+    line-height: 1.6em;
+    resize: none;
+}
+
 /* Comments */
 /* ==================================================================== */
 
diff --git a/sweettooth/static/images/face-angry.png b/sweettooth/static/images/face-angry.png
new file mode 100644
index 0000000..52612f5
Binary files /dev/null and b/sweettooth/static/images/face-angry.png differ
diff --git a/sweettooth/static/images/face-smile.png b/sweettooth/static/images/face-smile.png
new file mode 100644
index 0000000..8c9b04e
Binary files /dev/null and b/sweettooth/static/images/face-smile.png differ
diff --git a/sweettooth/static/js/extensions.js b/sweettooth/static/js/extensions.js
index a7fa12e..eb2f129 100644
--- a/sweettooth/static/js/extensions.js
+++ b/sweettooth/static/js/extensions.js
@@ -197,6 +197,16 @@ function($, messages, dbusProxy) {
         });
     };
 
+    $.fn.fillInErrors = function (uuid) {
+        var $textarea = $(this);
+        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');
+        });
+    };
+
     $.fn.addExtensionsSwitches = function () {
         var $container = $(this);
         dbusProxy.ListExtensions().done(function(extensions) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]