Skip to contentSkip to conversation

series.py: return bundle objects only when authenticated

PATCH New Jose Lamego 1 participant 1 message Mar 9, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 series.py: return bundle objects only when authenticated

If a non-authenticated user tries to get a series view from patchwork web UI, a 500 error message is displayed caused by the database access attempted when filtering the bundle objects.

This change allows not-logged users to acces series view by returning an empty bundle variable, instead of trying to access the database.

---
 patchwork/views/series.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
patchwork/views/series.py +4 -1
index cb3b721..765d2e5 100644
@@ -48,7 +48,10 @@ class SeriesView(View):
         revisions = get_list_or_404(SeriesRevision, series=series)
         patchform = PatchForm(project=series.project)
         createbundleform = CreateBundleForm()
-        bundles = Bundle.objects.filter(owner=request.user)
+        if request.user.is_authenticated():
+            bundles = Bundle.objects.filter(owner=request.user)
+        else:
+            bundles=""
         for revision in revisions:
             revision.patch_list = revision.ordered_patches().\
                 select_related('state', 'submitter')
Signature · 1 line
2.7.4