Processing panel view
authorChristopher Allan Webber <cwebber@dustycloud.org>
Sun, 14 Aug 2011 12:56:10 +0000 (07:56 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Sun, 14 Aug 2011 12:56:10 +0000 (07:56 -0500)
Now you can view your failed and in-process media items!

mediagoblin/static/css/base.css
mediagoblin/templates/mediagoblin/user_pages/processing_panel.html [new file with mode: 0644]
mediagoblin/user_pages/routing.py
mediagoblin/user_pages/views.py

index 59c2f49d09364a8713ee6186c82f1f1f46298ada..a421bb4db81fc34f590a3755506757cbde5416b2 100644 (file)
@@ -291,3 +291,15 @@ ul.mediaentry_tags li {
   margin: 0px 5px 0px 0px;
   padding: 0px;
 }
+
+
+/* media processing panel */
+
+table.media_panel {
+  width: 100%;
+}
+
+table.media_panel th {
+  font-weight: bold;
+  padding-bottom: 4px;
+}
\ No newline at end of file
diff --git a/mediagoblin/templates/mediagoblin/user_pages/processing_panel.html b/mediagoblin/templates/mediagoblin/user_pages/processing_panel.html
new file mode 100644 (file)
index 0000000..abc7efd
--- /dev/null
@@ -0,0 +1,67 @@
+{#
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011 Free Software Foundation, Inc
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#}
+{% extends "mediagoblin/base.html" %}
+
+{% block mediagoblin_content %}
+
+<h1>{% trans %}Media processing panel{% endtrans %}</h1>
+
+<p>
+  {% trans %}You can track the state of media being processed for your gallery here.{% endtrans %}
+</p>
+    
+<h2>{% trans %}Media in-processing{% endtrans %}</h2>
+
+{% if processing_entries.count() %}
+  <table class="media_panel processing">
+    <tr>
+      <th>Title</th>
+      <th>When submitted</th>
+      <th>Status</th>
+    </tr>
+    {% for media_entry in processing_entries %}
+      <tr>
+        <td>{{ media_entry['title'] }}</td>
+        <td>{{ media_entry['created'].strftime("%m-%d-%Y %I:%M %p") }}</td>
+        <td></td>
+      </tr>
+    {% endfor %}
+  </table>
+{% else %}
+  <p><i>{% trans %}No media in-processing{% endtrans %}</i></p>
+{% endif %}  
+
+{% if failed_entries.count() %}
+  <h2>{% trans %}These uploads failed to process:{% endtrans %}</h2>
+
+  <table class="media_panel failed">
+    <tr>
+      <th>Title</th>
+      <th>When submitted</th>
+      <th>Reason for failure</th>
+    </tr>
+    {% for media_entry in failed_entries %}
+      <tr>
+        <td>{{ media_entry['title'] }}</td>
+        <td>{{ media_entry['created'].strftime("%m-%d-%Y %I:%M %p") }}</td>
+        <td>{{ media_entry.get_fail_exception().general_message }}</td>
+      </tr>
+    {% endfor %}
+  </table>
+{% endif %}  
+{% endblock %}
index 3be0617dd74e69ef99fd89e60e3a7295b65d8814..bf9f12ab287ae9c161c0a347fbf3a71de6ba6d5e 100644 (file)
@@ -33,4 +33,8 @@ user_routes = [
         controller="mediagoblin.user_pages.views:atom_feed"),
     Route('mediagoblin.user_pages.media_post_comment',
           '/{user}/m/{media}/comment/add/',
-          controller="mediagoblin.user_pages.views:media_post_comment")]
+          controller="mediagoblin.user_pages.views:media_post_comment"),
+    Route('mediagoblin.user_pages.processing_panel',
+          '/{user}/panel/',
+          controller="mediagoblin.user_pages.views:processing_panel"),
+    ]
index fb72a42187e279c26cdfd0b3509bcf280b336b76..d4ff1fcedcf834547551e120d9c2602679f794df 100644 (file)
@@ -1,4 +1,4 @@
-# GNU MediaGoblin -- federated, autonomous media hosting
+# MediaGoblin -- federated, autonomous media hosting
 # Copyright (C) 2011 Free Software Foundation, Inc
 #
 # This program is free software: you can redistribute it and/or modify
@@ -175,3 +175,53 @@ def atom_feed(request):
             url=entry.url_for_self(request.urlgen))
 
     return feed.get_response()
+
+
+@require_active_login
+def processing_panel(request):
+    """
+    Show to the user what media is still in conversion/processing...
+    and what failed, and why!
+    """
+    # Get the user
+    user = request.db.User.find_one(
+        {'username': request.matchdict['user'],
+         'status': 'active'})
+
+    # Make sure the user exists and is active
+    if not user:
+        return exc.HTTPNotFound()
+    elif user['status'] != u'active':
+        return render_to_response(
+            request,
+            'mediagoblin/user_pages/user.html',
+            {'user': user})
+
+    # XXX: Should this be a decorator?
+    #
+    # Make sure we have permission to access this user's panel.  Only
+    # admins and this user herself should be able to do so.
+    if not (user[u'_id'] == request.user[u'_id']
+            or request.user.is_admin):
+        # No?  Let's simply redirect to this user's homepage then.
+        return redirect(
+            request, 'mediagoblin.user_pages.user_home',
+            user=request.matchdict['user'])
+
+    # Get media entries which are in-processing
+    processing_entries = request.db.MediaEntry.find(
+        {'uploader': user['_id'],
+         'state': 'processing'}).sort('created', DESCENDING)
+
+    # Get media entries which have failed to process
+    failed_entries = request.db.MediaEntry.find(
+        {'uploader': user['_id'],
+         'state': 'failed'}).sort('created', DESCENDING)
+
+    # Render to response
+    return render_to_response(
+        request,
+        'mediagoblin/user_pages/processing_panel.html',
+        {'user': user,
+         'processing_entries': processing_entries,
+         'failed_entries': failed_entries})