From fd5427eefa227164b28cbfdb7fbc797ecdce90f3 Mon Sep 17 00:00:00 2001 From: Francesco Filicetti Date: Fri, 7 Jun 2024 08:49:37 +0200 Subject: [PATCH] fix: templates --- .../uni_ticket/templatetags/uni_ticket_tags.py | 1 + uniticket/uni_ticket/views/manager.py | 7 ++++--- .../manager/category_add_ticket_user.html | 15 +++++++++++++++ .../templates/manager/office_add_operator.html | 15 +++++++++++++++ .../templates/manager/settings_add_manager.html | 15 +++++++++++++++ 5 files changed, 50 insertions(+), 3 deletions(-) diff --git a/uniticket/uni_ticket/templatetags/uni_ticket_tags.py b/uniticket/uni_ticket/templatetags/uni_ticket_tags.py index b248b30a..be098eac 100644 --- a/uniticket/uni_ticket/templatetags/uni_ticket_tags.py +++ b/uniticket/uni_ticket/templatetags/uni_ticket_tags.py @@ -156,6 +156,7 @@ def uni_ticket_settings_value(name, **kwargs): @register.simple_tag def obj_get_attr(obj, attr, **kwargs): + if type(obj) == dict: return obj.get(attr, None) return getattr(obj, attr, None) diff --git a/uniticket/uni_ticket/views/manager.py b/uniticket/uni_ticket/views/manager.py index 9ed740df..210bdd8b 100644 --- a/uniticket/uni_ticket/views/manager.py +++ b/uniticket/uni_ticket/views/manager.py @@ -19,6 +19,7 @@ from uni_ticket.forms import * from uni_ticket.models import * from uni_ticket.protocol_utils import ticket_protocol +from uni_ticket.settings import EMPLOYEE_ATTRIBUTE_NAME from uni_ticket.utils import ( base_context, custom_message, @@ -489,7 +490,7 @@ def office_add_operator(request, structure_slug, office_slug, structure): all_users = get_user_model().objects.filter(q_filter, is_active=True)\ .values("pk", "taxpayer_id", "last_name", "first_name", - "email") + "email", EMPLOYEE_ATTRIBUTE_NAME) paginator = Paginator(all_users, 20) page = request.GET.get("page") users = paginator.get_page(page) @@ -940,7 +941,7 @@ def category_add_ticket_user(request, structure_slug, category_slug, structure): all_users = get_user_model().objects.filter(q_filter, is_active=True)\ .values("pk", "taxpayer_id", "last_name", "first_name", - "email") + "email", EMPLOYEE_ATTRIBUTE_NAME) paginator = Paginator(all_users, 20) page = request.GET.get("page") users = paginator.get_page(page) @@ -3195,7 +3196,7 @@ def manager_settings_add_manager(request, structure_slug, structure): all_users = get_user_model().objects.filter(q_filter, is_active=True)\ .values("pk", "taxpayer_id", "last_name", "first_name", - "email") + "email", EMPLOYEE_ATTRIBUTE_NAME) paginator = Paginator(all_users, 20) page = request.GET.get("page") users = paginator.get_page(page) diff --git a/uniticket/uni_ticket_bootstrap_italia_template/templates/manager/category_add_ticket_user.html b/uniticket/uni_ticket_bootstrap_italia_template/templates/manager/category_add_ticket_user.html index b5349b6b..4002df4d 100644 --- a/uniticket/uni_ticket_bootstrap_italia_template/templates/manager/category_add_ticket_user.html +++ b/uniticket/uni_ticket_bootstrap_italia_template/templates/manager/category_add_ticket_user.html @@ -2,6 +2,7 @@ {% load i18n %} {% load static %} +{% load uni_ticket_tags %} {% block menu_links %} {% include 'manager/main_menu.html' %} @@ -41,6 +42,7 @@ {% trans "Cognome" %} {% trans "Nome" %} {% trans "Email" %} + {% trans "Staff" %} {% for user in users %} @@ -53,6 +55,19 @@ {{ user.last_name }} {{ user.first_name }} {{ user.email }} + + {% uni_ticket_settings_value "EMPLOYEE_ATTRIBUTE_NAME" as employee_attribute_name %} + {% obj_get_attr user employee_attribute_name as user_employee_attribute %} + {% if user_employee_attribute %} + + + + {% else %} + + + + {% endif %} +