mirror of
https://github.com/ae-utbm/sith.git
synced 2026-10-12 05:36:02 +00:00
fix permission for companies
This commit is contained in:
1 parent
554929b4ec
commit
8133db804e
1 file changed
+26
@@ -45,6 +45,32 @@ class Company(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("company")
|
verbose_name = _("company")
|
||||||
|
|
||||||
|
def is_owned_by(self, user):
|
||||||
|
"""
|
||||||
|
Method to see if that object can be edited by the given user
|
||||||
|
"""
|
||||||
|
if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def can_be_edited_by(self, user):
|
||||||
|
"""
|
||||||
|
Method to see if that object can be edited by the given user
|
||||||
|
"""
|
||||||
|
for club in user.memberships.filter(end_date=None).all():
|
||||||
|
if club and club.role == 7:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def can_be_viewed_by(self, user):
|
||||||
|
"""
|
||||||
|
Method to see if that object can be viewed by the given user
|
||||||
|
"""
|
||||||
|
for club in user.memberships.filter(end_date=None).all():
|
||||||
|
if club and club.role >= 7:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('accounting:co_edit', kwargs={'co_id': self.id})
|
return reverse('accounting:co_edit', kwargs={'co_id': self.id})
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user