From 2abc7d3aa042b4bba1319a788b6db6571e3d1de5 Mon Sep 17 00:00:00 2001 From: Francesco Filicetti Date: Tue, 9 Jul 2024 14:26:28 +0200 Subject: [PATCH] feat: PRIN projects block --- src/unicms_unical_storage_handler/settings.py | 2 + ...al_storage_projects_list_prin_filters.html | 260 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 src/unicms_unical_storage_handler/templates/blocks/unical_storage_projects_list_prin_filters.html diff --git a/src/unicms_unical_storage_handler/settings.py b/src/unicms_unical_storage_handler/settings.py index 2a886f14..ce63a295 100644 --- a/src/unicms_unical_storage_handler/settings.py +++ b/src/unicms_unical_storage_handler/settings.py @@ -314,6 +314,8 @@ 'ProjectDescription', 'ProjectAbstract', 'ProjectImage', 'InfrastructureId', 'IsActive'] +PROJECTS_PRIN_ID_LIST = [] + INITIAL_STRUCTURE_FATHER = '' SPINOFF_INFO_NOT_SHOW = ['SpinoffId', 'SpinoffImage', 'SpinoffTechAreaId', diff --git a/src/unicms_unical_storage_handler/templates/blocks/unical_storage_projects_list_prin_filters.html b/src/unicms_unical_storage_handler/templates/blocks/unical_storage_projects_list_prin_filters.html new file mode 100644 index 00000000..4e2143e2 --- /dev/null +++ b/src/unicms_unical_storage_handler/templates/blocks/unical_storage_projects_list_prin_filters.html @@ -0,0 +1,260 @@ +{% extends "bases/unical_storage_list.html" %} + +{% load i18n %} +{% load static %} +{% load unicms_storage_handler %} +{% load unicms_templates %} + +{% block content %} + +{% get_allowed_website request.get_host as host %} + +{% settings_value "CMS_PATH_PREFIX" as cms_path_prefix %} +{% storage_settings_value "CMS_STORAGE_BASE_PATH" as base_prefix %} +{% storage_settings_value "CMS_STORAGE_PROJECTS_VIEW_PREFIX_PATH" as projects_prefix %} +{% storage_settings_value "CMS_STORAGE_TEACHER_VIEW_PREFIX_PATH" as teacher_prefix %} + + +
+ +
+
+
+
+ {% block filters %} + +
+
+ + {% include "includes/unical_storage_search_input.html" with id=id %} + +
+ +
+ + {% block filter_programtype %} + + +
+
+ +
+ +
+
+
+ {% endblock filter_programtype %} + + + +
+
+ +
+ +
+
+
+
+ + +
+
+
+ {% endblock filters %} +
+
+
+ + + + + + +
+
+
+ +
+
+
+
+ {% comment %} +
+ +
+ {% endcomment %} +
+
+ + [[ item.ProjectTitle ]] + +
+

+ +

+
+
+ + [[ labels['InfrastructureDescription'] ]] > + [[ item.InfrastructureDescription ]] + +
+
+ + [[ labels['ProjectYear'] ]] > + [[ item.ProjectYear ]] + +
+
+ + [[ labels['TerritorialScopeDescription'] ]] > + [[ item.TerritorialScopeDescription ]] + +
+
+ + {% trans "Tech Area" %} > + [[ item.TechAreaDescription ]] + +
+
+ + [[ labels['TypeProgramDescription'] ]] > + [[ item.TypeProgramDescription ]] + +
+
+
+
+
+
+
+ +
+
+
+ + +
+ +
+ {% trans "No items here" %} +
+ +
+{% endblock content %} + +{% block extra_scripts %} + +{% endblock extra_scripts %} + +{% block extra_data %} +{% get_current_language as LANGUAGE_CODE %} + +{% storage_api_root "CMS_STORAGE_PROJECTS_PROGRAMS_TYPES_API" as programtypes_api %} +{% storage_api_root "CMS_STORAGE_PROJECTS_INFRASTRUCTURES_API" as infrastructures_api %} +{% storage_settings_value "PROJECTS_PRIN_ID_LIST" as prin_id_list %} + +search_dict: {}, +programtypes: [], +infrastructures: [], + +is_loading_programtypes: true, +is_loading_infrastructures: true, + +loader_source_programtypes: '{{ programtypes_api }}?lang={{ LANGUAGE_CODE }}&page_size=200', +loader_source_infrastructures: '{{ infrastructures_api }}?lang={{ LANGUAGE_CODE }}&page_size=200', + +selected_search: this.getItemFromSession("{{ id }}", 'search'), +selected_programtype: this.getItemFromSession("{{ id }}", 'programtype'), +selected_infrastructure: this.getItemFromSession("{{ id }}", 'infrastructure'), + +let id_list: {{ prin_id_list|safe }}, +{% endblock extra_data %} + +{% block extra_mounted %} +this.parameters = {{ id }}_encodeQueryData(this.getItemsFromSession("{{ id }}")) + +this.callProgramTypes(); +this.callInfrastructures(); + +this.excluded_programtypes = {{ id }}_get_param("-programtype").split(","); +{% endblock extra_mounted %} + +{% block extra_methods %} +callProgramTypes() { + axios + .get(this.loader_source_programtypes) + .then(response => { + this.programtypes = response.data.results.filter( p => id_list.includes( p.TypeProgramId ) ); + this.is_loading_programtypes = false + }) +}, +callInfrastructures() { + axios + .get(this.loader_source_infrastructures) + .then(response => { + this.infrastructures = response.data.results; + this.is_loading_infrastructures = false + }) +}, +{% endblock extra_methods %} +