Merge branch '512_bump_video_js'
[mediagoblin.git] / mediagoblin / admin / views.py
1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
13 #
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 from werkzeug.exceptions import Forbidden
18
19 from mediagoblin.db.util import DESCENDING
20 from mediagoblin.decorators import require_active_login
21 from mediagoblin.tools.response import render_to_response
22
23 @require_active_login
24 def admin_processing_panel(request):
25 '''
26 Show the global processing panel for this instance
27 '''
28 # TODO: Why not a "require_admin_login" decorator throwing a 403 exception?
29 if not request.user.is_admin:
30 raise Forbidden()
31
32 processing_entries = request.db.MediaEntry.find(
33 {'state': u'processing'}).sort('created', DESCENDING)
34
35 # Get media entries which have failed to process
36 failed_entries = request.db.MediaEntry.find(
37 {'state': u'failed'}).sort('created', DESCENDING)
38
39 processed_entries = request.db.MediaEntry.find(
40 {'state': u'processed'}).sort('created', DESCENDING).limit(10)
41
42 # Render to response
43 return render_to_response(
44 request,
45 'mediagoblin/admin/panel.html',
46 {'processing_entries': processing_entries,
47 'failed_entries': failed_entries,
48 'processed_entries': processed_entries})