From c0058f4b2d4746add96a62e06b95eeb7b867026d Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Wed, 14 Feb 2018 13:02:20 +0100 Subject: [PATCH] subject list contain information about type of subject list --- smash/web/models/study_subject_list.py | 2 +- smash/web/templates/subjects/index.html | 4 ++-- smash/web/views/subject.py | 28 +++++++++++-------------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/smash/web/models/study_subject_list.py b/smash/web/models/study_subject_list.py index de31e3cf..8813f34b 100644 --- a/smash/web/models/study_subject_list.py +++ b/smash/web/models/study_subject_list.py @@ -9,7 +9,7 @@ SUBJECT_LIST_REQUIRE_CONTACT = "REQUIRE_CONTACT" SUBJECT_LIST_VOUCHER_EXPIRY = "VOUCHER_EXPIRY" SUBJECT_LIST_CHOICES = { - SUBJECT_LIST_GENERIC: 'Generic', + SUBJECT_LIST_GENERIC: 'Generic subject list', SUBJECT_LIST_NO_VISIT: 'Subjects without visit', SUBJECT_LIST_REQUIRE_CONTACT: 'Subjects required contact', SUBJECT_LIST_VOUCHER_EXPIRY: 'Subject with vouchers to be expired soon' diff --git a/smash/web/templates/subjects/index.html b/smash/web/templates/subjects/index.html index b3b4aaa0..4033c02d 100644 --- a/smash/web/templates/subjects/index.html +++ b/smash/web/templates/subjects/index.html @@ -8,10 +8,10 @@ {% endblock styles %} {% block ui_active_tab %}'subjects'{% endblock ui_active_tab %} -{% block page_header %}Subjects{% endblock page_header %} +{% block page_header %}{{ list_description }}{% endblock page_header %} {% block page_description %}{% endblock page_description %} -{% block title %}{{ block.super }} - Subjects{% endblock %} +{% block title %}{{ block.super }} - {{ list_description }}{% endblock %} {% block breadcrumb %} {% include "subjects/breadcrumb.html" %} diff --git a/smash/web/views/subject.py b/smash/web/views/subject.py index f8df4c1a..4237d946 100644 --- a/smash/web/views/subject.py +++ b/smash/web/views/subject.py @@ -9,19 +9,24 @@ from ..forms import VisitDetailForm, SubjectAddForm, SubjectEditForm, StudySubje from ..models import StudySubject, MailTemplate, Worker, Study from ..models.constants import GLOBAL_STUDY_ID from ..models.study_subject_list import SUBJECT_LIST_GENERIC, SUBJECT_LIST_NO_VISIT, SUBJECT_LIST_REQUIRE_CONTACT, \ - SUBJECT_LIST_VOUCHER_EXPIRY + SUBJECT_LIST_VOUCHER_EXPIRY, SUBJECT_LIST_CHOICES logger = logging.getLogger(__name__) -def subjects(request): +def subject_list(request, subject_list_type): context = { - 'list_type': SUBJECT_LIST_GENERIC, - 'worker': Worker.get_by_user(request.user) + 'list_type': subject_list_type, + 'worker': Worker.get_by_user(request.user), + 'list_description': SUBJECT_LIST_CHOICES[subject_list_type], } return wrap_response(request, 'subjects/index.html', context) +def subjects(request): + return subject_list(request, SUBJECT_LIST_GENERIC) + + def subject_add(request): study = Study.objects.filter(id=GLOBAL_STUDY_ID)[0] if request.method == 'POST': @@ -47,24 +52,15 @@ def subject_add(request): def subject_no_visits(request): - context = { - 'list_type': SUBJECT_LIST_NO_VISIT, - } - return wrap_response(request, 'subjects/index.html', context) + return subject_list(request, SUBJECT_LIST_NO_VISIT) def subject_voucher_expiry(request): - context = { - 'list_type': SUBJECT_LIST_VOUCHER_EXPIRY, - } - return wrap_response(request, 'subjects/index.html', context) + return subject_list(request, SUBJECT_LIST_VOUCHER_EXPIRY) def subject_require_contact(request): - context = { - 'list_type': SUBJECT_LIST_REQUIRE_CONTACT, - } - return wrap_response(request, 'subjects/index.html', context) + return subject_list(request, SUBJECT_LIST_REQUIRE_CONTACT) def subject_edit(request, id): -- GitLab