Commit | Line | Data |
---|---|---|
808eac00 JW |
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 | ||
cfa92229 SS |
17 | from werkzeug.exceptions import Forbidden |
18 | ||
b0c8328e | 19 | from mediagoblin.db.models import MediaEntry |
808eac00 | 20 | from mediagoblin.decorators import require_active_login |
cfa92229 | 21 | from mediagoblin.tools.response import render_to_response |
808eac00 JW |
22 | |
23 | @require_active_login | |
24 | def admin_processing_panel(request): | |
25 | ''' | |
26 | Show the global processing panel for this instance | |
27 | ''' | |
60de3209 | 28 | # TODO: Why not a "require_admin_login" decorator throwing a 403 exception? |
808eac00 | 29 | if not request.user.is_admin: |
cfa92229 | 30 | raise Forbidden() |
808eac00 | 31 | |
0efe9e27 SS |
32 | processing_entries = MediaEntry.query.filter_by(state = u'processing').\ |
33 | order_by(MediaEntry.created.desc()) | |
808eac00 JW |
34 | |
35 | # Get media entries which have failed to process | |
0efe9e27 SS |
36 | failed_entries = MediaEntry.query.filter_by(state = u'failed').\ |
37 | order_by(MediaEntry.created.desc()) | |
808eac00 | 38 | |
0efe9e27 SS |
39 | processed_entries = MediaEntry.query.filter_by(state = u'processed').\ |
40 | order_by(MediaEntry.created.desc()).limit(10) | |
808eac00 JW |
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}) |