-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Email Notifications): Ajout du formulaire d'édition des préféren…
…ces (#1595)
- Loading branch information
1 parent
84c637c
commit b50530a
Showing
13 changed files
with
343 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
...rsations/migrations/0017_emailgroup_disabledemail_templatetransactional_group_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# Generated by Django 4.2.15 on 2024-12-11 17:02 | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
def create_email_groups(apps, schema_editor): | ||
# Get the model | ||
EmailGroup = apps.get_model("conversations", "EmailGroup") | ||
|
||
# Create email groups | ||
email_groups = [ | ||
{ | ||
"id": 1, | ||
"display_name": "Structure(s) intéressée(s)", | ||
"description": "En désactivant cette option, vous ne serez plus averti par email lorsque des fournisseurs s'intéressent à votre besoin, ce qui pourrait vous faire perdre des opportunités de collaboration rapide et efficace.", | ||
"relevant_user_kind": "BUYER", | ||
"can_be_unsubscribed": True, | ||
}, | ||
{ | ||
"id": 2, | ||
"display_name": "Communication marketing", | ||
"description": "En désactivant cette option, vous ne recevrez plus par email nos newsletters, enquêtes, invitations à des webinaires et Open Labs, ce qui pourrait vous priver d'informations utiles et de moments d'échange exclusifs.", | ||
"relevant_user_kind": "BUYER", | ||
"can_be_unsubscribed": True, | ||
}, | ||
{ | ||
"id": 3, | ||
"display_name": "Opportunités commerciales", | ||
"description": "En désactivant cette option, vous ne recevrez plus par email les demandes de devis et les appels d'offres spécialement adaptés à votre activité, ce qui pourrait vous faire manquer des opportunités importantes pour votre entreprise.", | ||
"relevant_user_kind": "SIAE", | ||
"can_be_unsubscribed": True, | ||
}, | ||
{ | ||
"id": 4, | ||
"display_name": "Demandes de mise en relation", | ||
"description": "En désactivant cette option, vous ne recevrez plus par email les demandes de mise en relation de clients intéressés par votre structure, ce qui pourrait vous faire perdre des opportunités précieuses de collaboration et de développement.", | ||
"relevant_user_kind": "SIAE", | ||
"can_be_unsubscribed": True, | ||
}, | ||
{ | ||
"id": 5, | ||
"display_name": "Communication marketing", | ||
"description": "En désactivant cette option, vous ne recevrez plus par email nos newsletters, enquêtes, invitations aux webinaires et Open Labs, ce qui pourrait vous faire passer à côté d’informations clés, de ressources utiles et d’événements exclusifs.", | ||
"relevant_user_kind": "SIAE", | ||
"can_be_unsubscribed": True, | ||
}, | ||
] | ||
|
||
for group in email_groups: | ||
EmailGroup.objects.create(**group) | ||
|
||
|
||
def delete_email_groups(apps, schema_editor): | ||
# Get the model | ||
EmailGroup = apps.get_model("conversations", "EmailGroup") | ||
# Delete all email groups | ||
EmailGroup.objects.all().delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
("conversations", "0016_templatetransactionalsendlog"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="EmailGroup", | ||
fields=[ | ||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), | ||
("display_name", models.CharField(blank=True, max_length=255, verbose_name="Nom")), | ||
("description", models.TextField(blank=True, verbose_name="Description")), | ||
( | ||
"relevant_user_kind", | ||
models.CharField( | ||
choices=[ | ||
("SIAE", "Structure"), | ||
("BUYER", "Acheteur"), | ||
("PARTNER", "Partenaire"), | ||
("INDIVIDUAL", "Particulier"), | ||
], | ||
default="BUYER", | ||
max_length=20, | ||
verbose_name="Type d'utilisateur", | ||
), | ||
), | ||
( | ||
"can_be_unsubscribed", | ||
models.BooleanField(default=False, verbose_name="L'utilisateur peut s'y désinscrire"), | ||
), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name="DisabledEmail", | ||
fields=[ | ||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), | ||
("disabled_at", models.DateTimeField(auto_now_add=True)), | ||
( | ||
"group", | ||
models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="conversations.emailgroup"), | ||
), | ||
( | ||
"user", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="disabled_emails", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
), | ||
migrations.AddField( | ||
model_name="templatetransactional", | ||
name="group", | ||
field=models.ForeignKey( | ||
null=True, on_delete=django.db.models.deletion.CASCADE, to="conversations.emailgroup" | ||
), | ||
), | ||
migrations.AddConstraint( | ||
model_name="disabledemail", | ||
constraint=models.UniqueConstraint(models.F("user"), models.F("group"), name="unique_group_per_user"), | ||
), | ||
migrations.RunPython(create_email_groups, delete_email_groups), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{% extends "layouts/base.html" %} | ||
{% load static widget_tweaks dsfr_tags process_dict theme_inclusion %} | ||
{% block page_title %} | ||
Notifications{{ block.super }} | ||
{% endblock page_title %} | ||
{% block breadcrumb %} | ||
{% process_dict root_dir=HOME_PAGE_PATH current="Notifications" as breadcrumb_data %} | ||
{% dsfr_breadcrumb breadcrumb_data %} | ||
{% endblock breadcrumb %} | ||
{% block content %} | ||
<div class="fr-grid-row fr-grid-row-gutters fr-grid-row--center"> | ||
<div class="fr-col-12 fr-col-lg-10"> | ||
<div class="fr-container fr-px-md-0 fr-py-2v fr-py-md-4v"> | ||
<div class="fr-grid-row fr-grid-row-gutters fr-grid-row--center"> | ||
<div class="fr-col-12 fr-col-lg-8"> | ||
<h1>Notifications</h1> | ||
<div> | ||
<form method="post"> | ||
{% csrf_token %} | ||
<fieldset class="fr-fieldset"> | ||
<div class="fr-fieldset__element"> | ||
{% if form.non_field_errors %} | ||
<section class="fr-my-4v fr-input-group fr-input-group--error"> | ||
{{ form.non_field_errors }} | ||
</section> | ||
{% endif %} | ||
<ul class="fr-toggle__list"> | ||
{% for group_item in form.group_items %} | ||
{% get_form_field form group_item.field_name as field %} | ||
<li> | ||
<div class="fr-toggle fr-toggle--label-left fr-toggle--border-bottom fr-mt-8v"> | ||
{% with aria_describedby="aria-describedby:"|add:field.auto_id|add:"-hint-text" %} | ||
{{ field|dsfr_input_class_attr|attr:"type:checkbox"|attr:aria_describedby|attr:"class:fr-toggle__input" }} | ||
{% endwith %} | ||
<label class="fr-toggle__label" | ||
for="{{ field.id_for_label }}" | ||
data-fr-checked-label="Activé" | ||
data-fr-unchecked-label="Désactivé"> | ||
{{ group_item.group.display_name }} | ||
</label> | ||
<p class="fr-hint-text" id="{{ field.id_for_label }}-hint-text">{{ group_item.group.description }}</p> | ||
</div> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
<div class="fr-fieldset__element"> | ||
<ul class="fr-btns-group--right fr-btns-group fr-btns-group--inline"> | ||
<li> | ||
<button class="fr-mt-2v fr-btn fr-btn" type="submit">Sauvegarder</button> | ||
</li> | ||
</ul> | ||
</div> | ||
</fieldset> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.