diff --git a/smash/web/models/study.py b/smash/web/models/study.py index 4501a3be57d712de4cb3f35cf77eae8a9407c67a..bfff2a6e067dd09fdb9803f4a261ec57c5412547 100644 --- a/smash/web/models/study.py +++ b/smash/web/models/study.py @@ -29,3 +29,19 @@ class Study(models.Model): def __unicode__(self): return "%s" % self.name + + @property + def has_voucher_types(self): + return self.columns.voucher_types + + @property + def has_vouchers(self): + return self.columns.vouchers + + @staticmethod + def get_by_id(study_id): + study = Study.objects.filter(id=study_id) + if len(study) > 0: + return study[0] + else: + return None \ No newline at end of file diff --git a/smash/web/templates/sidebar.html b/smash/web/templates/sidebar.html index 1816f05cdc961a653d62180b1805e846dec2ac06..f4b3c8575046b51a695816f564e40c7e02272e37 100644 --- a/smash/web/templates/sidebar.html +++ b/smash/web/templates/sidebar.html @@ -66,12 +66,14 @@ </a> </li> + {% if study.has_vouchers %} <li data-desc="vouchers"> <a href="{% url 'web.views.vouchers' %}"> <i class="fa fa-user-md"></i> <span>Vouchers</span> </a> </li> + {% endif %} <li data-desc="configuration" class="treeview"> <a href="#"> @@ -83,8 +85,12 @@ <ul class="treeview-menu"> <li><a href="{% url 'web.views.configuration' %}">General</a></li> <li><a href="{% url 'web.views.languages' %}">Languages</a></li> + {% if study.has_voucher_types %} <li><a href="{% url 'web.views.voucher_types' %}">Voucher types</a></li> + {% endif %} + {% if study.has_vouchers %} <li><a href="{% url 'web.views.workers' 'VOUCHER_PARTNER' %}">Voucher partners</a></li> + {% endif %} <li><a href="{% url 'web.views.workers' 'HEALTH_PARTNER' %}">Health partners</a></li> <li><a href="{% url 'web.views.edit_study' study_id %}">Study</a></li> </ul> diff --git a/smash/web/views/__init__.py b/smash/web/views/__init__.py index b3624a8449ff7865816136ccbaff18c180ab7f6a..fa58ba75a4ac649f8e573ce6a4cc339583d5c402 100644 --- a/smash/web/views/__init__.py +++ b/smash/web/views/__init__.py @@ -5,7 +5,7 @@ from django.views.generic.base import ContextMixin from web.models.constants import GLOBAL_STUDY_ID from notifications import get_notifications -from ..models import Worker +from ..models import Worker, Study handler404 = 'web.views.e404_page_not_found' handler500 = 'web.views.e500_error' @@ -54,11 +54,13 @@ def extend_context(params, request): role = '<No worker information>' notifications = get_notifications(request.user) final_params = params.copy() + study = Study.get_by_id(GLOBAL_STUDY_ID) final_params.update({ 'person': person, 'role': role, 'notifications': notifications, - 'study_id': GLOBAL_STUDY_ID + 'study_id': GLOBAL_STUDY_ID, + 'study' : study }) return final_params