Skip to content

Commit

Permalink
Fix repeater and club update view permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
elnappo committed May 21, 2019
1 parent 3c81081 commit 77bebce
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions project_novis/callsign/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ def dispatch(self, request, *args, **kwargs):
slug = self.kwargs.get(self.slug_url_kwarg)
try:
callsign_instance = Callsign.objects.get(name=slug)
if callsign_instance.owner != request.user:
if request.user.is_authenticated and callsign_instance.owner != request.user:
return HttpResponseForbidden()
elif not request.user.is_authenticated:
return super().dispatch(request, *args, **kwargs)
self.model.objects.create(callsign=callsign_instance, created_by_id=request.user.id)
except Callsign.DoesNotExist:
raise Http404(_("No callsign found matching the query") %
Expand Down Expand Up @@ -135,8 +137,10 @@ def dispatch(self, request, *args, **kwargs):
slug = self.kwargs.get(self.slug_url_kwarg)
try:
callsign_instance = Callsign.objects.get(name=slug)
if callsign_instance.owner != request.user:
if request.user.is_authenticated and callsign_instance.owner != request.user:
return HttpResponseForbidden()
elif not request.user.is_authenticated:
return super().dispatch(request, *args, **kwargs)
self.model.objects.create(callsign=callsign_instance, created_by_id=request.user.id)
except Callsign.DoesNotExist:
raise Http404(_("No callsign found matching the query") %
Expand Down

0 comments on commit 77bebce

Please sign in to comment.