From 01c75c7ebaeee707271773c37f111ff9075d3656 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Sun, 14 Aug 2011 07:56:10 -0500 Subject: [PATCH] Processing panel view Now you can view your failed and in-process media items! --- mediagoblin/static/css/base.css | 12 ++++ .../user_pages/processing_panel.html | 67 +++++++++++++++++++ mediagoblin/user_pages/routing.py | 6 +- mediagoblin/user_pages/views.py | 52 +++++++++++++- 4 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 mediagoblin/templates/mediagoblin/user_pages/processing_panel.html diff --git a/mediagoblin/static/css/base.css b/mediagoblin/static/css/base.css index 59c2f49d..a421bb4d 100644 --- a/mediagoblin/static/css/base.css +++ b/mediagoblin/static/css/base.css @@ -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 index 00000000..abc7efd3 --- /dev/null +++ b/mediagoblin/templates/mediagoblin/user_pages/processing_panel.html @@ -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 . +#} +{% extends "mediagoblin/base.html" %} + +{% block mediagoblin_content %} + +

{% trans %}Media processing panel{% endtrans %}

+ +

+ {% trans %}You can track the state of media being processed for your gallery here.{% endtrans %} +

+ +

{% trans %}Media in-processing{% endtrans %}

+ +{% if processing_entries.count() %} + + + + + + + {% for media_entry in processing_entries %} + + + + + + {% endfor %} +
TitleWhen submittedStatus
{{ media_entry['title'] }}{{ media_entry['created'].strftime("%m-%d-%Y %I:%M %p") }}
+{% else %} +

{% trans %}No media in-processing{% endtrans %}

+{% endif %} + +{% if failed_entries.count() %} +

{% trans %}These uploads failed to process:{% endtrans %}

+ + + + + + + + {% for media_entry in failed_entries %} + + + + + + {% endfor %} +
TitleWhen submittedReason for failure
{{ media_entry['title'] }}{{ media_entry['created'].strftime("%m-%d-%Y %I:%M %p") }}{{ media_entry.get_fail_exception().general_message }}
+{% endif %} +{% endblock %} diff --git a/mediagoblin/user_pages/routing.py b/mediagoblin/user_pages/routing.py index 3be0617d..bf9f12ab 100644 --- a/mediagoblin/user_pages/routing.py +++ b/mediagoblin/user_pages/routing.py @@ -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"), + ] diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py index fb72a421..d4ff1fce 100644 --- a/mediagoblin/user_pages/views.py +++ b/mediagoblin/user_pages/views.py @@ -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}) -- 2.25.1