Skip to content

Commit

Permalink
feat(DDB): ajout d'un fragement wagtail pour info bulle des structures (
Browse files Browse the repository at this point in the history
#1213)

Co-authored-by: Sébastien Reuiller <[email protected]>
  • Loading branch information
madjid-asa and SebastienReuiller authored May 15, 2024
1 parent 1daf3b8 commit 8a5151c
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lemarche/cms/migrations/0011_infocard.py
Original file line number Diff line number Diff line change
@@ -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",
},
),
]
26 changes: 26 additions & 0 deletions lemarche/cms/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions lemarche/cms/templatetags/info_card_cms.py
Original file line number Diff line number Diff line change
@@ -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"],
}
8 changes: 8 additions & 0 deletions lemarche/templates/cms/snippets/_info_card_snippet.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% if info_card %}
<div class="alert alert-info ">
<p>
<b><i class="ri-information-line"></i> Conseil</b>
</p>
{{info_card.content_card|linebreaks}}
</div>
{% endif %}
4 changes: 4 additions & 0 deletions lemarche/templates/tenders/_detail_sidebar.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!-- admin info -->
{% load info_card_cms %}
{% if is_admin %}
{% include "tenders/_detail_admin_extra_info.html" with tender=tender %}
{% endif %}
Expand Down Expand Up @@ -36,6 +37,9 @@
{% endif %}
<!-- siae info & actions -->
{% 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 %}
Expand Down

0 comments on commit 8a5151c

Please sign in to comment.