Skip to content

Commit

Permalink
Fix wrong tests/permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
klmp200 committed Dec 23, 2024
1 parent ccf5118 commit 7f6fd7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions counter/tests/test_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def test_refilling_user_can_not_buy(self):
self.refill_user(
self.customer_old_can_not_buy, self.counter, 10
).status_code
== 403
== 404
)

def test_refilling_counter_success(self):
Expand Down Expand Up @@ -868,4 +868,4 @@ def test_barman(self):
self.counter.sellers.add(self.user)
self.client.force_login(self.user)
res = self.client.get(self.click_url)
assert res.status_code == 200
assert res.status_code == 403
5 changes: 4 additions & 1 deletion counter/views/click.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ def dispatch(self, request, *args, **kwargs):
if not self.customer.can_buy or self.customer.user.is_banned_counter:
return redirect(obj) # Redirect to counter

if obj.type == "OFFICE" and not obj.club.has_rights_in_club(request.user):
if obj.type == "OFFICE" and (
obj.sellers.filter(pk=request.user.pk).exists()
or not obj.club.has_rights_in_club(request.user)
):
raise PermissionDenied

if obj.type == "BAR" and (
Expand Down

0 comments on commit 7f6fd7d

Please sign in to comment.