-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mise en avant newsletter #469
Open
pyDez
wants to merge
7
commits into
main
Choose a base branch
from
feature/opt-in-newsletter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,37 @@ | ||
<div class="fr-follow fr-py-8w hide-print"> | ||
<div class="fr-container"> | ||
<div class="fr-grid-row"> | ||
<div class="fr-col-12"> | ||
<div class="fr-follow__newsletter"> | ||
<div> | ||
<h2 class="fr-h5">Abonnez-vous à notre lettre d’information</h2> | ||
<p class="fr-text--sm"> | ||
Tous les 3 mois, recevez nos actualités sur la réglementation environnementale et les évolutions du service EnvErgo en lien avec votre activité professionnelle. | ||
</p> | ||
<p id="newsletter-email-hint-text" | ||
class="fr-hint-text fr-hidden fr-unhidden-md"> | ||
En renseignant votre adresse électronique, vous acceptez de recevoir nos actualités par courriel. Désinscription en un clic. | ||
</p> | ||
</div> | ||
<div> | ||
<form action="{% url 'newsletter_opt_in' %}" method="post"> | ||
{% csrf_token %} | ||
|
||
<input type="hidden" | ||
name="redirect_url" | ||
value="{{ request.build_absolute_uri }}" /> | ||
{% include '_field_snippet.html' with field=newsletter_opt_in_form.type %} | ||
{% include '_field_snippet.html' with field=newsletter_opt_in_form.email %} | ||
<button class="fr-btn fr-mt-2w" | ||
title="S‘abonner à notre lettre d’information" | ||
type="submit">M'abonner</button> | ||
</form> | ||
<p id="newsletter-email-hint-text" class="fr-hint-text fr-hidden-md"> | ||
En renseignant votre adresse électronique, vous acceptez de recevoir nos actualités par courriel. Désinscription en un clic. | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from django import forms | ||
from django.contrib.auth.forms import UserCreationForm | ||
from django.forms.widgets import Select | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from envergo.users.models import User | ||
|
@@ -40,3 +41,41 @@ def __init__(self, *args, **kwargs): | |
def clean_email(self): | ||
email = self.cleaned_data["email"] | ||
return email.lower() | ||
|
||
|
||
class AllowDisabledSelect(Select): | ||
"""A select widget (drop down list) that will disable options where the value is set to an empty string""" | ||
|
||
def create_option( | ||
self, name, value, label, selected, index, subindex=None, attrs=None | ||
): | ||
option_dict = super().create_option( | ||
name, value, label, selected, index, subindex=subindex, attrs=attrs | ||
) | ||
if not value: | ||
option_dict["attrs"]["disabled"] = "disabled" | ||
return option_dict | ||
|
||
|
||
class NewsletterOptInForm(forms.Form): | ||
type = forms.ChoiceField( | ||
required=True, | ||
label="Vous êtes", | ||
choices=( | ||
("", "Sélectionner une option"), | ||
("instructeur", "Service instructeur urbanisme"), | ||
("amenageur", "Aménageur"), | ||
("geometre", "Géomètre"), | ||
("bureau", "Bureau d'études"), | ||
("architecte", "Architecte"), | ||
("particulier", "Particulier"), | ||
("autre", "Autre"), | ||
), | ||
widget=AllowDisabledSelect(attrs={"placeholder": "Sélectionnez votre type"}), | ||
) | ||
email = forms.EmailField( | ||
required=True, | ||
label="Votre adresse email", | ||
widget=forms.EmailInput(attrs={"placeholder": "ex. : [email protected]"}), | ||
) | ||
redirect_url = forms.CharField(required=True, widget=forms.HiddenInput()) |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je m'interroge sur cette gestion d'erreur. S'il y a un problème de settings manquant, c'est l'équipe EnvErgo qui devrait recevoir une erreur, pas l'utilisateur. Ici, le message affiché laisse penser à l'utilisateur qu'il y a une erreur de son côté ce qui n'est pas le cas. Au moins ajouter un log d'erreur avec
logger.error
?