Skip to content
Snippets Groups Projects
Commit bbe5d91b authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch 'bug/hide_vouchers_if_not_set_in_study' into 'master'

Bug/hide vouchers if not set in study

Closes #246

See merge request NCER-PD/scheduling-system!174
parents 6e08448a d6d992e2
No related branches found
No related tags found
1 merge request!174Bug/hide vouchers if not set in study
Pipeline #7080 passed
...@@ -29,3 +29,19 @@ class Study(models.Model): ...@@ -29,3 +29,19 @@ class Study(models.Model):
def __unicode__(self): def __unicode__(self):
return "%s" % self.name 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
...@@ -66,12 +66,14 @@ ...@@ -66,12 +66,14 @@
</a> </a>
</li> </li>
{% if study.has_vouchers %}
<li data-desc="vouchers"> <li data-desc="vouchers">
<a href="{% url 'web.views.vouchers' %}"> <a href="{% url 'web.views.vouchers' %}">
<i class="fa fa-user-md"></i> <i class="fa fa-user-md"></i>
<span>Vouchers</span> <span>Vouchers</span>
</a> </a>
</li> </li>
{% endif %}
<li data-desc="configuration" class="treeview"> <li data-desc="configuration" class="treeview">
<a href="#"> <a href="#">
...@@ -83,8 +85,12 @@ ...@@ -83,8 +85,12 @@
<ul class="treeview-menu"> <ul class="treeview-menu">
<li><a href="{% url 'web.views.configuration' %}">General</a></li> <li><a href="{% url 'web.views.configuration' %}">General</a></li>
<li><a href="{% url 'web.views.languages' %}">Languages</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> <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> <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.workers' 'HEALTH_PARTNER' %}">Health partners</a></li>
<li><a href="{% url 'web.views.edit_study' study_id %}">Study</a></li> <li><a href="{% url 'web.views.edit_study' study_id %}">Study</a></li>
</ul> </ul>
......
...@@ -5,7 +5,7 @@ from django.views.generic.base import ContextMixin ...@@ -5,7 +5,7 @@ from django.views.generic.base import ContextMixin
from web.models.constants import GLOBAL_STUDY_ID from web.models.constants import GLOBAL_STUDY_ID
from notifications import get_notifications from notifications import get_notifications
from ..models import Worker from ..models import Worker, Study
handler404 = 'web.views.e404_page_not_found' handler404 = 'web.views.e404_page_not_found'
handler500 = 'web.views.e500_error' handler500 = 'web.views.e500_error'
...@@ -54,11 +54,13 @@ def extend_context(params, request): ...@@ -54,11 +54,13 @@ def extend_context(params, request):
role = '<No worker information>' role = '<No worker information>'
notifications = get_notifications(request.user) notifications = get_notifications(request.user)
final_params = params.copy() final_params = params.copy()
study = Study.get_by_id(GLOBAL_STUDY_ID)
final_params.update({ final_params.update({
'person': person, 'person': person,
'role': role, 'role': role,
'notifications': notifications, 'notifications': notifications,
'study_id': GLOBAL_STUDY_ID 'study_id': GLOBAL_STUDY_ID,
'study' : study
}) })
return final_params return final_params
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment