mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 02:54:20 +00:00
adaptations for settings and deletion checked
This commit is contained in:
parent
92bc6cf96f
commit
9152688efd
@ -58,7 +58,7 @@ class Company(models.Model):
|
||||
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:
|
||||
if club and club.role == settings.SITH_CLUB_ROLES_ID['Treasurer']:
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -67,7 +67,7 @@ class Company(models.Model):
|
||||
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:
|
||||
if club and club.role >= settings.SITH_CLUB_ROLES_ID['Treasurer']:
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -97,7 +97,7 @@ class BankAccount(models.Model):
|
||||
if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID):
|
||||
return True
|
||||
m = self.club.get_membership_for(user)
|
||||
if m is not None and m.role >= 7:
|
||||
if m is not None and m.role >= settings.SITH_CLUB_ROLES_ID['Treasurer']:
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -129,7 +129,7 @@ class ClubAccount(models.Model):
|
||||
Method to see if that object can be edited by the given user
|
||||
"""
|
||||
m = self.club.get_membership_for(user)
|
||||
if m and m.role == 7:
|
||||
if m and m.role == settings.SITH_CLUB_ROLES_ID['Treasurer']:
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -138,7 +138,7 @@ class ClubAccount(models.Model):
|
||||
Method to see if that object can be viewed by the given user
|
||||
"""
|
||||
m = self.club.get_membership_for(user)
|
||||
if m and m.role >= 7:
|
||||
if m and m.role >= settings.SITH_CLUB_ROLES_ID['Treasurer']:
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -218,7 +218,7 @@ class Operation(models.Model):
|
||||
journal = models.ForeignKey(GeneralJournal, related_name="operations", null=False, verbose_name=_("journal"))
|
||||
amount = CurrencyField(_('amount'))
|
||||
date = models.DateField(_('date'))
|
||||
remark = models.CharField(_('comment'), max_length=128, default="", null=True, blank=True)
|
||||
remark = models.CharField(_('comment'), max_length=128, null=True, blank=True)
|
||||
mode = models.CharField(_('payment method'), max_length=255, choices=settings.SITH_ACCOUNTING_PAYMENT_METHOD)
|
||||
cheque_number = models.CharField(_('cheque number'), max_length=32, default="", null=True, blank=True)
|
||||
invoice = models.ForeignKey(SithFile, related_name='operations', verbose_name=_("invoice"), null=True, blank=True)
|
||||
|
@ -24,7 +24,9 @@
|
||||
{% for c in object.club_accounts.all() %}
|
||||
<li><a href="{{ url('accounting:club_details', c_account_id=c.id) }}">{{ c }}</a>
|
||||
- <a href="{{ url('accounting:club_edit', c_account_id=c.id) }}">{% trans %}Edit{% endtrans %}</a>
|
||||
{% if c.journals.count() == 0 %}
|
||||
- <a href="{{ url('accounting:club_delete', c_account_id=c.id) }}">{% trans %}Delete{% endtrans %}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
@ -55,7 +55,7 @@
|
||||
{% endif %}
|
||||
<td> <a href="{{ url('accounting:journal_details', j_id=j.id) }}">{% trans %}View{% endtrans %}</a>
|
||||
<a href="{{ url('accounting:journal_edit', j_id=j.id) }}">{% trans %}Edit{% endtrans %}</a>
|
||||
{% if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID) %}
|
||||
{% if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID) and j.operations.count() == 0 %}
|
||||
<a href="{{ url('accounting:journal_delete', j_id=j.id) }}">{% trans %}Delete{% endtrans %}</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
@ -67,7 +67,7 @@ class CanEditPropMixin(View):
|
||||
except: pass
|
||||
# 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)]
|
||||
if not l_id:
|
||||
if not l_id and self.get_queryset().count() != 0:
|
||||
raise PermissionDenied
|
||||
self._get_queryset = self.get_queryset
|
||||
def get_qs(self2):
|
||||
@ -89,7 +89,7 @@ class CanEditMixin(View):
|
||||
except: pass
|
||||
# If we get here, it's a ListView
|
||||
l_id = [o.id for o in self.get_queryset() if can_edit(o, request.user)]
|
||||
if not l_id:
|
||||
if not l_id and self.get_queryset().count() != 0:
|
||||
raise PermissionDenied
|
||||
self._get_queryset = self.get_queryset
|
||||
def get_qs(self2):
|
||||
@ -111,7 +111,7 @@ class CanViewMixin(View):
|
||||
except: pass
|
||||
# If we get here, it's a ListView
|
||||
l_id = [o.id for o in self.get_queryset() if can_view(o, request.user)]
|
||||
if ((not l_id) and self.get_queryset().count() != 0):
|
||||
if not l_id and self.get_queryset().count() != 0:
|
||||
raise PermissionDenied
|
||||
self._get_queryset = self.get_queryset
|
||||
def get_qs(self2):
|
||||
|
Loading…
Reference in New Issue
Block a user