From dc617692dc7f7b6fd48eec4a8e7445806ff4730a Mon Sep 17 00:00:00 2001 From: Carlos Vega <carlos.vega@uni.lu> Date: Mon, 30 Nov 2020 12:39:02 +0100 Subject: [PATCH] changed sidebar menu. #363 Vouchers has its own menu, kit requests is alone now and equipment/rooms/health partners are now inside configuration --- .../appointment_types/breadcrumb.html | 2 +- smash/web/templates/doctors/breadcrumb.html | 7 +- .../equipment/breadcrumb.html | 2 +- .../flying_teams/breadcrumb.html | 2 +- .../kit_requests/breadcrumb.html | 1 - .../equipment_and_rooms/rooms/breadcrumb.html | 2 +- smash/web/templates/sidebar.html | 94 ++++++++++--------- .../voucher_type_prices/breadcrumb.html | 1 + .../templates/voucher_types/breadcrumb.html | 2 +- smash/web/templates/vouchers/breadcrumb.html | 3 +- smash/web/templates/vouchers/list.html | 2 +- smash/web/views/__init__.py | 1 + smash/web/views/kit.py | 6 +- 13 files changed, 69 insertions(+), 56 deletions(-) diff --git a/smash/web/templates/appointment_types/breadcrumb.html b/smash/web/templates/appointment_types/breadcrumb.html index 2ab1c8ec..eb8c7038 100644 --- a/smash/web/templates/appointment_types/breadcrumb.html +++ b/smash/web/templates/appointment_types/breadcrumb.html @@ -1,5 +1,5 @@ <li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li> -<li><a href="{% url 'web.views.equipment_and_rooms' %}">Equipment and rooms</a></li> +<li><a>Configuration</a></li> <li class="active"> <a href="{% url 'web.views.appointment_types' %}">Appointment Types</a> </li> \ No newline at end of file diff --git a/smash/web/templates/doctors/breadcrumb.html b/smash/web/templates/doctors/breadcrumb.html index 391f87d8..fe408c61 100644 --- a/smash/web/templates/doctors/breadcrumb.html +++ b/smash/web/templates/doctors/breadcrumb.html @@ -1,7 +1,10 @@ <li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li> {% if worker_type == 'HEALTH_PARTNER' %} <li>Configuration</li> +<li class="active"><a href="{% url 'web.views.workers' %}">Workers</a></li> {% elif worker_type == 'VOUCHER_PARTNER' %} -<li>Configuration</li> +<li>Voucher</li> +<li class="active"><a href="{% url 'web.views.workers' %}">Voucher Partners</a></li> +{% else %} +<li class="active"><a href="{% url 'web.views.workers' %}">Workers</a></li> {% endif %} -<li class="active"><a href="{% url 'web.views.workers' %}">Workers</a></li> \ No newline at end of file diff --git a/smash/web/templates/equipment_and_rooms/equipment/breadcrumb.html b/smash/web/templates/equipment_and_rooms/equipment/breadcrumb.html index 7205568f..71c23fe2 100644 --- a/smash/web/templates/equipment_and_rooms/equipment/breadcrumb.html +++ b/smash/web/templates/equipment_and_rooms/equipment/breadcrumb.html @@ -1,3 +1,3 @@ <li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li> -<li><a href="{% url 'web.views.equipment_and_rooms' %}">Equipment and rooms</a></li> +<li><a>Configuration</a></li> <li class="active"><a href="{% url 'web.views.equipment' %}">Equipment definitions</a></li> diff --git a/smash/web/templates/equipment_and_rooms/flying_teams/breadcrumb.html b/smash/web/templates/equipment_and_rooms/flying_teams/breadcrumb.html index 1259da09..6743d135 100644 --- a/smash/web/templates/equipment_and_rooms/flying_teams/breadcrumb.html +++ b/smash/web/templates/equipment_and_rooms/flying_teams/breadcrumb.html @@ -1,3 +1,3 @@ <li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li> -<li><a href="{% url 'web.views.equipment_and_rooms' %}">Equipment and rooms</a></li> +<li><a>Configuration</a></li> <li class="active"><a href="{% url 'web.views.equipment_and_rooms.flying_teams' %}">Flying teams</a></li> diff --git a/smash/web/templates/equipment_and_rooms/kit_requests/breadcrumb.html b/smash/web/templates/equipment_and_rooms/kit_requests/breadcrumb.html index b2e3801a..23c6107e 100644 --- a/smash/web/templates/equipment_and_rooms/kit_requests/breadcrumb.html +++ b/smash/web/templates/equipment_and_rooms/kit_requests/breadcrumb.html @@ -1,3 +1,2 @@ <li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li> -<li><a href="{% url 'web.views.equipment_and_rooms' %}">Equipment and rooms</a></li> <li class="active"><a href="{% url 'web.views.kit_requests' %}">Kit requests</a></li> diff --git a/smash/web/templates/equipment_and_rooms/rooms/breadcrumb.html b/smash/web/templates/equipment_and_rooms/rooms/breadcrumb.html index b2ecb34d..8c39a0ac 100644 --- a/smash/web/templates/equipment_and_rooms/rooms/breadcrumb.html +++ b/smash/web/templates/equipment_and_rooms/rooms/breadcrumb.html @@ -1,3 +1,3 @@ <li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li> -<li><a href="{% url 'web.views.equipment_and_rooms' %}">Equipment and rooms</a></li> +<li><a>Configuration</a></li> <li class="active"><a href="{% url 'web.views.equipment_and_rooms.rooms' %}">Rooms</a></li> diff --git a/smash/web/templates/sidebar.html b/smash/web/templates/sidebar.html index bea2f85b..1ca1ba46 100644 --- a/smash/web/templates/sidebar.html +++ b/smash/web/templates/sidebar.html @@ -34,33 +34,12 @@ </li> {% endif %} - {% if equipment_perms %} - <li data-desc="equipment_and_rooms" class="treeview"> - <a href="{% url 'web.views.equipment_and_rooms' %}"> - <i class="fa fa-building-o"></i> <span>Equipment & Rooms</span> - <span class="pull-right-container"> - <i class="fa fa-angle-left pull-right"></i> - </span> + {% if "send_sample_mail_for_appointments" in permissions %} + <li data-desc="kit_requests"> + <a href="{% url 'web.views.kit_requests' %}"> + <i class="fa fa-truck"></i> + <span>Kit requests</span> </a> - <ul class="treeview-menu"> - {% if "change_item" in permissions %} - <li data-desc="equipment_items"><a href="{% url 'web.views.equipment' %}">Equipment items</a></li> - {% endif %} - {% if "change_appointmenttype" in permissions %} - <li data-desc="appointment_types"><a href="{% url 'web.views.appointment_types' %}">Appointment - Types</a></li> - {% endif %} - {% if "change_flyingteam" in permissions %} - <li data-desc="flying_teams"><a href="{% url 'web.views.equipment_and_rooms.flying_teams' %}">Flying - teams</a></li> - {% endif %} - {% if "send_sample_mail_for_appointments" in permissions %} - <li data-desc="kit_requests"><a href="{% url 'web.views.kit_requests' %}">Kit requests</a></li> - {% endif %} - {% if "change_room" in permissions %} - <li data-desc="rooms"><a href="{% url 'web.views.equipment_and_rooms.rooms' %}">Rooms</a></li> - {% endif %} - </ul> </li> {% endif %} @@ -92,13 +71,32 @@ </li> {% endif %} - {% if study.has_vouchers and "change_voucher" in permissions %} - <li data-desc="vouchers"> - <a href="{% url 'web.views.vouchers' %}"> - <i class="fa fa-user-md"></i> - <span>Vouchers</span> - </a> - </li> + {% if voucher_should_shown %} + <li data-desc="vouchers" class="treeview"> + <a href="#"> + <i class="fa fa-user-md"></i> <span>Vouchers</span> + <span class="pull-right-container"> + <i class="fa fa-angle-left pull-right"></i> + </span> + </a> + <ul class="treeview-menu"> + {% if study.has_vouchers and "change_voucher" in permissions %} + <li data-desc="vouchers"> + <a href="{% url 'web.views.vouchers' %}"> + Voucher List + </a> + </li> + {% endif %} + {% if study.has_voucher_types and "change_vouchertype" in permissions %} + <li data-desc="voucher_types"><a href="{% url 'web.views.voucher_types' %}">Voucher types</a></li> + {% endif %} + + {% if study.has_vouchers and "change_worker" in permissions %} + <li data-desc="voucher_partner"><a href="{% url 'web.views.workers' 'VOUCHER_PARTNER' %}">Voucher + partners</a></li> + {% endif %} + </ul> + </li> {% endif %} {% if conf_perms %} @@ -115,17 +113,16 @@ <li data-desc="settings"><a href="{% url 'web.views.configuration' %}">General</a></li> {% endif %} - {% if "change_language" in permissions %} - <li data-desc="languages"><a href="{% url 'web.views.languages' %}">Languages</a></li> + {% if "change_study" in permissions %} + <li data-desc="study_conf"><a href="{% url 'web.views.edit_study' study_id %}">Study</a></li> {% endif %} - - {% if study.has_voucher_types and "change_vouchertype" in permissions %} - <li data-desc="voucher_types"><a href="{% url 'web.views.voucher_types' %}">Voucher types</a></li> + + {% if "change_configurationitem" in permissions or "change_study" in permissions %} + <hr style="margin: 5px 20px 5px 10px; border-top-color: #6b6b6b"> {% endif %} - {% if study.has_vouchers and "change_worker" in permissions %} - <li data-desc="voucher_partner"><a href="{% url 'web.views.workers' 'VOUCHER_PARTNER' %}">Voucher - partners</a></li> + {% if "change_language" in permissions %} + <li data-desc="languages"><a href="{% url 'web.views.languages' %}">Languages</a></li> {% endif %} {% if "change_worker" in permissions %} @@ -133,8 +130,19 @@ partners</a></li> {% endif %} - {% if "change_study" in permissions %} - <li data-desc="study_conf"><a href="{% url 'web.views.edit_study' study_id %}">Study</a></li> + {% if equipment_perms and "change_appointmenttype" in permissions %} + <li data-desc="appointment_types"><a href="{% url 'web.views.appointment_types' %}">Appointment + Types</a></li> + {% endif %} + {% if equipment_perms and "change_item" in permissions %} + <li data-desc="equipment_items"><a href="{% url 'web.views.equipment' %}">Equipment items</a></li> + {% endif %} + {% if equipment_perms and "change_flyingteam" in permissions %} + <li data-desc="flying_teams"><a href="{% url 'web.views.equipment_and_rooms.flying_teams' %}">Flying + teams</a></li> + {% endif %} + {% if equipment_perms and "change_room" in permissions %} + <li data-desc="rooms"><a href="{% url 'web.views.equipment_and_rooms.rooms' %}">Rooms</a></li> {% endif %} </ul> </li> diff --git a/smash/web/templates/voucher_type_prices/breadcrumb.html b/smash/web/templates/voucher_type_prices/breadcrumb.html index 844971e6..d6d7bd90 100644 --- a/smash/web/templates/voucher_type_prices/breadcrumb.html +++ b/smash/web/templates/voucher_type_prices/breadcrumb.html @@ -1,2 +1,3 @@ <li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li> +<li>Vouchers</li> <li class="active"><a href="{% url 'web.views.voucher_types' %}">Voucher types</a></li> \ No newline at end of file diff --git a/smash/web/templates/voucher_types/breadcrumb.html b/smash/web/templates/voucher_types/breadcrumb.html index d3fe1508..d6d7bd90 100644 --- a/smash/web/templates/voucher_types/breadcrumb.html +++ b/smash/web/templates/voucher_types/breadcrumb.html @@ -1,3 +1,3 @@ <li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li> -<li>Configuration</li> +<li>Vouchers</li> <li class="active"><a href="{% url 'web.views.voucher_types' %}">Voucher types</a></li> \ No newline at end of file diff --git a/smash/web/templates/vouchers/breadcrumb.html b/smash/web/templates/vouchers/breadcrumb.html index f71acc80..b0865891 100644 --- a/smash/web/templates/vouchers/breadcrumb.html +++ b/smash/web/templates/vouchers/breadcrumb.html @@ -1,2 +1,3 @@ <li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li> -<li class="active"><a href="{% url 'web.views.vouchers' %}">Vouchers</a></li> \ No newline at end of file +<li>Vouchers</li> +<li class="active"><a href="{% url 'web.views.vouchers' %}">Voucher List</a></li> \ No newline at end of file diff --git a/smash/web/templates/vouchers/list.html b/smash/web/templates/vouchers/list.html index 99a39340..f4d47ef8 100644 --- a/smash/web/templates/vouchers/list.html +++ b/smash/web/templates/vouchers/list.html @@ -7,7 +7,7 @@ <link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}"> {% endblock styles %} -{% block ui_active_tab %}'configuration'{% endblock ui_active_tab %} +{% block ui_active_tab %}'vouchers'{% endblock ui_active_tab %} {% block page_header %}Vouchers{% endblock page_header %} {% block page_description %}{% endblock page_description %} diff --git a/smash/web/views/__init__.py b/smash/web/views/__init__.py index 0684e2c6..dbde0f77 100644 --- a/smash/web/views/__init__.py +++ b/smash/web/views/__init__.py @@ -68,6 +68,7 @@ def extend_context(params, request: HttpRequest): 'permissions' : permissions, 'conf_perms' : permissions & PermissionDecorator.codename_groups['configuration'], 'equipment_perms' : permissions & PermissionDecorator.codename_groups['equipment'], + 'voucher_should_shown': study.has_vouchers and bool({'change_voucher', 'change_vouchertype', 'change_worker'} | permissions), #at least one permission must be present and study should have vouchers 'person': person, 'role': role, 'notifications': notifications, diff --git a/smash/web/views/kit.py b/smash/web/views/kit.py index 472a3947..3a3fb57e 100644 --- a/smash/web/views/kit.py +++ b/smash/web/views/kit.py @@ -65,7 +65,7 @@ def get_kit_requests(user, start_date=None, end_date=None): return result -@PermissionDecorator('send_sample_mail_for_appointments', 'equipment') +@PermissionDecorator('send_sample_mail_for_appointments', 'kit') def get_kit_requests_data(request, start_date=None, end_date=None): form = KitRequestForm() if request.method == 'POST': @@ -82,7 +82,7 @@ def get_kit_requests_data(request, start_date=None, end_date=None): return params -@PermissionDecorator('send_sample_mail_for_appointments', 'equipment') +@PermissionDecorator('send_sample_mail_for_appointments', 'kit') def kit_requests(request): return wrap_response(request, 'equipment_and_rooms/kit_requests/kit_requests.html', get_kit_requests_data(request)) @@ -216,7 +216,7 @@ def send_mail(data): EmailSender().send_email(title, email_body, recipients, cc_recipients) -@PermissionDecorator('send_sample_mail_for_appointments', 'equipment') +@PermissionDecorator('send_sample_mail_for_appointments', 'kit') def kit_requests_send_mail(request, start_date, end_date=None): data = get_kit_requests_data(request, start_date, end_date) try: -- GitLab