Skip to content

Commit

Permalink
Merge pull request #755 from MTES-MCT/feat-newsletter-form
Browse files Browse the repository at this point in the history
Ajout d'une page-formulaire d'inscription à la newsletter
  • Loading branch information
alexisig authored Nov 27, 2024
2 parents 631edec + c48fb44 commit 2645c19
Show file tree
Hide file tree
Showing 22 changed files with 272 additions and 224 deletions.
2 changes: 1 addition & 1 deletion home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_token(self):
return "".join(choices(alphabet, k=25))

def get_confirmation_url(self):
return get_url_with_domain(reverse("home:nwl-confirmation", kwargs={"token": self.confirm_token}))
return get_url_with_domain(reverse("home:nwl-validation", kwargs={"token": self.confirm_token}))

def confirm(self):
self.confirmation_date = timezone.now()
Expand Down
5 changes: 5 additions & 0 deletions home/static/home/css/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
width: 750px;
}

.newsletter-container .fr-follow .fr-container {
height: 25vh;
display: flex;
}

.card {
background: #ffffff;
border-radius: 8px;
Expand Down
11 changes: 3 additions & 8 deletions home/templates/home/newsletter.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@
{% load static %}
{% load crispy_forms_tags %}

{% block pagetitle %}Formulaire de contact{% endblock pagetitle %}
{% block pagetitle %}Inscription à la newsletter{% endblock pagetitle %}

{% block content %}
<div class="d-flex justify-content-center">
<div class="home-container">
<h1>Inscrivez-vous à notre newsletter</h1>
<form action="" method="post">
{% csrf_token %}
{{ form|crispy }}
<button id="btn-send" class="fr-btn mt-4" type="submit">S'inscrire</button>
</form>
<div class="newsletter-container">
{% include "home/partials/newsletter_form.html" %}
</div>
</div>
{% endblock content %}
2 changes: 1 addition & 1 deletion home/templates/home/partials/newsletter_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h2 class="fr-h5">Abonnez-vous à notre lettre d'information</h2>
<p class="fr-text--sm">Ne ratez rien de notre actualité.</p>
</div>
<div>
<form hx-post="{% url 'home:nwl-subscription' %}">
<form hx-post="{% url 'home:nwl-confirmation' %}">
{% csrf_token %}
<div class="fr-input-group">
<label class="fr-label" for="newsletter-email">
Expand Down
10 changes: 5 additions & 5 deletions home/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
name="nwl-subscription",
),
path(
"newsletter/confirmation/<slug:token>",
views.NewsLetterConfirmationView.as_view(),
"newsletter/confirmation",
views.NewsletterConfirmationSubscriptionView.as_view(),
name="nwl-confirmation",
),
path(
"emails",
views.AllEmailsView.as_view(),
name="all-emails",
"newsletter/confirmation/<slug:token>",
views.NewsletterEmailValidationView.as_view(),
name="nwl-validation",
),
path("maintenance", views.MaintenanceView.as_view(), name="maintenance_mode"),
path("alive/async-workers", views.AliveView.as_view(), name="alive"),
Expand Down
209 changes: 0 additions & 209 deletions home/views.py

This file was deleted.

7 changes: 7 additions & 0 deletions home/views/AccessView.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.views.generic import TemplateView

from utils.views_mixins import BreadCrumbMixin


class AccessView(BreadCrumbMixin, TemplateView):
template_name = "home/accessibilite.html"
20 changes: 20 additions & 0 deletions home/views/AliveView.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from datetime import timedelta
from typing import Any

from django.http import HttpRequest, HttpResponse, HttpResponseGone
from django.utils import timezone
from django.views.generic import TemplateView

from home.models import AliveTimeStamp


class AliveView(TemplateView):
template_name = "home/alive.html"

def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:
from_datetime = timezone.now() - timedelta(minutes=35)
default_is_alive = AliveTimeStamp.objects.filter(queue_name="default", timestamp__gte=from_datetime).exists()
long_is_alive = AliveTimeStamp.objects.filter(queue_name="default", timestamp__gte=from_datetime).exists()
if default_is_alive and long_is_alive:
return HttpResponse("All good...")
return HttpResponseGone("Celery workers are not alive.")
15 changes: 15 additions & 0 deletions home/views/ContactView.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.conf import settings
from django.views.generic import CreateView

from home.models import ContactForm


class ContactView(CreateView):
model = ContactForm
template_name = "home/contact.html"
success_url = "/"
fields = ["email", "content"]

def get_context_data(self, **kwargs):
kwargs["crisp_website_id"] = settings.CRISP_WEBSITE_ID
return super().get_context_data(**kwargs)
17 changes: 17 additions & 0 deletions home/views/DownloadView.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic import TemplateView

from home.forms import NewsletterForm
from project.models import RNUPackage
from utils.views_mixins import BreadCrumbMixin


class DownloadView(LoginRequiredMixin, BreadCrumbMixin, TemplateView):
template_name = "home/download.html"

def get_context_data(self, **kwargs):
kwargs |= {
"form": NewsletterForm(),
"rnu_packages": RNUPackage.objects.all().order_by("departement_official_id"),
}
return super().get_context_data(**kwargs)
12 changes: 12 additions & 0 deletions home/views/HomeRapportLocalView.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.views.generic import TemplateView

from home.forms import NewsletterForm
from utils.views_mixins import BreadCrumbMixin


class HomeRapportLocalView(BreadCrumbMixin, TemplateView):
template_name = "home/home_rapport_local.html"

def get_context_data(self, **kwargs):
kwargs["form"] = NewsletterForm()
return super().get_context_data(**kwargs)
12 changes: 12 additions & 0 deletions home/views/HomeView.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.views.generic import TemplateView

from home.forms import NewsletterForm
from utils.views_mixins import BreadCrumbMixin


class HomeView(BreadCrumbMixin, TemplateView):
template_name = "home/home.html"

def get_context_data(self, **kwargs):
kwargs["form"] = NewsletterForm()
return super().get_context_data(**kwargs)
7 changes: 7 additions & 0 deletions home/views/LegalNoticeView.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.views.generic import TemplateView

from utils.views_mixins import BreadCrumbMixin


class LegalNoticeView(BreadCrumbMixin, TemplateView):
template_name = "home/legal_notices.html"
Loading

0 comments on commit 2645c19

Please sign in to comment.