From 3e8f28422fe6eead64fffd3396fd4f64302fd0cc Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Sat, 16 Dec 2023 19:37:13 +0100 Subject: [PATCH] ajout d'un formulaire de contact --- .../locale/fr/LC_MESSAGES/django.po | 355 ++++++++++-------- .../migrations/0007_contactmessage.py | 26 ++ ...ge_author_contactmessage_email_and_more.py | 28 ++ ...e_comments_alter_contactmessage_message.py | 24 ++ src/agenda_culturel/models.py | 13 + .../templates/agenda_culturel/page.html | 2 +- src/agenda_culturel/urls.py | 3 +- src/agenda_culturel/views.py | 36 +- 8 files changed, 303 insertions(+), 184 deletions(-) create mode 100644 src/agenda_culturel/migrations/0007_contactmessage.py create mode 100644 src/agenda_culturel/migrations/0008_remove_contactmessage_author_contactmessage_email_and_more.py create mode 100644 src/agenda_culturel/migrations/0009_contactmessage_comments_alter_contactmessage_message.py diff --git a/src/agenda_culturel/locale/fr/LC_MESSAGES/django.po b/src/agenda_culturel/locale/fr/LC_MESSAGES/django.po index 6441a0d..5fb4d84 100644 --- a/src/agenda_culturel/locale/fr/LC_MESSAGES/django.po +++ b/src/agenda_culturel/locale/fr/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: agenda_culturel\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-10-29 21:20+0000\n" +"POT-Creation-Date: 2023-12-16 18:21+0000\n" "PO-Revision-Date: 2023-10-29 14:16+0000\n" "Last-Translator: Jean-Marie Favreau \n" "Language-Team: Jean-Marie Favreau \n" @@ -17,258 +17,305 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: agenda_culturel/models.py:25 +#: agenda_culturel/forms.py:36 +msgid "The start date cannot be earler than today." +msgstr "La date de début ne peut pas être avant aujourd'hui." + +#: agenda_culturel/forms.py:46 +msgid "The end date must be after the start date." +msgstr "La date de fin doit être après la date de début." + +#: agenda_culturel/forms.py:48 +msgid "The end date cannot be earler than today." +msgstr "La date de fin ne peut pas être avant aujourd'hui." + +#: agenda_culturel/forms.py:63 +msgid "The end time cannot be earlier than the start time." +msgstr "L'heure de fin ne peut pas être avant l'heure de début." + +#: agenda_culturel/models.py:19 agenda_culturel/models.py:48 +#: agenda_culturel/models.py:179 msgid "Name" msgstr "Nom" -#: agenda_culturel/models.py:25 +#: agenda_culturel/models.py:19 agenda_culturel/models.py:48 msgid "Category name" msgstr "Nom de la catégorie" -#: agenda_culturel/models.py:26 +#: agenda_culturel/models.py:20 +msgid "Content" +msgstr "Contenu" + +#: agenda_culturel/models.py:20 +msgid "Text as shown to the visitors" +msgstr "Text tel que présenté aux visiteureuses" + +#: agenda_culturel/models.py:21 +msgid "URL path" +msgstr "" + +#: agenda_culturel/models.py:21 +msgid "URL path where the content is included." +msgstr "" + +#: agenda_culturel/models.py:49 msgid "Alternative Name" msgstr "Nom alternatif" -#: agenda_culturel/models.py:26 +#: agenda_culturel/models.py:49 msgid "Alternative name used with a time period" msgstr "Nom alternatif utilisé avec une période de temps" -#: agenda_culturel/models.py:27 -#, fuzzy -#| msgid "Short title" +#: agenda_culturel/models.py:50 msgid "Short name" msgstr "Nom court" -#: agenda_culturel/models.py:27 +#: agenda_culturel/models.py:50 msgid "Short name of the category" msgstr "Nom court de la catégorie" -#: agenda_culturel/models.py:28 +#: agenda_culturel/models.py:51 msgid "Color" msgstr "Couleur" -#: agenda_culturel/models.py:28 +#: agenda_culturel/models.py:51 msgid "Color used as background for the category" msgstr "Couleur utilisée comme fond de la catégorie" -#: agenda_culturel/models.py:53 agenda_culturel/models.py:70 +#: agenda_culturel/models.py:88 agenda_culturel/models.py:105 msgid "Category" msgstr "Catégorie" -#: agenda_culturel/models.py:54 +#: agenda_culturel/models.py:89 msgid "Categories" msgstr "Catégories" -#: agenda_culturel/models.py:59 +#: agenda_culturel/models.py:94 msgid "Published" msgstr "Publié" -#: agenda_culturel/models.py:60 -msgid "Trash" -msgstr "Corbeille" - -#: agenda_culturel/models.py:61 +#: agenda_culturel/models.py:95 msgid "Draft" msgstr "Brouillon" -#: agenda_culturel/models.py:66 +#: agenda_culturel/models.py:96 +msgid "Trash" +msgstr "Corbeille" + +#: agenda_culturel/models.py:101 msgid "Title" msgstr "Titre" -#: agenda_culturel/models.py:66 +#: agenda_culturel/models.py:101 msgid "Short title" msgstr "Titre court" -#: agenda_culturel/models.py:68 +#: agenda_culturel/models.py:103 msgid "Status" msgstr "Status" -#: agenda_culturel/models.py:70 +#: agenda_culturel/models.py:105 msgid "Category of the event" msgstr "Catégorie de l'événement" -#: agenda_culturel/models.py:72 +#: agenda_culturel/models.py:107 msgid "Day of the event" msgstr "Date de l'événement" -#: agenda_culturel/models.py:73 +#: agenda_culturel/models.py:108 msgid "Starting time" msgstr "Heure de début" -#: agenda_culturel/models.py:75 +#: agenda_culturel/models.py:110 msgid "End day of the event" msgstr "Fin de l'événement" -#: agenda_culturel/models.py:75 +#: agenda_culturel/models.py:110 msgid "End day of the event, only required if different from the start day." msgstr "" "Date de fin de l'événement, uniquement nécessaire s'il est différent du " "premier jour de l'événement" -#: agenda_culturel/models.py:76 +#: agenda_culturel/models.py:111 msgid "Final time" msgstr "Heure de fin" -#: agenda_culturel/models.py:78 +#: agenda_culturel/models.py:113 msgid "Location" msgstr "Localisation" -#: agenda_culturel/models.py:78 +#: agenda_culturel/models.py:113 msgid "Address of the event" msgstr "Adresse de l'événement" -#: agenda_culturel/models.py:80 +#: agenda_culturel/models.py:115 msgid "Description" msgstr "Description" -#: agenda_culturel/models.py:80 +#: agenda_culturel/models.py:115 msgid "General description of the event" msgstr "Description générale de l'événement" -#: agenda_culturel/models.py:82 -msgid "Illustration" -msgstr "Illustration" - -#: agenda_culturel/models.py:82 -msgid "URL of the illustration image" -msgstr "URL de l'image illustrative" - -#: agenda_culturel/models.py:83 -msgid "Illustration description" -msgstr "Description de l'illustration" - -#: agenda_culturel/models.py:83 -msgid "Alternative text used by screen readers for the image" -msgstr "Texte alternatif utiliser par les lecteurs d'écrans pour l'image" - -#: agenda_culturel/models.py:85 -msgid "URLs" -msgstr "URLs" - -#: agenda_culturel/models.py:85 -msgid "List of all the urls where this event can be found." -msgstr "Liste de toutes les urls où l'événement peut être trouvé." - -#: agenda_culturel/models.py:87 -msgid "Tags" -msgstr "Étiquettes" - -#: agenda_culturel/models.py:87 -msgid "A list of tags that describe the event." -msgstr "Une liste d'étiquettes décrivant l'événement" - -#: agenda_culturel/models.py:96 -msgid "Event" -msgstr "Événement" - -#: agenda_culturel/models.py:97 -msgid "Events" -msgstr "Événements" - -#: agenda_culturel/models.py:101 -msgid "URL" -msgstr "URL" - -#: agenda_culturel/models.py:101 -msgid "URL where this event can be found." -msgstr "URL où l'événement peut être trouvé." - -#: agenda_culturel/models.py:105 -msgid "Event submission form" -msgstr "Formulaire de proposition d'événement" - -#: agenda_culturel/models.py:106 -msgid "Event submissions forms" -msgstr "Formulaires de proposition d'événement" - -#: agenda_culturel/settings/base.py:122 -msgid "English" -msgstr "anglais" - -#: agenda_culturel/settings/base.py:123 -msgid "French" -msgstr "français" - -msgid "this week" -msgstr "cette semaine" - -msgid "this weekend" -msgstr "ce week-end" - -msgid "next week" -msgstr "la semaine prochaine" - -msgid "next weekend" -msgstr "le week-end prochain" - -msgid "this month" -msgstr "ce mois-ci" - -msgid "next month" -msgstr "le mois prochain" - -msgid "Add another" -msgstr "Ajouter une autre" - -msgid "Search" -msgstr "Rechercher" - -msgid "Text as shown to the visitors" -msgstr "Text tel que présenté aux visiteureuses" - -msgid "Content" -msgstr "Contenu" - +#: agenda_culturel/models.py:117 msgid "Illustration (local image)" msgstr "Illustration (image locale)" +#: agenda_culturel/models.py:117 msgid "Illustration image stored in the agenda server" msgstr "Image d'illustration stockée sur le serveur de l'agenda" -msgid "The event has been successfully modified." -msgstr "L'événement a été modifié avec succès." +#: agenda_culturel/models.py:119 +msgid "Illustration" +msgstr "Illustration" -msgid "The event has been successfully deleted." -msgstr "L'événement a été supprimé avec succès" +#: agenda_culturel/models.py:119 +msgid "URL of the illustration image" +msgstr "URL de l'image illustrative" -msgid "The URL has been submitted and the associated event will be integrated in the agenda after validation." -msgstr "L'adresse a été soumise et l'événement associé sera prochainement intégré à l'agenda après validation." +#: agenda_culturel/models.py:120 +msgid "Illustration description" +msgstr "Description de l'illustration" +#: agenda_culturel/models.py:120 +msgid "Alternative text used by screen readers for the image" +msgstr "Texte alternatif utiliser par les lecteurs d'écrans pour l'image" + +#: agenda_culturel/models.py:122 +msgid "URLs" +msgstr "URLs" + +#: agenda_culturel/models.py:122 +msgid "List of all the urls where this event can be found." +msgstr "Liste de toutes les urls où l'événement peut être trouvé." + +#: agenda_culturel/models.py:124 +msgid "Tags" +msgstr "Étiquettes" + +#: agenda_culturel/models.py:124 +msgid "A list of tags that describe the event." +msgstr "Une liste d'étiquettes décrivant l'événement" + +#: agenda_culturel/models.py:149 +msgid "Event" +msgstr "Événement" + +#: agenda_culturel/models.py:150 +msgid "Events" +msgstr "Événements" + +#: agenda_culturel/models.py:178 +msgid "Subject" +msgstr "Sujet" + +#: agenda_culturel/models.py:178 +msgid "The subject of your message" +msgstr "Sujet de votre message" + +#: agenda_culturel/models.py:179 +msgid "Your name" +msgstr "Votre nom" + +#: agenda_culturel/models.py:180 +msgid "Email address" +msgstr "Adresse email" + +#: agenda_culturel/models.py:180 +msgid "Your email address" +msgstr "Votre adresse email" + +#: agenda_culturel/models.py:181 +msgid "Message" +msgstr "Message" + +#: agenda_culturel/models.py:181 +msgid "Your message" +msgstr "Votre message" + +#: agenda_culturel/models.py:185 +msgid "Closed" +msgstr "Fermé" + +#: agenda_culturel/models.py:185 +msgid "this message has been processed and no longer needs to be handled" +msgstr "Ce message a été traité et ne nécessite plus d'être pris en charge" + +#: agenda_culturel/models.py:186 +msgid "Comments" +msgstr "Commentaires" + +#: agenda_culturel/models.py:186 +msgid "Comments on the message from the moderation team" +msgstr "Commentaires sur ce message par l'équipe de modération" + +#: agenda_culturel/settings/base.py:128 +msgid "English" +msgstr "anglais" + +#: agenda_culturel/settings/base.py:129 +msgid "French" +msgstr "français" + +#: agenda_culturel/views.py:182 msgid "The static content has been successfully updated." msgstr "Le contenu statique a été modifié avec succès." -msgid "The end date must be after the start date." -msgstr "La date de fin doit être après la date de début." +#: agenda_culturel/views.py:191 +msgid "Your message has been sent successfully." +msgstr "L'événement a été supprimé avec succès" -msgid "The end date cannot be earler than today." -msgstr "La date de fin ne peut pas être avant aujourd'hui." +#: agenda_culturel/views.py:197 +msgid "The event has been successfully modified." +msgstr "L'événement a été modifié avec succès." -msgid "The start date cannot be earler than today." -msgstr "La date de début ne peut pas être avant aujourd'hui." +#: agenda_culturel/views.py:208 +msgid "The event has been successfully deleted." +msgstr "L'événement a été supprimé avec succès" -msgid "The end time cannot be earlier than the start time." -msgstr "L'heure de fin ne peut pas être avant l'heure de début." +#: agenda_culturel/views.py:246 +msgid "The event is saved." +msgstr "L'événement est enregistré." -msgid "The event has been submitted and will be published as soon as it has been validated by the moderation team." -msgstr "L'événement a été soumis et sera publié dès qu'il aura été validé par l'équipe de modération." +#: agenda_culturel/views.py:249 +msgid "" +"The event has been submitted and will be published as soon as it has been " +"validated by the moderation team." +msgstr "" +"L'événement a été soumis et sera publié dès qu'il aura été validé par " +"l'équipe de modération." -msgid "The URL has been taken into account, and the associated event will be available in a few moments for validation." -msgstr "L'URL a été prise en compte, et l'événement associé sera disponible dans quelques instants pour validation." +#: agenda_culturel/views.py:279 +msgid "" +"The event has been successfully extracted, and you can now submit it after " +"modifying it if necessary." +msgstr "" +"L'événement a été extrait avec succès, vous pouvez maintenant le soumettre " +"après l'avoir modifié au besoin." -msgid "The event has been successfully extracted, and you can now submit it after modifying it if necessary." -msgstr "L'événement a été extrait avec succès, vous pouvez maintenant le soumettre après l'avoir modifié au besoin." - -msgid "Unable to extract an event from the proposed URL. Please use the form below to submit the event." -msgstr "Impossible d'extraire un événement depuis l'URL proposée. Veuillez utiliser le formulaire ci-dessous pour soumettre l'événement." +#: agenda_culturel/views.py:283 +msgid "" +"Unable to extract an event from the proposed URL. Please use the form below " +"to submit the event." +msgstr "" +"Impossible d'extraire un événement depuis l'URL proposée. Veuillez utiliser " +"le formulaire ci-dessous pour soumettre l'événement." +#: agenda_culturel/views.py:292 msgid "This URL has already been submitted, and you can find the event below." msgstr "Cette URL a déjà été soumise, et vous trouverez l'événement ci-dessous." +#: agenda_culturel/views.py:296 +msgid "" +"This URL has already been submitted, but has not been selected for " +"publication by the moderation team." +msgstr "" +"Cette URL a déjà été soumise, mais n'a pas été retenue par l'équipe de " +"modération pour la publication." + +#: agenda_culturel/views.py:298 msgid "This URL has already been submitted and is awaiting moderation." msgstr "Cette URL a déjà été soumise, et est en attente de modération" -msgid "This URL has already been submitted, but has not been selected for publication by the moderation team." -msgstr "Cette URL a déjà été soumise, mais n'a pas été retenue par l'équipe de modération pour la publication." - -msgid "The event is saved." -msgstr "L'événement est enregistré." \ No newline at end of file +#: agenda_culturel/views.py:329 +msgid "Search" +msgstr "Rechercher" diff --git a/src/agenda_culturel/migrations/0007_contactmessage.py b/src/agenda_culturel/migrations/0007_contactmessage.py new file mode 100644 index 0000000..56835fb --- /dev/null +++ b/src/agenda_culturel/migrations/0007_contactmessage.py @@ -0,0 +1,26 @@ +# Generated by Django 4.2.7 on 2023-12-16 18:06 + +import ckeditor.fields +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('agenda_culturel', '0006_alter_event_status'), + ] + + operations = [ + migrations.CreateModel( + name='ContactMessage', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('subject', models.CharField(help_text='The subject of your message', max_length=512, verbose_name='Subject')), + ('name', models.CharField(blank=True, help_text='Your name', max_length=512, null=True, verbose_name='Name')), + ('author', models.EmailField(blank=True, help_text='Your email address', max_length=254, null=True, verbose_name='Email address')), + ('date', models.DateTimeField(auto_now_add=True)), + ('closed', models.BooleanField(default=False, help_text='this message has been processed and no longer needs to be handled', verbose_name='Closed')), + ('message', ckeditor.fields.RichTextField(default='', help_text='Comments on the message from the modaration team', verbose_name='Comments')), + ], + ), + ] diff --git a/src/agenda_culturel/migrations/0008_remove_contactmessage_author_contactmessage_email_and_more.py b/src/agenda_culturel/migrations/0008_remove_contactmessage_author_contactmessage_email_and_more.py new file mode 100644 index 0000000..9151a9e --- /dev/null +++ b/src/agenda_culturel/migrations/0008_remove_contactmessage_author_contactmessage_email_and_more.py @@ -0,0 +1,28 @@ +# Generated by Django 4.2.7 on 2023-12-16 18:33 + +import ckeditor.fields +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('agenda_culturel', '0007_contactmessage'), + ] + + operations = [ + migrations.RemoveField( + model_name='contactmessage', + name='author', + ), + migrations.AddField( + model_name='contactmessage', + name='email', + field=models.EmailField(blank=True, help_text='Your email address', max_length=254, null=True, verbose_name='Email address'), + ), + migrations.AlterField( + model_name='contactmessage', + name='message', + field=ckeditor.fields.RichTextField(default='', help_text='Comments on the message from the moderation team', verbose_name='Comments'), + ), + ] diff --git a/src/agenda_culturel/migrations/0009_contactmessage_comments_alter_contactmessage_message.py b/src/agenda_culturel/migrations/0009_contactmessage_comments_alter_contactmessage_message.py new file mode 100644 index 0000000..e7958f0 --- /dev/null +++ b/src/agenda_culturel/migrations/0009_contactmessage_comments_alter_contactmessage_message.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.7 on 2023-12-16 18:35 + +import ckeditor.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('agenda_culturel', '0008_remove_contactmessage_author_contactmessage_email_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='contactmessage', + name='comments', + field=ckeditor.fields.RichTextField(default='', help_text='Comments on the message from the moderation team', verbose_name='Comments'), + ), + migrations.AlterField( + model_name='contactmessage', + name='message', + field=ckeditor.fields.RichTextField(help_text='Your message', verbose_name='Message'), + ), + ] diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index febdbe5..e3b1936 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -172,3 +172,16 @@ class Event(models.Model): def modified(self): return abs((self.modified_date - self.created_date).total_seconds()) > 1 + +class ContactMessage(models.Model): + + subject = models.CharField(verbose_name=_('Subject'), help_text=_('The subject of your message'), max_length=512) + name = models.CharField(verbose_name=_('Name'), help_text=_('Your name'), max_length=512, blank=True, null=True) + email = models.EmailField(verbose_name=_('Email address'), help_text=_('Your email address'), max_length=254, blank=True, null=True) + message = RichTextField(verbose_name=_('Message'), help_text=_('Your message')) + + date = models.DateTimeField(auto_now_add=True) + + closed = models.BooleanField(verbose_name=_('Closed'), help_text=_('this message has been processed and no longer needs to be handled'), default=False) + comments = RichTextField(verbose_name=_('Comments'), help_text=_('Comments on the message from the moderation team'), default="") + diff --git a/src/agenda_culturel/templates/agenda_culturel/page.html b/src/agenda_culturel/templates/agenda_culturel/page.html index dd19551..23fd797 100644 --- a/src/agenda_culturel/templates/agenda_culturel/page.html +++ b/src/agenda_culturel/templates/agenda_culturel/page.html @@ -70,7 +70,7 @@ Mentions légales
- Contact + Contact
Ajouter un événement diff --git a/src/agenda_culturel/urls.py b/src/agenda_culturel/urls.py index 69ce9dd..aec3b83 100644 --- a/src/agenda_culturel/urls.py +++ b/src/agenda_culturel/urls.py @@ -30,7 +30,8 @@ urlpatterns = [ path("static-content//edit", StaticContentUpdateView.as_view(), name="edit_static_content"), path('rechercher', event_search, name='event_search'), path('rechercher/complet/', event_search_full, name='event_search_full'), - path('mentions-legales', mentions_legales, name='mentions_legales') + path('mentions-legales', mentions_legales, name='mentions_legales'), + path('contact', ContactMessageCreateView.as_view(), name='contact') ] if settings.DEBUG: diff --git a/src/agenda_culturel/views.py b/src/agenda_culturel/views.py index 0653d96..0423c69 100644 --- a/src/agenda_culturel/views.py +++ b/src/agenda_culturel/views.py @@ -13,7 +13,7 @@ import urllib from .forms import EventSubmissionForm, EventForm -from .models import Event, Category, StaticContent +from .models import Event, Category, StaticContent, ContactMessage from django.utils import timezone from enum import StrEnum from datetime import date, timedelta @@ -97,6 +97,7 @@ def mentions_legales(request): context = { "title": "Mentions légales", "static_content": "mentions_legales", "url_path": reverse_lazy("mentions_legales") } return render(request, 'agenda_culturel/page-single.html', context) + def home(request): return week_view(request, home=True) @@ -181,34 +182,13 @@ class StaticContentUpdateView(SuccessMessageMixin, LoginRequiredMixin, UpdateVie success_message = _('The static content has been successfully updated.') +class ContactMessageCreateView(SuccessMessageMixin, CreateView): + model = ContactMessage + template_name = "agenda_culturel/contactmessage_create_form.html" + fields = ['subject', 'name', 'email', 'message'] -# class EventCreateView(SuccessMessageMixin, CreateView): -# model = Event - -# form_class = EventForm -# template_name_suffix = "_create_form" -# success_message = _('The event has been submitted and will be published as soon as it has been validated by the moderation team.') - -# def get_form_kwargs(self): -# kwargs = super().get_form_kwargs() -# kwargs['is_authenticated'] = self.request.user.is_authenticated -# return kwargs - - -# def get_initial(self): -# initial = super().get_initial() -# initial = initial.copy() -# initial["start_day"] = date.today() + timedelta(days=1) -# initial["start_time"] = "20:00" -# initial["end_time"] = "22:00" -# return initial - - -# def get_success_url(self, **kwargs): -# if self.request.user.is_authenticated: -# return self.object.get_absolute_url() -# else: -# return reverse_lazy("home") + success_url = reverse_lazy('home') + success_message = _('Your message has been sent successfully.') class EventUpdateView(SuccessMessageMixin, LoginRequiredMixin, UpdateView):