Commit 3305a19f authored by Skia's avatar Skia
Browse files

Fix permissions on sellings and refillings

parent 3667a121
Pipeline #152 failed with stage
in 2 minutes and 59 seconds
...@@ -135,6 +135,9 @@ class Counter(models.Model): ...@@ -135,6 +135,9 @@ class Counter(models.Model):
return reverse('counter:details', kwargs={'counter_id': self.id}) return reverse('counter:details', kwargs={'counter_id': self.id})
def is_owned_by(self, user): def is_owned_by(self, user):
mem = self.club.get_membership_for(user)
if mem and mem.role >= 7:
return True
return user.is_in_group(settings.SITH_GROUPS['counter-admin']['name']) return user.is_in_group(settings.SITH_GROUPS['counter-admin']['name'])
def can_be_viewed_by(self, user): def can_be_viewed_by(self, user):
...@@ -211,10 +214,7 @@ class Refilling(models.Model): ...@@ -211,10 +214,7 @@ class Refilling(models.Model):
return "Refilling: %.2f for %s" % (self.amount, self.customer.user.get_display_name()) return "Refilling: %.2f for %s" % (self.amount, self.customer.user.get_display_name())
def is_owned_by(self, user): def is_owned_by(self, user):
return user.can_edit(self.counter) and self.payment_method != "CARD" return user.is_owner(self.counter) and self.payment_method != "CARD"
# def get_absolute_url(self):
# return reverse('counter:details', kwargs={'counter_id': self.id})
def delete(self, *args, **kwargs): def delete(self, *args, **kwargs):
self.customer.amount -= self.amount self.customer.amount -= self.amount
...@@ -256,7 +256,7 @@ class Selling(models.Model): ...@@ -256,7 +256,7 @@ class Selling(models.Model):
self.quantity*self.unit_price, self.customer.user.get_display_name()) self.quantity*self.unit_price, self.customer.user.get_display_name())
def is_owned_by(self, user): def is_owned_by(self, user):
return user.can_edit(self.counter) and self.payment_method != "CARD" return user.is_owner(self.counter) and self.payment_method != "CARD"
def delete(self, *args, **kwargs): def delete(self, *args, **kwargs):
self.customer.amount += self.quantity * self.unit_price self.customer.amount += self.quantity * self.unit_price
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment