Skip to content

Commit

Permalink
fix: getting settings value
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed Feb 21, 2023
1 parent 78701e4 commit 91d4ee2
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 57 deletions.
4 changes: 2 additions & 2 deletions publiccode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ name: uniTicket
platforms:
- linux
- web
releaseDate: '2023-02-17'
releaseDate: '2023-02-21'
roadmap: 'https://github.com/UniversitaDellaCalabria/uniTicket/issues'
softwareType: standalone/web
softwareVersion: v2.4.0
softwareVersion: v2.4.1
url: 'https://github.com/UniversitaDellaCalabria/uniTicket'
usedBy:
- Università della Calabria - https://www.unical.it
Expand Down
3 changes: 2 additions & 1 deletion uniticket/organizational_area/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from django.utils import timezone
from django.utils.text import slugify

from organizational_area.settings import DEFAULT_ORGANIZATIONAL_STRUCTURE_OFFICE, DEFAULT_ORGANIZATIONAL_STRUCTURE_OFFICE_DESC
from organizational_area.settings import (DEFAULT_ORGANIZATIONAL_STRUCTURE_OFFICE,
DEFAULT_ORGANIZATIONAL_STRUCTURE_OFFICE_DESC)

from . decorators import disable_for_loaddata
from . models import (OrganizationalStructure,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django import template

from organizational_area import settings
from organizational_area.models import OrganizationalStructureOfficeEmployee


Expand All @@ -16,3 +17,11 @@ def employee_offices(user, structure=None):
if structure:
oe = oe.filter(office__organizational_structure=structure)
return oe


@register.simple_tag
def organizational_area_settings_value(name, **kwargs):
value = getattr(settings, name, None)
if value and kwargs:
return value.format(**kwargs)
return value
3 changes: 2 additions & 1 deletion uniticket/uni_ticket/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,8 @@
]
)

STATS_SHOW_TICKETS_BY_USER = True
STATS_SHOW_TICKETS_BY_USER = getattr(
settings, 'STATS_SHOW_TICKETS_BY_USER', True)

PRECOMPILED_TICKET_EXPIRE_DAYS = getattr(
settings, 'PRECOMPILED_TICKET_EXPIRE_DAYS', 7)
Expand Down
6 changes: 2 additions & 4 deletions uniticket/uni_ticket/templatetags/uni_ticket_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,8 @@ def user_operator_chat(user, structure):


@register.simple_tag
def settings_value(name, **kwargs):
value = getattr(settings, name) \
if hasattr(settings, name) \
else getattr(uni_ticket_settings, name, None)
def uni_ticket_settings_value(name, **kwargs):
value = getattr(uni_ticket_settings, name, None)
if value and kwargs:
return value.format(**kwargs)
return value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% load i18n %}
{% load static %}
{% load uni_ticket_tags %}
{% load uni_ticket_bootstrap_italia_tags %}


{% block top_buttons %}
Expand Down Expand Up @@ -52,7 +53,7 @@
</script>
<!-- datetime picker -->
<script>
{% settings_value "JS_DEFAULT_DATETIME_FORMAT" as js_default_datetime_value %}
{% uni_ticket_settings_value "JS_DEFAULT_DATETIME_FORMAT" as js_default_datetime_value %}
{% settings_value "LANGUAGE_CODE" as language_code %}

$(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% load static %}

{% load uni_ticket_tags %}
{% load uni_ticket_bootstrap_italia_tags %}

{% if request.user.is_authenticated %}
{% not_a_simple_user request.user as not_a_simple_user %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ <h6 class="text-muted">{% trans "Richieste chiuse per operatore" %}</h6>
</div>
</div>

{% settings_value "STATS_SHOW_TICKETS_BY_USER" as stats_show_tickets_by_user %}
{% uni_ticket_settings_value "STATS_SHOW_TICKETS_BY_USER" as stats_show_tickets_by_user %}
{% if stats_show_tickets_by_user %}
<div class="row">
<div class="col">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

{% load i18n %}
{% load static %}
{% load organizational_area_tags %}
{% load uni_ticket_tags %}

{% block right_button %}
Expand Down Expand Up @@ -30,9 +31,9 @@

{% block top_buttons %}
{% ticket_is_open ticket as is_open %}
{% settings_value name="MANAGER_PREFIX" as manager_label %}
{% settings_value name="OPERATOR_PREFIX" as operator_label %}
{% settings_value name="DEFAULT_ORGANIZATIONAL_STRUCTURE_OFFICE" as default_office %}
{% organizational_area_settings_value name="DEFAULT_ORGANIZATIONAL_STRUCTURE_OFFICE" as default_office %}
{% uni_ticket_settings_value name="MANAGER_PREFIX" as manager_label %}
{% uni_ticket_settings_value name="OPERATOR_PREFIX" as operator_label %}

{% if untaken_user_offices and not ticket.is_closed %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
{{ category.not_available_message }}
{% else %}
{% trans "Messaggio predefinito:" %}
{% settings_value "UNAVAILABLE_TICKET_CATEGORY" as default_unavailable_message %}
{% uni_ticket_settings_value "UNAVAILABLE_TICKET_CATEGORY" as default_unavailable_message %}
{{ default_unavailable_message }}
{% endif %}
</td>
Expand Down Expand Up @@ -209,7 +209,7 @@ <h5 class="modal-title">
{{ category.confirm_message_text }}
{% else %}
{% trans "Messaggio predefinito:" %}
{% settings_value "NEW_TICKET_CREATED_ALERT" as default_message %}
{% uni_ticket_settings_value "NEW_TICKET_CREATED_ALERT" as default_message %}
{{ default_message }}
{% endif %}
</td>
Expand Down Expand Up @@ -285,7 +285,7 @@ <h5 class="modal-title">
</td>
</tr>
<tr>
{% settings_value name="ORGANIZATION_USER_LABEL" as organization_user_label %}
{% uni_ticket_settings_value name="ORGANIZATION_USER_LABEL" as organization_user_label %}
<th scope="row">{% trans "Accessibile a" %} {{ organization_user_label }}</th>
<td>
<svg class="icon icon-sm icon-secondary">
Expand All @@ -298,7 +298,7 @@ <h5 class="modal-title">
</td>
</tr>
<tr>
{% settings_value name="ORGANIZATION_EMPLOYEE_LABEL" as organization_employee_label %}
{% uni_ticket_settings_value name="ORGANIZATION_EMPLOYEE_LABEL" as organization_employee_label %}
<th scope="row">{% trans "Accessibile a" %} {{ organization_employee_label }}</th>
<td>
<svg class="icon icon-sm icon-secondary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

{% if ticket.input_module.ticket_category.show_heading_text %}
<p class="card-title text-left">
{% settings_value name="TICKET_HEADING_TEXT" user=ticket.created_by taxpayer=ticket.created_by.taxpayer_id category=ticket.input_module.ticket_category as heading %}
{% uni_ticket_settings_value name="TICKET_HEADING_TEXT" user=ticket.created_by taxpayer=ticket.created_by.taxpayer_id category=ticket.input_module.ticket_category as heading %}
{{ heading|safe }}
{% settings_value "EMPLOYEE_ATTRIBUTE_NAME" as employee_attribute_name %}
{% settings_value "EMPLOYEE_ATTRIBUTE_LABEL" as employee_attribute_label %}
{% uni_ticket_settings_value "EMPLOYEE_ATTRIBUTE_NAME" as employee_attribute_name %}
{% uni_ticket_settings_value "EMPLOYEE_ATTRIBUTE_LABEL" as employee_attribute_label %}
{% obj_get_attr ticket.created_by employee_attribute_name as user_employee_attribute %}
{% if user_employee_attribute %}
<br><span class="x-small"><b>{{ employee_attribute_label }}</b>: {{user_employee_attribute}}</span>
{% endif %}
{% settings_value "USER_ATTRIBUTE_NAME" as user_attribute_name %}
{% settings_value "USER_ATTRIBUTE_LABEL" as user_attribute_label %}
{% uni_ticket_settings_value "USER_ATTRIBUTE_NAME" as user_attribute_name %}
{% uni_ticket_settings_value "USER_ATTRIBUTE_LABEL" as user_attribute_label %}
{% obj_get_attr ticket.created_by user_attribute_name as user_user_attribute %}
{% if user_user_attribute %}
<br><span class="x-small"><b>{{ user_attribute_label }}</b>: {{user_user_attribute}}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{% endif %}
<!-- stupid var passed to template only to
check if current user is manager/operator -->
{% settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% uni_ticket_settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% if not is_simple_user or user_show_priority %}
<tr>
<th scope="row">{% trans 'Priorità' %}</th>
Expand All @@ -43,14 +43,14 @@
{% if ticket.created_by.taxpayer_id %}
<br><b>{% trans "Codice fiscale" %}</b>: {{ticket.created_by.taxpayer_id}}
{% endif %}
{% settings_value "EMPLOYEE_ATTRIBUTE_NAME" as employee_attribute_name %}
{% settings_value "EMPLOYEE_ATTRIBUTE_LABEL" as employee_attribute_label %}
{% uni_ticket_settings_value "EMPLOYEE_ATTRIBUTE_NAME" as employee_attribute_name %}
{% uni_ticket_settings_value "EMPLOYEE_ATTRIBUTE_LABEL" as employee_attribute_label %}
{% obj_get_attr ticket.created_by employee_attribute_name as user_employee_attribute %}
{% if user_employee_attribute %}
<br><b>{{ employee_attribute_label }}</b>: {{user_employee_attribute}}
{% endif %}
{% settings_value "USER_ATTRIBUTE_NAME" as user_attribute_name %}
{% settings_value "USER_ATTRIBUTE_LABEL" as user_attribute_label %}
{% uni_ticket_settings_value "USER_ATTRIBUTE_NAME" as user_attribute_name %}
{% uni_ticket_settings_value "USER_ATTRIBUTE_LABEL" as user_attribute_label %}
{% obj_get_attr ticket.created_by user_attribute_name as user_user_attribute %}
{% if user_user_attribute %}
<br><b>{{ user_attribute_label }}</b>: {{user_user_attribute}}
Expand All @@ -71,14 +71,14 @@
{% if ticket.compiled_by.taxpayer_id %}
<br><b>{% trans "Codice fiscale" %}</b>: {{ticket.compiled_by.taxpayer_id}}
{% endif %}
{% settings_value "EMPLOYEE_ATTRIBUTE_NAME" as employee_attribute_name %}
{% settings_value "EMPLOYEE_ATTRIBUTE_LABEL" as employee_attribute_label %}
{% uni_ticket_settings_value "EMPLOYEE_ATTRIBUTE_NAME" as employee_attribute_name %}
{% uni_ticket_settings_value "EMPLOYEE_ATTRIBUTE_LABEL" as employee_attribute_label %}
{% obj_get_attr ticket.compiled_by employee_attribute_name as user_employee_attribute %}
{% if user_employee_attribute %}
<br><b>{{ employee_attribute_label }}</b>: {{user_employee_attribute}}
{% endif %}
{% settings_value "USER_ATTRIBUTE_NAME" as user_attribute_name %}
{% settings_value "USER_ATTRIBUTE_LABEL" as user_attribute_label %}
{% uni_ticket_settings_value "USER_ATTRIBUTE_NAME" as user_attribute_name %}
{% uni_ticket_settings_value "USER_ATTRIBUTE_LABEL" as user_attribute_label %}
{% obj_get_attr ticket.compiled_by user_attribute_name as user_user_attribute %}
{% if user_user_attribute %}
<br><b>{{ user_attribute_label }}</b>: {{user_user_attribute}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
{% endblock top_buttons %}

{% block page_content %}
{% settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% uni_ticket_settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% include 'datatables/table.html' with user_show_priority=user_show_priority %}
{% endblock page_content %}

{% block extra_scripts %}
{% settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% uni_ticket_settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% url 'uni_ticket:user_ticket_url' as var_url %}
{% url 'uni_ticket:user_closed_ticket_json' as ajax_url %}
{% include 'datatables/datatable_script.html' with var_url=var_url ajax_url=ajax_url is_simple_user=request.user user_show_priority=user_show_priority %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@
{% endblock top_buttons %}

{% block page_content %}
{% settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% uni_ticket_settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% include 'datatables/table.html' with user_show_priority=user_show_priority %}
{% endblock page_content %}


{% block extra_scripts %}
{% settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% uni_ticket_settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% url 'uni_ticket:user_ticket_url' as var_url %}
{% url 'uni_ticket:user_all_tickets_json' as ajax_url %}
{% include 'datatables/datatable_script.html' with var_url=var_url ajax_url=ajax_url user_show_priority=user_show_priority %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
{% endblock top_buttons %}

{% block page_content %}
{% settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% uni_ticket_settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% include 'datatables/table.html' with user_show_priority=user_show_priority %}
{% endblock page_content %}

{% block extra_scripts %}
{% settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% uni_ticket_settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% url 'uni_ticket:user_ticket_url' as var_url %}
{% url 'uni_ticket:user_opened_ticket_json' as ajax_url %}
{% include 'datatables/datatable_script.html' with var_url=var_url ajax_url=ajax_url user_show_priority=user_show_priority %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,33 @@
<div class="card-body">
{% if categoria.show_heading_text and request.user.is_authenticated %}
<p class="card-title text-left">
{% settings_value name="TICKET_HEADING_TEXT" user=request.user taxpayer=request.user.taxpayer_id as heading %}
{% uni_ticket_settings_value name="TICKET_HEADING_TEXT" user=request.user taxpayer=request.user.taxpayer_id as heading %}
{{ heading|safe }}
{% settings_value "EMPLOYEE_ATTRIBUTE_NAME" as employee_attribute_name %}
{% settings_value "EMPLOYEE_ATTRIBUTE_LABEL" as employee_attribute_label %}
{% uni_ticket_settings_value "EMPLOYEE_ATTRIBUTE_NAME" as employee_attribute_name %}
{% uni_ticket_settings_value "EMPLOYEE_ATTRIBUTE_LABEL" as employee_attribute_label %}
{% obj_get_attr request.user employee_attribute_name as user_employee_attribute %}
{% if user_employee_attribute %}
<br><span class="x-small"><b>{{ employee_attribute_label }}</b>: {{user_employee_attribute}}</span>
{% endif %}
{% settings_value "USER_ATTRIBUTE_NAME" as user_attribute_name %}
{% settings_value "USER_ATTRIBUTE_LABEL" as user_attribute_label %}
{% uni_ticket_settings_value "USER_ATTRIBUTE_NAME" as user_attribute_name %}
{% uni_ticket_settings_value "USER_ATTRIBUTE_LABEL" as user_attribute_label %}
{% obj_get_attr request.user user_attribute_name as user_user_attribute %}
{% if user_user_attribute %}
<br><span class="x-small"><b>{{ user_attribute_label }}</b>: {{user_user_attribute}}</span>
{% endif %}
</p>
{% if compiled_by %}
<p class="card-title text-left">
{% settings_value name="TICKET_COMPILED_HEADING_TEXT" user=compiled_by taxpayer=compiled_by.taxpayer_id as heading %}
{% uni_ticket_settings_value name="TICKET_COMPILED_HEADING_TEXT" user=compiled_by taxpayer=compiled_by.taxpayer_id as heading %}
{{ heading|safe }}
{% settings_value "EMPLOYEE_ATTRIBUTE_NAME" as employee_attribute_name %}
{% settings_value "EMPLOYEE_ATTRIBUTE_LABEL" as employee_attribute_label %}
{% uni_ticket_settings_value "EMPLOYEE_ATTRIBUTE_NAME" as employee_attribute_name %}
{% uni_ticket_settings_value "EMPLOYEE_ATTRIBUTE_LABEL" as employee_attribute_label %}
{% obj_get_attr compiled_by employee_attribute_name as user_employee_attribute %}
{% if user_employee_attribute %}
<br><span class="x-small"><b>{{ employee_attribute_label }}</b>: {{user_employee_attribute}}</span>
{% endif %}
{% settings_value "USER_ATTRIBUTE_NAME" as user_attribute_name %}
{% settings_value "USER_ATTRIBUTE_LABEL" as user_attribute_label %}
{% uni_ticket_settings_value "USER_ATTRIBUTE_NAME" as user_attribute_name %}
{% uni_ticket_settings_value "USER_ATTRIBUTE_LABEL" as user_attribute_label %}
{% obj_get_attr compiled_by user_attribute_name as user_user_attribute %}
{% if user_user_attribute %}
<br><span class="x-small"><b>{{ user_attribute_label }}</b>: {{user_user_attribute}}</span>
Expand Down Expand Up @@ -194,7 +194,7 @@ <h5 class="modal-title">
</p>
</div>
<div class="modal-footer">
{% settings_value name="TICKET_CREATE_BUTTON_NAME" as confirm_button_name %}
{% uni_ticket_settings_value name="TICKET_CREATE_BUTTON_NAME" as confirm_button_name %}
<input class="btn btn-success"
type="submit"
id="submitForm"
Expand Down Expand Up @@ -229,9 +229,9 @@ <h5 class="modal-title">
role="tabpanel"
aria-labelledby="heading1-lft">
<div class="collapse-body">
{% settings_value name="TICKET_GENERATE_URL_BUTTON_NAME" as generate_url_button_name %}
{% settings_value "TICKET_COMPILED_BY_USER_NAME" as compiled_by_name %}
{% settings_value "TICKET_COMPILED_ONE_TIME_FLAG" as compiled_one_time %}
{% uni_ticket_settings_value name="TICKET_GENERATE_URL_BUTTON_NAME" as generate_url_button_name %}
{% uni_ticket_settings_value "TICKET_COMPILED_BY_USER_NAME" as compiled_by_name %}
{% uni_ticket_settings_value "TICKET_COMPILED_ONE_TIME_FLAG" as compiled_one_time %}
<input type="checkbox"
id="{{ compiled_by_name }}"
name="{{ compiled_by_name }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
{% endblock top_buttons %}

{% block page_content %}
{% settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% uni_ticket_settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% include 'datatables/table.html' with user_show_priority=user_show_priority %}
{% endblock page_content %}

{% block extra_scripts %}
{% settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% uni_ticket_settings_value name="SIMPLE_USER_SHOW_PRIORITY" as user_show_priority %}
{% url 'uni_ticket:user_ticket_url' as var_url %}
{% url 'uni_ticket:user_unassigned_ticket_json' as ajax_url %}
{% include 'datatables/datatable_script.html' with var_url=var_url ajax_url=ajax_url user_show_priority=user_show_priority %}
Expand Down
Loading

0 comments on commit 91d4ee2

Please sign in to comment.