From 43415f1b3ce19d979ab7f35fa969216f721eaaed Mon Sep 17 00:00:00 2001 From: octavioamu Date: Wed, 23 Sep 2020 14:48:51 -0300 Subject: [PATCH 1/2] dynamic flags --- app/app/context.py | 1 + app/dashboard/models.py | 4 ++++ app/dashboard/templates/bounty/new_bounty.html | 8 +++++--- .../templates/dashboard/hackathon/new_bounty.html | 3 ++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/app/context.py b/app/app/context.py index 98be1b21ab3..3c543eeec88 100644 --- a/app/app/context.py +++ b/app/app/context.py @@ -172,6 +172,7 @@ def preprocess(request): 'is_staff': request.user.is_staff if user_is_authenticated else False, 'is_moderator': profile.is_moderator if profile else False, 'is_alpha_tester': profile.is_alpha_tester if profile else False, + 'user_groups': list(profile.user_groups) if profile else False, 'persona_is_funder': profile.persona_is_funder if profile else False, 'persona_is_hunter': profile.persona_is_hunter if profile else False, 'pref_do_not_track': profile.pref_do_not_track if profile else False, diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 6da0f9982fd..3264bfa201e 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -3412,6 +3412,10 @@ def is_alpha_tester(self): return True return self.user.groups.filter(name='Alpha_Testers').cache().exists() if self.user else False + @property + def user_groups(self): + return self.user.groups.all().cache().values_list('name', flat=True) if self.user else False + @property def is_staff(self): """Determine whether or not the user is a staff member. diff --git a/app/dashboard/templates/bounty/new_bounty.html b/app/dashboard/templates/bounty/new_bounty.html index 82b9293771d..038d0acd885 100644 --- a/app/dashboard/templates/bounty/new_bounty.html +++ b/app/dashboard/templates/bounty/new_bounty.html @@ -97,9 +97,11 @@

Fund Issue

{% endif %} - + {% if 'polkadot_testers' in user_groups or is_staff %} + + {% endif %}