templates: import publik notification prototype cells (#76575)
gitea/publik-base-theme/pipeline/head This commit looks good Details

portal settings:

    "pn-alertes": {
      "name": "publik-notifications/alertes",
      "template-name": "combo/publik-notifications/alertes.html",
      "url": "{{ eservices_url }}api/cards/pn_message/list/messages-publications-publies?email=accesapi@entrouvert.com&full=on",
      "cache_duration": 30,
      "timeout": 0
    },
    "pn-alerte": {
      "name": "publik-notifications/alerte",
      "template-name": "combo/publik-notifications/alerte.html",
      "url": "{{ eservices_url }}api/cards/pn_message/{{ pn_message_id }}?email=accesapi@entrouvert.com&full=on",
      "cache_duration": 0,
      "timeout": 0
    },
    "pn-alertes-preview": {
      "name": "publik-notifications/alertes-preview",
      "template-name": "combo/publik-notifications/alertes-preview.html",
      "url": "{{ eservices_url }}api/cards/pn_message/list/messages-publication-dans-le-tube?email=accesapi@entrouvert.com&full=on",
      "cache_duration": 60,
      "timeout": 0
    },
    "pn-alerte-preview": {
      "name": "publik-notifications/alerte-preview",
      "template-name": "combo/publik-notifications/alerte-preview.html",
      "url": "{{ eservices_url }}api/cards/pn_modelesmessages/{{ pn_modelesmessages_id }}?email=accesapi@entrouvert.com&full=on",
      "cache_duration": 0,
      "timeout": 0
    }

portal agent settings:

    "pn-modeles-filters": {
      "name": "publik-notifications/agents/modeles-filters",
      "template-name": "combo/publik-notifications/agents/modeles-filters.html",
      "url": "{{ eservices_url }}api/cards/pn_modelesmessages/list/?filter-origin={{pn_producteurs_id}}&filter-categorie={{ request.GET.categorie }}&email=accesapi@entrouvert.com&full=on",
      "cache_duration": 0,
      "timeout": 0
    }
This commit is contained in:
Frédéric Péters 2023-04-12 10:44:25 +02:00
parent c32774d314
commit 65daacfd39
5 changed files with 419 additions and 0 deletions

View File

@ -0,0 +1,42 @@
{% load wcs %}
{% with parametres=cards|objects:"pn-v2-parametres-generaux"|get_full|first|get:"fields" %}
{% with cat=request.GET.categorie filtre=cards|objects:"pn_categoriesmessages"|filter_by:"origin"|filter_value:pn_producteurs_id %}
<!-- Filtres -->
{% if filtre|count > 0 %}
<p>
<a class="pk-button" style="margin-right:10px;" href="{{ eservices_url }}backoffice/data/pn_modelesmessages/add/?origin={{pn_producteurs_id}}">+ Nouveau message</a>
<a class="pk-button" style="margin-right:10px;" href="{{ eservices_url }}backoffice/data/pn_categoriesmessages/add/?origin={{pn_producteurs_id}}">+ Nouvelle catégorie</a>
<a class="pk-button" href="{{ eservices_url }}backoffice/data/pn_categoriesmessages/?offset=0&limit=20&order_by=f2&q=&filter-3-value={{pn_producteurs_id}}&filter-3=on&id=on&1=on&3=on&2=on">Voir la liste des catégories</a>
</p><br>
<p><b>Filter par : </b>
{% if not cat %}
<b><a href="?categorie=">Toutes les catégories</a></b>
{%else %}
<a href="?categorie=">Toutes les catégories</a>
{% endif %}
|
{% for unit in filtre %}
{% with id=unit.id %}
{% if id|decimal == cat|decimal %}
<b><a href="?categorie={{ unit.id }}">{{ unit.text }}</a></b> |
{% else %}
<a href="?categorie={{ unit.id }}">{{ unit.text }}</a> |
{% endif %}
{% endwith %}
{% endfor %}
</p>
{% else %}
<p>Vous devez créer une catégorie de message avant de créer un message.<br>
<a style="color:{{colorcrea}};" href="{{ eservices_url }}backoffice/data/pn_categoriesmessages/add/?origin={{pn_producteurs_id}}">+ Nouvelle catégorie</a></p>
{% endif %}
{% endwith %}
{% endwith %}
{# <p>json brut :</p> <pre>{{ json|pprint }}</pre> #}

View File

@ -0,0 +1,44 @@
{% with var=json.fields varwf=json.workflow.fields %}
<div style="
max-width: 100%;
margin-left: auto;
margin-right: auto;">
{% with img=var.detail_image %}
{% if img %}
{% with urlimg=img|get:"url" %}
<img style="max-width:100%; max-height: 600px; width: 100%; object-fit: cover" src="{% make_public_url url=urlimg %}">
{% endwith %}
{% endif %}
{% endwith %}
</div>
<h1 style="padding:0px 20px;" >{{ var.detail_titre }}</h1>
<div style="padding:0px 20px;" >
<h3>{{ var.detail_chapeau|linebreaksbr }}</h3>
<p>{{ var.detail_description|linebreaksbr }}</p>
{% if var.detail_lien1 or var.detail_lien2 or var.detail_lien3 %}
<p><strong>Liens</strong></p>
{% if var.detail_lien1 %}<p><a href="{{ var.detail_lien1 }}">{{ var.detail_lien1_libelle }}</a>{% endif %}
{% if var.detail_lien2 %}<br><a href="{{ var.detail_lien2 }}">{{ var.detail_lien2_libelle }}</a>{% endif %}
{% if var.detail_lien3 %}<br><a href="{{ var.detail_lien3 }}">{{ var.detail_lien3_libelle }}</a>{% endif %}
</p>
{% endif %}
</div>
{% if var.detail_encart == True %}
<div style="padding:20px;background-color:whitesmoke;" >
<p><strong>{{ var.titre_encart|upper }}</p>
<p>{{ var.contenu_encart|linebreaksbr }}</p>
{% if var.detail_lien3 %}<p><a href="{{ var.lien_encart }}">{{ var.libelle_lien_encart }}</p>{% endif %}
</div>
{% endif %}
{% endwith %}
{# <pre>{{json|pprint}}</pre> #}

View File

@ -0,0 +1,56 @@
{% with var=json.fields varwf=json.workflow.fields %}
{% if var.utiliser_img_modele is True %}
<!-- Recup image du modèle -->
<div style="
max-width: 100%;
margin-left: auto;
margin-right: auto;">
{% with param=cards|objects:"pn_modelesmessages"|filter_by_internal_id:var.modelemsg_structured.id|get_full|first|get:"fields" %}
{% with img=param|get:"detail_image" %}
{% if img %}
{% with urlimg=img|get:"url" %}
<img style="max-width:100%; max-height: 300px; width: 100%; object-fit: cover" src="{% make_public_url url=urlimg %}">
{% endwith %}
{% endif %}
{% endwith %}
{% endwith %}
</div>
{% elif var.imgalerte %}
<div style="
max-width: 100%;
margin-left: auto;
margin-right: auto;">
{% with urlimg=var.imgalerte|get:"url" %}
<img style="max-width:100%; max-height: 300px; width: 100%; object-fit: cover" src="{% make_public_url url=urlimg %}">
{% endwith %}
</div>
{% endif %}
<h1 style="padding:0px 20px;" >{{ var.detail_titre }}</h1>
<div style="padding:0px 20px;" >
<strong>{{ var.detail_chapeau|linebreaks }}</strong>
<p>{{ var.detail_description|linebreaks }}</p>
{% if var.detail_lien1 or var.detail_lien2 or var.detail_lien3 %}
<p><strong>Liens</strong></p>
{% if var.detail_lien1 %}<p><a href="{{ var.detail_lien1 }}">{{ var.detail_lien1_libelle }}</a>{% endif %}
{% if var.detail_lien2 %}<br><a href="{{ var.detail_lien2 }}">{{ var.detail_lien2_libelle }}</a>{% endif %}
{% if var.detail_lien3 %}<br><a href="{{ var.detail_lien3 }}">{{ var.detail_lien3_libelle }}</a>{% endif %}
</p>
{% endif %}
</div>
{% if var.detail_encart == True %}
<div style="padding:20px;background-color:whitesmoke;" >
<p><strong>{{ var.titre_encart|upper }}</strong></p>
<p>{{ var.contenu_encart|linebreaksbr }}</p>
{% if var.lien_encart %}<p><a href="{{ var.lien_encart }}">{{ var.libelle_lien_encart }}</a></p>{% endif %}
</div>
{% endif %}
{% endwith %}
{# <pre>{{json|pprint}}</pre> #}

View File

@ -0,0 +1,47 @@
{% load assets %}{% load wcs %}
{% with parametres=cards|objects:"pn_parametres_cellules"|get_full|first|get:"fields" %}
<div style="margin-bottom: 10px;"><h2>Aperçu des alertes</h2></div>
{% for fiche in json.data %}
<div style="
{% if parametres|get:"utiliser_style_alternatif" is True %}
{{ parametres|get:"style_alternatif" }};
{% else %}
border: solid thin #ccc;
padding: 10px 10px 5px 10px;
margin: 0px 10px 10px 10px;
{% endif %}">
{% if parametres|get:"affiche_image" is True %}
<div class="fx-grid">
<div class="size--d1-6">
{% with refimgc="pn:thematique:"|add:fiche.fields.thematique_raw %}
<img style="max-width: 100%; height: auto;"
src="{% asset_url refimgc %}"/>
{% endwith %}
</div>
<div class="size--d5-6">
<strong>{{ fiche.fields.objet }}</strong><br>
{% if parametres|get:"affiche_thematique" is True and fiche.fields.thematique %}[{{ fiche.fields.thematique }}]<br>{% endif %}
{{ fiche.fields.contenu|linebreaksbr }}
{% if fiche.workflow.fields.lien %}
<br><a href="{{ fiche.workflow.fields.lien }}">En savoir plus</a>
{% endif %}
</div>
</div>
{% else %}
<div>
<strong>{{ fiche.fields.objet }}</strong><br>
{% if parametres|get:"affiche_thematique" is True and fiche.fields.thematique %}[{{ fiche.fields.thematique }}]<br>{% endif %}
{{ fiche.fields.contenu|linebreaksbr }}
{% if fiche.workflow.fields.lien %}
<br><a href="{{ fiche.workflow.fields.lien }}">En savoir plus</a>
{% endif %}
</div>
{% endif %}
</div>
{% endfor %}
{% endwith %}
{# <pre>{{json|pprint}}</pre> #}

View File

@ -0,0 +1,230 @@
{% load assets %}{% load wcs %}
{% if not json_error %}
{% with parametres=cards|objects:"pn_parametres_cellules"|get_full|first|get:"fields" %}
{% if parametres|get:"affiche_titre" is True %}
<div {% if parametres|get:"affiche_marge_titre" is True %}style="margin-bottom: 10px;"{% endif %}><h2>{{ parametres|get:"titre" }}</h2></div>
{% endif %}
{% for fiche in json.data %}
{# Notifications personnalisées #}
{% if request.user|has_role:"Publik Notification - Usager" %}{# Début vérification role #}
{# Notifications personnalisées "Adresses" #}
{% if fiche.fields.zone_diffusion_raw == "zone" %}
{% with pref_adresses=cards|objects:"pn_preferences_usagers_adresses"|get_full|filter_by_user:request.user|filter_by:"type"|filter_value:"Adresse"|filter_by:"thqs_quartier"|filter_value:fiche.fields.thematique_raw|set_geo_center_lat:fiche.geolocations.base.lat|set_geo_center_lon:fiche.geolocations.base.lon|filter_by_distance:fiche.fields.rayon %}
{% if pref_adresses|count > 0 %}
{% for unit in pref_adresses %}
{% ifchanged %}
<div style="
{% if parametres|get:"utiliser_style_alternatif" is True %}
{{ parametres|get:"style_alternatif" }};
{% else %}
border: solid thin #ccc;
padding: 10px 10px 5px 10px;
margin: 0px 10px 10px 10px;
{% endif %}">
{% if parametres|get:"affiche_image" is True %}
<div class="fx-grid">
<div class="size--d1-6">
{% with refimgc="pn:thematique:"|add:fiche.fields.thematique_raw %}
<img style="max-width: 100%; height: auto;"
src="{% asset_url refimgc %}"/>
{% endwith %}
</div>
<div class="size--d5-6">
<strong>{{ fiche.fields.objet }}</strong><br>
{% if parametres|get:"affiche_thematique" is True and fiche.fields.thematique %}[{{ fiche.fields.thematique }}]<br>{% endif %}
{{ fiche.fields.contenu|linebreaksbr }}
{% if fiche.workflow.fields.lien %}
<br><a href="{{ fiche.workflow.fields.lien }}">En savoir plus</a>
{% endif %}
</div>
</div>
{% else %}
<div>
<strong>{{ fiche.fields.objet }}</strong><br>
{{ fiche.fields.contenu|linebreaksbr }}
{% if parametres|get:"affiche_thematique" is True and fiche.fields.thematique %}[{{ fiche.fields.thematique }}]<br>{% endif %}
{% if fiche.workflow.fields.lien %}
<br><a href="{{ fiche.workflow.fields.lien }}">En savoir plus</a>
{% endif %}
</div>
{% endif %}
</div>
{% endifchanged %}
{% endfor %}
{% endif %}
{% endwith %}
{% endif %}
{# Fin des notifications personnalisées "Adresses" #}
{# Notifications personnalisées "communes" #}
{% if fiche.fields.zone_diffusion_raw == "commune" %}
{% with pref_adresses=cards|objects:"pn_preferences_usagers_adresses"|get_full|filter_by_user:request.user|filter_by:"commune"|filter_value:fiche.fields.commune_raw %}
{% if pref_adresses|count > 0 %}
{% for unit in pref_adresses %}
{% with adresse_thqs_quartier=unit|get:"fields"|get:"thqs_quartier_raw" message_thq=fiche.fields.thematique_raw %}
{% if message_thq in adresse_thqs_quartier %}
{% ifchanged %}
<div style="
{% if parametres|get:"utiliser_style_alternatif" is True %}
{{ parametres|get:"style_alternatif" }};
{% else %}
border: solid thin #ccc;
padding: 10px 10px 5px 10px;
margin: 0px 10px 10px 10px;
{% endif %}">
{% if parametres|get:"affiche_image" is True %}
<div class="fx-grid">
<div class="size--d1-6">
{% with refimgc="pn:thematique:"|add:fiche.fields.thematique_raw %}
<img style="max-width: 100%; height: auto;"
src="{% asset_url refimgc %}"/>
{% endwith %}
</div>
<div class="size--d5-6">
<strong>{{ fiche.fields.objet }}</strong><br>
{% if parametres|get:"affiche_thematique" is True and fiche.fields.thematique %}[{{ fiche.fields.thematique }}]<br>{% endif %}
{{ fiche.fields.contenu|linebreaksbr }}
{% if fiche.workflow.fields.lien %}
<br><a href="{{ fiche.workflow.fields.lien }}">En savoir plus</a>
{% endif %}
</div>
</div>
{% else %}
<div>
<strong>{{ fiche.fields.objet }}</strong><br>
{{ fiche.fields.contenu|linebreaksbr }}
{% if parametres|get:"affiche_thematique" is True and fiche.fields.thematique %}[{{ fiche.fields.thematique }}]<br>{% endif %}
{% if fiche.workflow.fields.lien %}
<br><a href="{{ fiche.workflow.fields.lien }}">En savoir plus</a>
{% endif %}
</div>
{% endif %}
</div>
{% endifchanged %}
{% endif %}
{% endwith %}
{% endfor %}
{% endif %}
{% endwith %}
{% endif %}
{# Fin des notifications personnalisées "communes" #}
{# Début des notifications personnalisées "Tout le territoire" #}
{% with cards|objects:"pn_preferencesusager"|filter_by_user:request.user|get_full|first as preference %} {# Debut with fiche préférence usager #}
{% with thememessage=fiche.fields.thematique preferencetheme=preference.fields.thematiques %}{# Début with thememessage & preferencetheme #}
{% if thememessage in preferencetheme and fiche.fields.zone_diffusion_raw == "metro" and preference.fields.metro == True %}
<div style="
{% if parametres|get:"utiliser_style_alternatif" is True %}
{{ parametres|get:"style_alternatif" }};
{% else %}
border: solid thin #ccc;
padding: 10px 10px 5px 10px;
margin: 0px 10px 10px 10px;
{% endif %}">
{% if parametres|get:"affiche_image" is True %}
<div class="fx-grid">
<div class="size--d1-6">
{% with refimgc="pn:thematique:"|add:fiche.fields.thematique_raw %}
<img style="max-width: 100%; height: auto;"
src="{% asset_url refimgc %}"/>
{% endwith %}
</div>
<div class="size--d5-6">
<strong>{{ fiche.fields.objet }}</strong><br>
{% if parametres|get:"affiche_thematique" is True and fiche.fields.thematique %}[{{ fiche.fields.thematique }}]<br>{% endif %}
{{ fiche.fields.contenu|linebreaksbr }}
{% if fiche.workflow.fields.lien %}
<br><a href="{{ fiche.workflow.fields.lien }}">En savoir plus</a>
{% endif %}
</div>
</div>
{% else %}
<div>
<strong>{{ fiche.fields.objet }}</strong><br>
{% if parametres|get:"affiche_thematique" is True and fiche.fields.thematique %}[{{ fiche.fields.thematique }}]<br>{% endif %}
{{ fiche.fields.contenu|linebreaksbr }}
{% if fiche.workflow.fields.lien %}
<br><a href="{{ fiche.workflow.fields.lien }}">En savoir plus</a>
{% endif %}
</div>
{% endif %}
</div>
{% endif %}
{% endwith %}
{% endwith %}
{# Fin des notifications personnalisées "Tout le territoire" #}
{% endif %} {# Fin verif rôle usager #}
{# Début des notifications non personnalisées #}
{% if fiche.fields.priseencompte == "Non" %}
<div style="
{% if parametres|get:"utiliser_style_alternatif" is True %}
{{ parametres|get:"style_alternatif" }};
{% else %}
border: solid thin #ccc;
padding: 10px 10px 5px 10px;
margin: 0px 10px 10px 10px;
{% endif %}">
{% if parametres|get:"affiche_image" is True %}
<div class="fx-grid">
<div class="size--d1-6">
<img style="max-width: 100%; height: auto;"
src="{% asset_url "refimgdefaut" %}"/>
</div>
<div class="size--d5-6">
<strong>{{ fiche.fields.objet }}</strong><br>
{% if parametres|get:"affiche_thematique" is True and fiche.fields.thematique %}[{{ fiche.fields.thematique }}]<br>{% endif %}
{{ fiche.fields.contenu|linebreaksbr }}{% if fiche.workflow.fields.lien %}<br>
<a href="{{ fiche.workflow.fields.lien }}">En savoir plus</a>{% endif %}
</div>
</div>
{% else %}
<div>
<strong>{{ fiche.fields.objet }}</strong><br>
{% if parametres|get:"affiche_thematique" is True and fiche.fields.thematique %}[{{ fiche.fields.thematique }}]<br>{% endif %}
{{ fiche.fields.contenu|linebreaksbr }}{% if fiche.workflow.fields.lien %}<br>
<a href="{{ fiche.workflow.fields.lien }}">En savoir plus</a>{% endif %}
</div>
{% endif %}
</div>
{% endif %}
{# Fin des notifications non personnalisées #}
{% endfor %} {# Fin de la bouche sur les fiches #}
{% if parametres|get:"affiche_lien_inscription" is True %}
<div style="{{ parametres|get:"style_div_inscription" }}">
{% if request.user|has_role:"Publik Notification - Usager" %}
<a class="pk-button" href="{{ portal_url }}{{ parametres|get:"uri_page_pref_usagers" }}">{{ parametres|get:"libelle_bouton_tb_usager" }}</a>
{% elif parametres|get:"affiche_elements_non_abonnes" is True %}
{% if parametres|get:"incitation_non_abonne" %}
<p><strong>{{ parametres|get:"incitation_non_abonne"|linebreaksbr }}</strong></p>
{% endif %}
<a class="pk-button" href="{{ eservices_url }}{{ parametres|get:"uri_inscription" }}">{{ parametres|get:"libelle_bouton_form_inscription" }}</a>
{% endif %}
</div>
{% endif %}
{% endwith %} {# Fin with pour les paramètres #}
{% endif %} {# Fin test json.error #}
{# <pre>{{json|pprint}}</pre> #}