Do not calculate processing info for anonymous user
authorBoris Bobrov <breton@cynicmansion.ru>
Fri, 5 Feb 2016 02:38:18 +0000 (05:38 +0300)
committerBoris Bobrov <breton@cynicmansion.ru>
Fri, 5 Feb 2016 02:38:18 +0000 (05:38 +0300)
mediagoblin/plugins/processing_info/__init__.py

index e5ce0a1c7968091092b07ee7f406104d50cfc521..fb824765b800e8e026db2d87f2f92701aa21af88 100644 (file)
@@ -35,12 +35,13 @@ def setup_plugin():
 def make_stats(context):
     request = context['request']
     user = request.user
-    num_queued = MediaEntry.query.filter_by(
-            actor=user.id, state=u'processing').count()
-    context['num_queued'] = num_queued
-    num_failed = MediaEntry.query.filter_by(
-            actor=user.id, state=u'failed').count()
-    context['num_failed'] = num_failed
+    if user:
+        num_queued = MediaEntry.query.filter_by(
+                actor=user.id, state=u'processing').count()
+        context['num_queued'] = num_queued
+        num_failed = MediaEntry.query.filter_by(
+                actor=user.id, state=u'failed').count()
+        context['num_failed'] = num_failed
     return context