Fix performance issue in rights check

This commit is contained in:
Skia 2016-12-18 11:55:03 +01:00
parent 8de0d54940
commit bf6483039d

View File

@ -62,6 +62,7 @@ class CanEditPropMixin(View):
self.object = self.get_object() self.object = self.get_object()
if can_edit_prop(self.object, request.user): if can_edit_prop(self.object, request.user):
return super(CanEditPropMixin, self).dispatch(request, *arg, **kwargs) return super(CanEditPropMixin, self).dispatch(request, *arg, **kwargs)
return forbidden(request)
except: pass except: pass
# If we get here, it's a ListView # If we get here, it's a ListView
l_id = [o.id for o in self.get_queryset() if can_edit_prop(o, request.user)] l_id = [o.id for o in self.get_queryset() if can_edit_prop(o, request.user)]
@ -83,6 +84,7 @@ class CanEditMixin(View):
self.object = self.get_object() self.object = self.get_object()
if can_edit(self.object, request.user): if can_edit(self.object, request.user):
return super(CanEditMixin, self).dispatch(request, *arg, **kwargs) return super(CanEditMixin, self).dispatch(request, *arg, **kwargs)
return forbidden(request)
except: pass except: pass
# If we get here, it's a ListView # If we get here, it's a ListView
l_id = [o.id for o in self.get_queryset() if can_edit(o, request.user)] l_id = [o.id for o in self.get_queryset() if can_edit(o, request.user)]
@ -104,6 +106,7 @@ class CanViewMixin(View):
self.object = self.get_object() self.object = self.get_object()
if can_view(self.object, request.user): if can_view(self.object, request.user):
return super(CanViewMixin, self).dispatch(request, *arg, **kwargs) return super(CanViewMixin, self).dispatch(request, *arg, **kwargs)
return forbidden(request)
except: pass except: pass
# If we get here, it's a ListView # If we get here, it's a ListView
l_id = [o.id for o in self.get_queryset() if can_view(o, request.user)] l_id = [o.id for o in self.get_queryset() if can_view(o, request.user)]