Automatisation de l'étiquetage des événements après ajout d'un alias

This commit is contained in:
Jean-Marie Favreau 2024-04-27 20:18:09 +02:00
parent 32bde7d3a8
commit 76d3bb78ba
3 changed files with 167 additions and 151 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: agenda_culturel\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-04-27 16:25+0000\n"
"POT-Creation-Date: 2024-04-27 18:16+0000\n"
"PO-Revision-Date: 2023-10-29 14:16+0000\n"
"Last-Translator: Jean-Marie Favreau <jeanmarie.favreau@free.fr>\n"
"Language-Team: Jean-Marie Favreau <jeanmarie.favreau@free.fr>\n"
@ -56,8 +56,8 @@ msgid "Cannot extract event from url {}"
msgstr "Impossible d'extraire l'événement depuis l'url {}"
#: agenda_culturel/models.py:39 agenda_culturel/models.py:68
#: agenda_culturel/models.py:162 agenda_culturel/models.py:770
#: agenda_culturel/models.py:809
#: agenda_culturel/models.py:162 agenda_culturel/models.py:792
#: agenda_culturel/models.py:831
msgid "Name"
msgstr "Nom"
@ -105,8 +105,8 @@ msgstr "Couleur"
msgid "Color used as background for the category"
msgstr "Couleur utilisée comme fond de la catégorie"
#: agenda_culturel/models.py:115 agenda_culturel/models.py:205
#: agenda_culturel/models.py:821 agenda_culturel/models.py:872
#: agenda_culturel/models.py:115 agenda_culturel/models.py:227
#: agenda_culturel/models.py:843 agenda_culturel/models.py:894
msgid "Category"
msgstr "Catégorie"
@ -150,73 +150,73 @@ msgstr ""
msgid "Places"
msgstr "Lieux"
#: agenda_culturel/models.py:189 agenda_culturel/models.py:819
#: agenda_culturel/models.py:211 agenda_culturel/models.py:841
msgid "Published"
msgstr "Publié"
#: agenda_culturel/models.py:190
#: agenda_culturel/models.py:212
msgid "Draft"
msgstr "Brouillon"
#: agenda_culturel/models.py:191
#: agenda_culturel/models.py:213
msgid "Trash"
msgstr "Corbeille"
#: agenda_culturel/models.py:201
#: agenda_culturel/models.py:223
msgid "Title"
msgstr "Titre"
#: agenda_culturel/models.py:201
#: agenda_culturel/models.py:223
msgid "Short title"
msgstr "Titre court"
#: agenda_culturel/models.py:203 agenda_culturel/models.py:856
#: agenda_culturel/models.py:225 agenda_culturel/models.py:878
msgid "Status"
msgstr "Status"
#: agenda_culturel/models.py:205
#: agenda_culturel/models.py:227
msgid "Category of the event"
msgstr "Catégorie de l'événement"
#: agenda_culturel/models.py:207
#: agenda_culturel/models.py:229
msgid "Day of the event"
msgstr "Date de l'événement"
#: agenda_culturel/models.py:208
#: agenda_culturel/models.py:230
msgid "Starting time"
msgstr "Heure de début"
#: agenda_culturel/models.py:210
#: agenda_culturel/models.py:232
msgid "End day of the event"
msgstr "Fin de l'événement"
#: agenda_culturel/models.py:210
#: agenda_culturel/models.py:232
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:211
#: agenda_culturel/models.py:233
msgid "Final time"
msgstr "Heure de fin"
#: agenda_culturel/models.py:213
#: agenda_culturel/models.py:235
msgid "Recurrence"
msgstr "Récurrence"
#: agenda_culturel/models.py:215 agenda_culturel/models.py:820
#: agenda_culturel/models.py:237 agenda_culturel/models.py:842
msgid "Location"
msgstr "Localisation"
#: agenda_culturel/models.py:215
#: agenda_culturel/models.py:237
msgid "Address of the event"
msgstr "Adresse de l'événement"
#: agenda_culturel/models.py:216
#: agenda_culturel/models.py:238
msgid "Location (free form)"
msgstr "Localisation (forme libre)"
#: agenda_culturel/models.py:216
#: agenda_culturel/models.py:238
msgid ""
"Address of the event in case its not available in the already known places "
"(free form)"
@ -224,187 +224,187 @@ msgstr ""
"Addresse d'un événement si elle n'est pas déjà présente dans la liste des "
"lieux disponible (forme libre)"
#: agenda_culturel/models.py:218
#: agenda_culturel/models.py:240
msgid "Description"
msgstr "Description"
#: agenda_culturel/models.py:218
#: agenda_culturel/models.py:240
msgid "General description of the event"
msgstr "Description générale de l'événement"
#: agenda_culturel/models.py:220
#: agenda_culturel/models.py:242
msgid "Illustration (local image)"
msgstr "Illustration (image locale)"
#: agenda_culturel/models.py:220
#: agenda_culturel/models.py:242
msgid "Illustration image stored in the agenda server"
msgstr "Image d'illustration stockée sur le serveur de l'agenda"
#: agenda_culturel/models.py:222
#: agenda_culturel/models.py:244
msgid "Illustration"
msgstr "Illustration"
#: agenda_culturel/models.py:222
#: agenda_culturel/models.py:244
msgid "URL of the illustration image"
msgstr "URL de l'image illustrative"
#: agenda_culturel/models.py:223
#: agenda_culturel/models.py:245
msgid "Illustration description"
msgstr "Description de l'illustration"
#: agenda_culturel/models.py:223
#: agenda_culturel/models.py:245
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:225
#: agenda_culturel/models.py:247
msgid "Importation source"
msgstr "Source d'importation"
#: agenda_culturel/models.py:225
#: agenda_culturel/models.py:247
msgid "Importation source used to detect removed entries."
msgstr "Source d'importation utilisée pour détecter les éléments supprimés/"
#: agenda_culturel/models.py:226
#: agenda_culturel/models.py:248
msgid "UUIDs"
msgstr "UUIDs"
#: agenda_culturel/models.py:226
#: agenda_culturel/models.py:248
msgid "UUIDs from import to detect duplicated entries."
msgstr "UUIDs utilisés pendant l'import pour détecter les entrées dupliquées"
#: agenda_culturel/models.py:227
#: agenda_culturel/models.py:249
msgid "URLs"
msgstr "URLs"
#: agenda_culturel/models.py:227
#: agenda_culturel/models.py:249
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:229
#: agenda_culturel/models.py:251
msgid "Tags"
msgstr "Étiquettes"
#: agenda_culturel/models.py:229
#: agenda_culturel/models.py:251
msgid "A list of tags that describe the event."
msgstr "Une liste d'étiquettes décrivant l'événement"
#: agenda_culturel/models.py:231
#: agenda_culturel/models.py:253
msgid "Possibly duplicated"
msgstr "Possibles doublons"
#: agenda_culturel/models.py:272
#: agenda_culturel/models.py:294
msgid "Event"
msgstr "Événement"
#: agenda_culturel/models.py:273
#: agenda_culturel/models.py:295
msgid "Events"
msgstr "Événements"
#: agenda_culturel/models.py:766
#: agenda_culturel/models.py:788
msgid "Contact message"
msgstr "Message de contact"
#: agenda_culturel/models.py:767
#: agenda_culturel/models.py:789
msgid "Contact messages"
msgstr "Messages de contact"
#: agenda_culturel/models.py:769
#: agenda_culturel/models.py:791
msgid "Subject"
msgstr "Sujet"
#: agenda_culturel/models.py:769
#: agenda_culturel/models.py:791
msgid "The subject of your message"
msgstr "Sujet de votre message"
#: agenda_culturel/models.py:770
#: agenda_culturel/models.py:792
msgid "Your name"
msgstr "Votre nom"
#: agenda_culturel/models.py:771
#: agenda_culturel/models.py:793
msgid "Email address"
msgstr "Adresse email"
#: agenda_culturel/models.py:771
#: agenda_culturel/models.py:793
msgid "Your email address"
msgstr "Votre adresse email"
#: agenda_culturel/models.py:772
#: agenda_culturel/models.py:794
msgid "Message"
msgstr "Message"
#: agenda_culturel/models.py:772
#: agenda_culturel/models.py:794
msgid "Your message"
msgstr "Votre message"
#: agenda_culturel/models.py:776 agenda_culturel/views.py:470
#: agenda_culturel/models.py:798 agenda_culturel/views.py:470
msgid "Closed"
msgstr "Fermé"
#: agenda_culturel/models.py:776
#: agenda_culturel/models.py:798
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:777
#: agenda_culturel/models.py:799
msgid "Comments"
msgstr "Commentaires"
#: agenda_culturel/models.py:777
#: agenda_culturel/models.py:799
msgid "Comments on the message from the moderation team"
msgstr "Commentaires sur ce message par l'équipe de modération"
#: agenda_culturel/models.py:787 agenda_culturel/models.py:854
#: agenda_culturel/models.py:809 agenda_culturel/models.py:876
msgid "Recurrent import"
msgstr "Import récurrent"
#: agenda_culturel/models.py:788
#: agenda_culturel/models.py:810
msgid "Recurrent imports"
msgstr "Imports récurrents"
#: agenda_culturel/models.py:792
#: agenda_culturel/models.py:814
msgid "ical"
msgstr "ical"
#: agenda_culturel/models.py:793
#: agenda_culturel/models.py:815
msgid "ical no busy"
msgstr "ical sans busy"
#: agenda_culturel/models.py:794
#: agenda_culturel/models.py:816
msgid "ical no VC"
msgstr "ical sans VC"
#: agenda_culturel/models.py:795
#: agenda_culturel/models.py:817
msgid "lacoope.org"
msgstr "lacoope.org"
#: agenda_culturel/models.py:796
#: agenda_culturel/models.py:818
msgid "la comédie"
msgstr "la comédie"
#: agenda_culturel/models.py:797
#: agenda_culturel/models.py:819
msgid "le fotomat"
msgstr "le fotomat"
#: agenda_culturel/models.py:798
#: agenda_culturel/models.py:820
msgid "la puce à loreille"
msgstr "la puce à loreille"
#: agenda_culturel/models.py:801
#: agenda_culturel/models.py:823
msgid "simple"
msgstr "simple"
#: agenda_culturel/models.py:802
#: agenda_culturel/models.py:824
msgid "Headless Chromium"
msgstr "chromium sans interface"
#: agenda_culturel/models.py:806
#: agenda_culturel/models.py:828
msgid "daily"
msgstr "chaque jour"
#: agenda_culturel/models.py:807
#: agenda_culturel/models.py:829
msgid "weekly"
msgstr "chaque semaine"
#: agenda_culturel/models.py:809
#: agenda_culturel/models.py:831
msgid ""
"Recurrent import name. Be careful to choose a name that is easy to "
"understand, as it will be public and displayed on the sites About page."
@ -412,127 +412,127 @@ msgstr ""
"Nom de l'import récurrent. Attention à choisir un nom compréhensible, car il "
"sera public, et affiché sur la page à propos du site."
#: agenda_culturel/models.py:810
#: agenda_culturel/models.py:832
msgid "Processor"
msgstr "Processeur"
#: agenda_culturel/models.py:811
#: agenda_culturel/models.py:833
msgid "Downloader"
msgstr "Téléchargeur"
#: agenda_culturel/models.py:813
#: agenda_culturel/models.py:835
msgid "Import recurrence"
msgstr "Récurrence d'import"
#: agenda_culturel/models.py:816
#: agenda_culturel/models.py:838
msgid "Source"
msgstr "Source"
#: agenda_culturel/models.py:816
#: agenda_culturel/models.py:838
msgid "URL of the source document"
msgstr "URL du document source"
#: agenda_culturel/models.py:817
#: agenda_culturel/models.py:839
msgid "Browsable url"
msgstr "URL navigable"
#: agenda_culturel/models.py:817
#: agenda_culturel/models.py:839
msgid "URL of the corresponding document that will be shown to visitors."
msgstr "URL correspondant au document et qui sera montrée aux visiteurs"
#: agenda_culturel/models.py:819
#: agenda_culturel/models.py:841
msgid "Status of each imported event (published or draft)"
msgstr "Status de chaque événement importé (publié ou brouillon)"
#: agenda_culturel/models.py:820
#: agenda_culturel/models.py:842
msgid "Address for each imported event"
msgstr "Adresse de chaque événement importé"
#: agenda_culturel/models.py:821
#: agenda_culturel/models.py:843
msgid "Category of each imported event"
msgstr "Catégorie de chaque événement importé"
#: agenda_culturel/models.py:822
#: agenda_culturel/models.py:844
msgid "Tags for each imported event"
msgstr "Étiquettes de chaque événement importé"
#: agenda_culturel/models.py:822
#: agenda_culturel/models.py:844
msgid "A list of tags that describe each imported event."
msgstr "Une liste d'étiquettes décrivant chaque événement importé"
#: agenda_culturel/models.py:841
#: agenda_culturel/models.py:863
msgid "Running"
msgstr "En cours"
#: agenda_culturel/models.py:842
#: agenda_culturel/models.py:864
msgid "Canceled"
msgstr "Annulé"
#: agenda_culturel/models.py:843
#: agenda_culturel/models.py:865
msgid "Success"
msgstr "Succès"
#: agenda_culturel/models.py:844
#: agenda_culturel/models.py:866
msgid "Failed"
msgstr "Erreur"
#: agenda_culturel/models.py:847
#: agenda_culturel/models.py:869
msgid "Batch importation"
msgstr "Importation par lot"
#: agenda_culturel/models.py:848
#: agenda_culturel/models.py:870
msgid "Batch importations"
msgstr "Importations par lot"
#: agenda_culturel/models.py:854
#: agenda_culturel/models.py:876
msgid "Reference to the recurrent import processing"
msgstr "Référence du processus d'import récurrent"
#: agenda_culturel/models.py:858
#: agenda_culturel/models.py:880
msgid "Error message"
msgstr "Votre message"
#: agenda_culturel/models.py:860
#: agenda_culturel/models.py:882
msgid "Number of collected events"
msgstr "Nombre d'événements collectés"
#: agenda_culturel/models.py:861
#: agenda_culturel/models.py:883
msgid "Number of imported events"
msgstr "Nombre d'événements importés"
#: agenda_culturel/models.py:862
#: agenda_culturel/models.py:884
msgid "Number of updated events"
msgstr "Nombre d'événements mis à jour"
#: agenda_culturel/models.py:863
#: agenda_culturel/models.py:885
msgid "Number of removed events"
msgstr "Nombre d'événements supprimés"
#: agenda_culturel/models.py:870
#: agenda_culturel/models.py:892
msgid "Weight"
msgstr "Poids"
#: agenda_culturel/models.py:870
#: agenda_culturel/models.py:892
msgid "The lower is the weight, the earlier the filter is applied"
msgstr "Plus le poids est léger, plus le filtre sera appliqué tôt"
#: agenda_culturel/models.py:872
#: agenda_culturel/models.py:894
msgid "Category applied to the event"
msgstr "Catégorie appliquée à l'événement"
#: agenda_culturel/models.py:874
#: agenda_culturel/models.py:896
msgid "Contained in the title"
msgstr "Contenu dans le titre"
#: agenda_culturel/models.py:874
#: agenda_culturel/models.py:896
msgid "Text contained in the event title"
msgstr "Texte contenu dans le titre de l'événement"
#: agenda_culturel/models.py:875
#: agenda_culturel/models.py:897
msgid "Exact title extract"
msgstr "Extrait exact du titre"
#: agenda_culturel/models.py:875
#: agenda_culturel/models.py:897
msgid ""
"If checked, the extract will be searched for in the title using the exact "
"form (capitals, accents)."
@ -540,19 +540,19 @@ msgstr ""
"Si coché, l'extrait sera recherché dans le titre en utilisant la forme "
"exacte (majuscules, accents)"
#: agenda_culturel/models.py:877
#: agenda_culturel/models.py:899
msgid "Contained in the description"
msgstr "Contenu dans la description"
#: agenda_culturel/models.py:877
#: agenda_culturel/models.py:899
msgid "Text contained in the description"
msgstr "Texte contenu dans la description"
#: agenda_culturel/models.py:878
#: agenda_culturel/models.py:900
msgid "Exact description extract"
msgstr "Extrait exact de description"
#: agenda_culturel/models.py:878
#: agenda_culturel/models.py:900
msgid ""
"If checked, the extract will be searched for in the description using the "
"exact form (capitals, accents)."
@ -560,19 +560,19 @@ msgstr ""
"Si coché, l'extrait sera recherché dans la description en utilisant la forme "
"exacte (majuscules, accents)"
#: agenda_culturel/models.py:880
#: agenda_culturel/models.py:902
msgid "Contained in the location"
msgstr "Contenu dans la localisation"
#: agenda_culturel/models.py:880
#: agenda_culturel/models.py:902
msgid "Text contained in the event location"
msgstr "Texte contenu dans la localisation de l'événement"
#: agenda_culturel/models.py:881
#: agenda_culturel/models.py:903
msgid "Exact location extract"
msgstr "Extrait exact de localisation"
#: agenda_culturel/models.py:881
#: agenda_culturel/models.py:903
msgid ""
"If checked, the extract will be searched for in the location using the exact "
"form (capitals, accents)."
@ -580,52 +580,52 @@ msgstr ""
"Si coché, l'extrait sera recherché dans la localisation en utilisant la "
"forme exacte (majuscules, accents)"
#: agenda_culturel/models.py:884
#: agenda_culturel/models.py:906
msgid "Categorisation rule"
msgstr "Règle de catégorisation"
#: agenda_culturel/models.py:885
#: agenda_culturel/models.py:907
msgid "Categorisation rules"
msgstr "Règles de catégorisation"
#: agenda_culturel/models.py:941 agenda_culturel/models.py:962
#: agenda_culturel/models.py:963 agenda_culturel/models.py:984
msgid "Question"
msgstr "Question"
#: agenda_culturel/models.py:941 agenda_culturel/models.py:964
#: agenda_culturel/models.py:963 agenda_culturel/models.py:986
msgid "Text that will be shown to moderators"
msgstr "Text tel que présenté aux modérateurices"
#: agenda_culturel/models.py:944
#: agenda_culturel/models.py:966
msgid "Moderation question"
msgstr "Question de modération"
#: agenda_culturel/models.py:945
#: agenda_culturel/models.py:967
msgid "Moderation questions"
msgstr "Questions de modération"
#: agenda_culturel/models.py:962
#: agenda_culturel/models.py:984
msgid "Associated question from moderation"
msgstr "Question associée pour la modération"
#: agenda_culturel/models.py:964
#: agenda_culturel/models.py:986
msgid "Answer"
msgstr "Réponse"
#: agenda_culturel/models.py:966
#: agenda_culturel/models.py:988
msgid "Adds tags"
msgstr "Ajoute les étiquettes"
#: agenda_culturel/models.py:966
#: agenda_culturel/models.py:988
msgid "A list of tags that will be added if you choose this answer."
msgstr ""
"Une liste d'étiquettes qui seront ajoutées si vous choisissez cette réponse."
#: agenda_culturel/models.py:967
#: agenda_culturel/models.py:989
msgid "Removes tags"
msgstr "Retire les étiquettes"
#: agenda_culturel/models.py:967
#: agenda_culturel/models.py:989
msgid "A list of tags that will be removed if you choose this answer."
msgstr ""
"Une liste d'étiquettes qui seront retirées si vous choisissez cette réponse."
@ -804,33 +804,36 @@ msgstr ""
msgid "The moderation question has been created with success."
msgstr "La question de modération a été créée avec succès."
#: agenda_culturel/views.py:1123 agenda_culturel/views.py:1178
#: agenda_culturel/views.py:1112 agenda_culturel/views.py:1167
#: agenda_culturel/views.py:1196
msgid "{} events have been updated."
msgstr "{} événements ont été mis à jour."
#: agenda_culturel/views.py:1125 agenda_culturel/views.py:1180
#: agenda_culturel/views.py:1114 agenda_culturel/views.py:1169
#: agenda_culturel/views.py:1198
msgid "1 event has been updated."
msgstr "1 événement a été mis à jour"
#: agenda_culturel/views.py:1127 agenda_culturel/views.py:1182
#: agenda_culturel/views.py:1116 agenda_culturel/views.py:1171
#: agenda_culturel/views.py:1200
msgid "No events have been modified."
msgstr "Aucun événement n'a été modifié."
#: agenda_culturel/views.py:1135
#: agenda_culturel/views.py:1124
msgid "The place has been successfully updated."
msgstr "Le lieu a été modifié avec succès."
#: agenda_culturel/views.py:1142
#: agenda_culturel/views.py:1131
msgid "The place has been successfully created."
msgstr "Le lieu a été créé avec succès."
#: agenda_culturel/views.py:1201
msgid "The selected place has been assigned to the event. "
msgstr "Le lieu sélectionné a été assigné à l'événement. "
#: agenda_culturel/views.py:1189
msgid "The selected place has been assigned to the event."
msgstr "Le lieu sélectionné a été assigné à l'événement."
#: agenda_culturel/views.py:1203
msgid "A new alias has been added to the selected place. "
msgstr "Un nouvel alias a été créé pour le lieu sélectionné. "
#: agenda_culturel/views.py:1191
msgid "A new alias has been added to the selected place."
msgstr "Un nouvel alias a été créé pour le lieu sélectionné."
msgid "Recurrent import name"
msgstr "Nome de l'import récurrent"

