From 8a5151c7e5fa07fe52b53558e46fbdf1e89434ee Mon Sep 17 00:00:00 2001 From: madjid-asa Date: Wed, 15 May 2024 09:52:38 +0200 Subject: [PATCH] feat(DDB): ajout d'un fragement wagtail pour info bulle des structures (#1213) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sébastien Reuiller --- lemarche/cms/migrations/0011_infocard.py | 33 +++++++++++++++++++ lemarche/cms/snippets.py | 26 +++++++++++++++ lemarche/cms/templatetags/info_card_cms.py | 17 ++++++++++ .../cms/snippets/_info_card_snippet.html | 8 +++++ .../templates/tenders/_detail_sidebar.html | 4 +++ 5 files changed, 88 insertions(+) create mode 100644 lemarche/cms/migrations/0011_infocard.py create mode 100644 lemarche/cms/templatetags/info_card_cms.py create mode 100644 lemarche/templates/cms/snippets/_info_card_snippet.html diff --git a/lemarche/cms/migrations/0011_infocard.py b/lemarche/cms/migrations/0011_infocard.py new file mode 100644 index 000000000..e5f3552c8 --- /dev/null +++ b/lemarche/cms/migrations/0011_infocard.py @@ -0,0 +1,33 @@ +# Generated by Django 4.2.10 on 2024-05-14 16:54 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("cms", "0010_remove_homepage_banner_cta_id_and_more"), + ] + + operations = [ + migrations.CreateModel( + name="InfoCard", + fields=[ + ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), + ("title", models.CharField(max_length=255, verbose_name="Titre de l'encart")), + ( + "slug", + models.SlugField( + allow_unicode=True, + help_text="A slug to identify this info card", + max_length=255, + verbose_name="slug", + ), + ), + ("content_card", models.TextField(verbose_name="Contenu")), + ], + options={ + "verbose_name": "Carte info", + "verbose_name_plural": "Cartes infos", + }, + ), + ] diff --git a/lemarche/cms/snippets.py b/lemarche/cms/snippets.py index ad7933c0c..bf8ebf8a1 100644 --- a/lemarche/cms/snippets.py +++ b/lemarche/cms/snippets.py @@ -62,3 +62,29 @@ class Meta: def __str__(self): return self.title + + +@register_snippet +class InfoCard(models.Model): + title = models.CharField(max_length=255, verbose_name="Titre de l'encart") + slug = models.SlugField( + verbose_name="slug", + allow_unicode=True, + max_length=255, + help_text="A slug to identify this info card", + ) + + content_card = models.TextField(verbose_name="Contenu") + + panels = [ + FieldPanel("title"), + FieldPanel("slug"), + FieldPanel("content_card"), + ] + + class Meta: + verbose_name = "Carte info" + verbose_name_plural = "Cartes infos" + + def __str__(self): + return self.title diff --git a/lemarche/cms/templatetags/info_card_cms.py b/lemarche/cms/templatetags/info_card_cms.py new file mode 100644 index 000000000..efdd309f5 --- /dev/null +++ b/lemarche/cms/templatetags/info_card_cms.py @@ -0,0 +1,17 @@ +from django import template + +from lemarche.cms.snippets import InfoCard + + +register = template.Library() + + +# Advert snippets +@register.inclusion_tag("cms/snippets/_info_card_snippet.html", takes_context=True) +def cms_info_card(context): + # we use only the last for now + info_card = InfoCard.objects.last() + return { + "info_card": info_card, + "request": context["request"], + } diff --git a/lemarche/templates/cms/snippets/_info_card_snippet.html b/lemarche/templates/cms/snippets/_info_card_snippet.html new file mode 100644 index 000000000..58d2263da --- /dev/null +++ b/lemarche/templates/cms/snippets/_info_card_snippet.html @@ -0,0 +1,8 @@ +{% if info_card %} +
+

+ Conseil +

+ {{info_card.content_card|linebreaks}} +
+{% endif %} diff --git a/lemarche/templates/tenders/_detail_sidebar.html b/lemarche/templates/tenders/_detail_sidebar.html index 979b74e9c..19b9f4e42 100644 --- a/lemarche/templates/tenders/_detail_sidebar.html +++ b/lemarche/templates/tenders/_detail_sidebar.html @@ -1,4 +1,5 @@ +{% load info_card_cms %} {% if is_admin %} {% include "tenders/_detail_admin_extra_info.html" with tender=tender %} {% endif %} @@ -36,6 +37,9 @@ {% endif %} {% elif user.kind == user.KIND_SIAE %} + {% if tender.can_display_contact_phone %} + {% cms_info_card %} + {% endif %} {% if not user.has_siae %} {% include "tenders/_detail_siae_user_without_siae.html" %} {% elif siae_has_detail_contact_click_date or siae_has_detail_cocontracting_click_date %}