Skip to content

Commit

Permalink
🐛 Do not show appoint and approve buttons unless status is right
Browse files Browse the repository at this point in the history
  • Loading branch information
Jip J. Dekker committed Apr 27, 2017
1 parent 4c625b2 commit b5f366c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions website/involvement/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from involvement.models import Team, Role, Position, Application, \
official_of, member_of
from involvement.rules import is_admin
from involvement.rules import is_admin, approve_state, appoint_state
from utils.permissions import RulesPermissionHelper


Expand Down Expand Up @@ -157,13 +157,15 @@ def get_buttons_for_obj(self, obj, exclude=None, classnames_add=None,
ph = self.permission_helper
usr = self.request.user
pk = quote(getattr(obj, self.opts.pk.attname))
if 'approve' not in exclude and ph.user_can_approve_obj(usr, obj):
if 'approve' not in exclude and approve_state(usr, obj)\
and ph.user_can_approve_obj(usr, obj):
btns.append(
self.approve_button(
pk, classnames_add, classnames_exclude
)
)
if 'appoint' not in exclude and ph.user_can_appoint_obj(usr, obj):
if 'appoint' not in exclude and appoint_state(usr, obj)\
and ph.user_can_appoint_obj(usr, obj):
btns.append(
self.appoint_button(
pk, classnames_add, classnames_exclude
Expand Down

0 comments on commit b5f366c

Please sign in to comment.