Commit 9152688e authored by Krophil's avatar Krophil
Browse files

adaptations for settings and deletion checked

parent 92bc6cf9
Pipeline #777 passed with stage
in 3 minutes and 16 seconds
...@@ -58,7 +58,7 @@ class Company(models.Model): ...@@ -58,7 +58,7 @@ class Company(models.Model):
Method to see if that object can be edited by the given user Method to see if that object can be edited by the given user
""" """
for club in user.memberships.filter(end_date=None).all(): 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 True
return False return False
...@@ -67,7 +67,7 @@ class Company(models.Model): ...@@ -67,7 +67,7 @@ class Company(models.Model):
Method to see if that object can be viewed by the given user Method to see if that object can be viewed by the given user
""" """
for club in user.memberships.filter(end_date=None).all(): 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 True
return False return False
...@@ -97,7 +97,7 @@ class BankAccount(models.Model): ...@@ -97,7 +97,7 @@ class BankAccount(models.Model):
if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID): if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID):
return True return True
m = self.club.get_membership_for(user) 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 True
return False return False
...@@ -129,7 +129,7 @@ class ClubAccount(models.Model): ...@@ -129,7 +129,7 @@ class ClubAccount(models.Model):
Method to see if that object can be edited by the given user Method to see if that object can be edited by the given user
""" """
m = self.club.get_membership_for(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 True
return False return False
...@@ -138,7 +138,7 @@ class ClubAccount(models.Model): ...@@ -138,7 +138,7 @@ class ClubAccount(models.Model):
Method to see if that object can be viewed by the given user Method to see if that object can be viewed by the given user
""" """
m = self.club.get_membership_for(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 True
return False return False
...@@ -218,7 +218,7 @@ class Operation(models.Model): ...@@ -218,7 +218,7 @@ class Operation(models.Model):
journal = models.ForeignKey(GeneralJournal, related_name="operations", null=False, verbose_name=_("journal")) journal = models.ForeignKey(GeneralJournal, related_name="operations", null=False, verbose_name=_("journal"))
amount = CurrencyField(_('amount')) amount = CurrencyField(_('amount'))
date = models.DateField(_('date')) 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) 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) 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) invoice = models.ForeignKey(SithFile, related_name='operations', verbose_name=_("invoice"), null=True, blank=True)
......
...@@ -24,7 +24,9 @@ ...@@ -24,7 +24,9 @@
{% for c in object.club_accounts.all() %} {% for c in object.club_accounts.all() %}
<li><a href="{{ url('accounting:club_details', c_account_id=c.id) }}">{{ c }}</a> <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> - <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> - <a href="{{ url('accounting:club_delete', c_account_id=c.id) }}">{% trans %}Delete{% endtrans %}</a>
{% endif %}
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
{% endif %} {% endif %}
<td> <a href="{{ url('accounting:journal_details', j_id=j.id) }}">{% trans %}View{% endtrans %}</a> <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> <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> <a href="{{ url('accounting:journal_delete', j_id=j.id) }}">{% trans %}Delete{% endtrans %}</a>
{% endif %} {% endif %}
</td> </td>
......
...@@ -67,7 +67,7 @@ class CanEditPropMixin(View): ...@@ -67,7 +67,7 @@ class CanEditPropMixin(View):
except: pass except: pass
# If we get here, it's a ListView # 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)] 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 raise PermissionDenied
self._get_queryset = self.get_queryset self._get_queryset = self.get_queryset
def get_qs(self2): def get_qs(self2):
...@@ -89,7 +89,7 @@ class CanEditMixin(View): ...@@ -89,7 +89,7 @@ class CanEditMixin(View):
except: pass except: pass
# If we get here, it's a ListView # If we get here, it's a ListView
l_id = [o.id for o in self.get_queryset() if can_edit(o, request.user)] 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 raise PermissionDenied
self._get_queryset = self.get_queryset self._get_queryset = self.get_queryset
def get_qs(self2): def get_qs(self2):
...@@ -111,7 +111,7 @@ class CanViewMixin(View): ...@@ -111,7 +111,7 @@ class CanViewMixin(View):
except: pass except: pass
# If we get here, it's a ListView # If we get here, it's a ListView
l_id = [o.id for o in self.get_queryset() if can_view(o, request.user)] 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 raise PermissionDenied
self._get_queryset = self.get_queryset self._get_queryset = self.get_queryset
def get_qs(self2): def get_qs(self2):
......
Supports Markdown
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