View File

@ -182,6 +182,21 @@ class Place(models.Model):
def match(self, event):
return event.location in self.aliases
def associate_matching_events(self):
u_events = Event.objects.filter(exact_location__isnull=True)
to_be_updated = []
# try to find matches
for ue in u_events:
if self.match(ue):
ue.exact_location = self
to_be_updated.append(ue)
continue
# update events with a location
Event.objects.bulk_update(to_be_updated, fields=["exact_location"])
return len(to_be_updated)
def get_all_cities():
try:
tags = list([p["city"] for p in Place.objects.values("city").distinct().order_by("city")])

View File

@ -1106,18 +1106,7 @@ class UpdatePlaces:
# if required, find all matching events
if form.apply():
u_events = Event.objects.filter(exact_location__isnull=True)
to_be_updated = []
# try to find matches
for ue in u_events:
if p.match(ue):
ue.exact_location = p
to_be_updated.append(ue)
continue
# update events with a location
Event.objects.bulk_update(to_be_updated, fields=["exact_location"])
self.nb_applied += len(to_be_updated)
self.nb_applied += p.associate_matching_events()
if self.nb_applied > 1:
messages.success(self.request, _("{} events have been updated.").format(self.nb_applied))
@ -1192,16 +1181,25 @@ class UnknownPlaceAddView(PermissionRequiredMixin, SuccessMessageMixin, UpdateVi
template_name = 'agenda_culturel/place_unknown_form.html'
def form_valid(self, form):
self.modified_event = form.modified_event()
return super().form_valid(form)
def get_success_message(self, cleaned_data):
msg = ""
if cleaned_data.get("place"):
msg += _('The selected place has been assigned to the event. ')
if cleaned_data.get('add_alias'):
msg += _('A new alias has been added to the selected place. ')
return msg
self.modified_event = form.cleaned_data.get('place')
result = super().form_valid(form)
if form.cleaned_data.get('place'):
messages.success(self.request, _("The selected place has been assigned to the event."))
if form.cleaned_data.get("add_alias"):
messages.success(self.request, _("A new alias has been added to the selected place."))
nb_applied = form.cleaned_data.get('place').associate_matching_events()
if nb_applied > 1:
messages.success(self.request, _("{} events have been updated.").format(nb_applied))
elif nb_applied == 1:
messages.success(self.request, _("1 event has been updated."))
else:
messages.info(self.request, _("No events have been modified."))
return result
def get_success_url(self):
if self.modified_event: