diff --git a/src/agenda_culturel/forms.py b/src/agenda_culturel/forms.py index 17d68b9..a5f9ea7 100644 --- a/src/agenda_culturel/forms.py +++ b/src/agenda_culturel/forms.py @@ -199,6 +199,8 @@ class SimpleContactForm(GroupFormMixin, Form): del self.fields["email"] del self.fields["comments"] +class URLSubmissionSimpleForm(Form): + url = URLField(max_length=512) class URLSubmissionForm(GroupFormMixin, Form): required_css_class = "required" diff --git a/src/agenda_culturel/import_tasks/extractor.py b/src/agenda_culturel/import_tasks/extractor.py index e8a8944..29fbf76 100644 --- a/src/agenda_culturel/import_tasks/extractor.py +++ b/src/agenda_culturel/import_tasks/extractor.py @@ -335,6 +335,12 @@ class Extractor(ABC): EventNotFoundExtractor, ] + def is_known_url_default_extractors(url): + for e in Extractor.get_default_extractors(True): + if e.is_known_url(url): + return True + return False + # A class that only produce a not found event class EventNotFoundExtractor(Extractor): diff --git a/src/agenda_culturel/import_tasks/generic_extractors/fbevent.py b/src/agenda_culturel/import_tasks/generic_extractors/fbevent.py index 851f0c2..7d18d99 100644 --- a/src/agenda_culturel/import_tasks/generic_extractors/fbevent.py +++ b/src/agenda_culturel/import_tasks/generic_extractors/fbevent.py @@ -227,6 +227,7 @@ class FacebookEvent: class CExtractor(Extractor): + pattern = r'^https?://(?:www\.|m\.)?facebook\.com/events/(\d+)(?:/(\d+))?(?:/([a-zA-Z0-9\-]+))?/?$' def __init__(self): super().__init__() self.has_2nd_method = True @@ -298,11 +299,15 @@ class CExtractor(Extractor): return url def is_known_url(url, include_links=True): - u = urlparse(url) - url_list = ["facebook.com", "www.facebook.com", "m.facebook.com"] + + if re.match(CExtractor.pattern, url): + return True + if include_links: - url_list.append("fb.me") - return u.netloc in url_list + u = urlparse(url) + return u.netloc == "fb.me" + else: + return False def extract( self, diff --git a/src/agenda_culturel/locale/fr/LC_MESSAGES/django.po b/src/agenda_culturel/locale/fr/LC_MESSAGES/django.po index ca93d62..5dee90f 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: 2025-04-12 14:10+0200\n" +"POT-Creation-Date: 2025-04-12 20:03+0200\n" "PO-Revision-Date: 2023-10-29 14:16+0000\n" "Last-Translator: Jean-Marie Favreau \n" "Language-Team: Jean-Marie Favreau \n" @@ -214,32 +214,32 @@ msgstr "" msgid "Receive notification of publication or leave a message for moderation" msgstr "Être notifié de la publication ou laisser un message à la modération" -#: agenda_culturel/forms.py:208 agenda_culturel/models.py:315 +#: agenda_culturel/forms.py:210 agenda_culturel/models.py:315 #: agenda_culturel/models.py:883 agenda_culturel/models.py:2924 #: agenda_culturel/models.py:3035 msgid "Category" msgstr "Catégorie" -#: agenda_culturel/forms.py:214 agenda_culturel/forms.py:247 -#: agenda_culturel/forms.py:293 agenda_culturel/forms.py:477 +#: agenda_culturel/forms.py:216 agenda_culturel/forms.py:249 +#: agenda_culturel/forms.py:295 agenda_culturel/forms.py:479 #: agenda_culturel/models.py:369 agenda_culturel/models.py:1000 msgid "Tags" msgstr "Étiquettes" -#: agenda_culturel/forms.py:222 agenda_culturel/forms.py:642 +#: agenda_culturel/forms.py:224 agenda_culturel/forms.py:644 #: agenda_culturel/models.py:1130 msgid "Event" msgstr "Événement" -#: agenda_culturel/forms.py:272 agenda_culturel/models.py:71 +#: agenda_culturel/forms.py:274 agenda_culturel/models.py:71 msgid "The '/' character is not allowed." msgstr "Le caractère '/' n'est pas autorisé." -#: agenda_culturel/forms.py:279 agenda_culturel/forms.py:483 +#: agenda_culturel/forms.py:281 agenda_culturel/forms.py:485 msgid "New tags" msgstr "Nouvelles étiquettes" -#: agenda_culturel/forms.py:281 agenda_culturel/forms.py:485 +#: agenda_culturel/forms.py:283 agenda_culturel/forms.py:487 msgid "" "Create new labels (sparingly). Note: by starting your tag with the " "characters “TW:”, youll create a “trigger warning” tag, and the associated " @@ -250,150 +250,150 @@ msgstr "" "étiquette “trigger warning”, et les événements associés seront annoncés " "comme tels." -#: agenda_culturel/forms.py:353 +#: agenda_culturel/forms.py:355 msgid "Main fields" msgstr "Champs principaux" -#: agenda_culturel/forms.py:356 +#: agenda_culturel/forms.py:358 msgid "Start of event" msgstr "Début de l'événement" -#: agenda_culturel/forms.py:360 +#: agenda_culturel/forms.py:362 msgid "End of event" msgstr "Fin de l'événement" -#: agenda_culturel/forms.py:366 +#: agenda_culturel/forms.py:368 msgid "This is a recurring event" msgstr "Cet événement est récurrent" -#: agenda_culturel/forms.py:378 +#: agenda_culturel/forms.py:380 msgid "Details" msgstr "Détails" -#: agenda_culturel/forms.py:383 agenda_culturel/models.py:912 +#: agenda_culturel/forms.py:385 agenda_culturel/models.py:912 #: agenda_culturel/models.py:2899 msgid "Location" msgstr "Localisation" -#: agenda_culturel/forms.py:388 agenda_culturel/models.py:113 +#: agenda_culturel/forms.py:390 agenda_culturel/models.py:113 #: agenda_culturel/models.py:956 msgid "Illustration" msgstr "Illustration" -#: agenda_culturel/forms.py:392 +#: agenda_culturel/forms.py:394 msgid "URLs" msgstr "URLs" -#: agenda_culturel/forms.py:396 agenda_culturel/forms.py:403 +#: agenda_culturel/forms.py:398 agenda_culturel/forms.py:405 msgid "Meta information" msgstr "Méta-informations" -#: agenda_culturel/forms.py:420 +#: agenda_culturel/forms.py:422 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:436 +#: agenda_culturel/forms.py:438 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/forms.py:478 +#: agenda_culturel/forms.py:480 msgid "Select tags from existing ones." msgstr "Sélectionner des étiquettes depuis celles existantes." -#: agenda_culturel/forms.py:539 +#: agenda_culturel/forms.py:541 msgid "JSON in the format expected for the import." msgstr "JSON dans le format attendu pour l'import" -#: agenda_culturel/forms.py:561 +#: agenda_culturel/forms.py:563 msgid " (locally modified version)" msgstr " (version modifiée localement)" -#: agenda_culturel/forms.py:565 +#: agenda_culturel/forms.py:567 msgid " (synchronized on import version)" msgstr " (version synchronisée sur l'import)" -#: agenda_culturel/forms.py:569 +#: agenda_culturel/forms.py:571 msgid "Select {} as representative version." msgstr "Sélectionner {} comme version représentative" -#: agenda_culturel/forms.py:579 +#: agenda_culturel/forms.py:581 msgid "Update {} using some fields from other versions (interactive mode)." msgstr "" "Mettre à jour {} en utilisant quelques champs des autres versions (mode " "interactif)." -#: agenda_culturel/forms.py:586 +#: agenda_culturel/forms.py:588 msgid " Warning: a version is already locally modified." msgstr " Attention: une version a déjà été modifiée localement." -#: agenda_culturel/forms.py:593 +#: agenda_culturel/forms.py:595 msgid "Create a new version by merging (interactive mode)." msgstr "Créer une nouvelle version par fusion (mode interactif)." -#: agenda_culturel/forms.py:601 +#: agenda_culturel/forms.py:603 msgid "Make {} independent." msgstr "Rendre {} indépendant." -#: agenda_culturel/forms.py:604 +#: agenda_culturel/forms.py:606 msgid "Make all versions independent." msgstr "Rendre toutes les versions indépendantes." -#: agenda_culturel/forms.py:676 agenda_culturel/forms.py:689 +#: agenda_culturel/forms.py:678 agenda_culturel/forms.py:691 msgid "Value of version {}" msgstr "Valeur de la version {}" -#: agenda_culturel/forms.py:681 +#: agenda_culturel/forms.py:683 msgid "Value of the selected version" msgstr "Valeur de la version sélectionnée" -#: agenda_culturel/forms.py:851 +#: agenda_culturel/forms.py:853 msgid "Apply category {} to the event {}" msgstr "Appliquer la catégorie {} à l'événement {}" -#: agenda_culturel/forms.py:868 agenda_culturel/models.py:700 +#: agenda_culturel/forms.py:870 agenda_culturel/models.py:700 #: agenda_culturel/models.py:3087 msgid "Place" msgstr "Lieu" -#: agenda_culturel/forms.py:870 +#: agenda_culturel/forms.py:872 msgid "Create a missing place" msgstr "Créer un lieu manquant" -#: agenda_culturel/forms.py:880 +#: agenda_culturel/forms.py:882 msgid "Add \"{}\" to the aliases of the place" msgstr "Ajouter « {} » aux alias du lieu" -#: agenda_culturel/forms.py:909 +#: agenda_culturel/forms.py:911 msgid "On saving, use aliases to detect all matching events with missing place" msgstr "" "Lors de l'enregistrement, utiliser des alias pour détecter tous les " "événements correspondants dont la place est manquante." -#: agenda_culturel/forms.py:922 +#: agenda_culturel/forms.py:924 msgid "Header" msgstr "Entête" -#: agenda_culturel/forms.py:925 agenda_culturel/models.py:662 +#: agenda_culturel/forms.py:927 agenda_culturel/models.py:662 msgid "Address" msgstr "Adresse" -#: agenda_culturel/forms.py:931 +#: agenda_culturel/forms.py:933 msgid "Meta" msgstr "Méta" -#: agenda_culturel/forms.py:934 +#: agenda_culturel/forms.py:936 msgid "Information" msgstr "Informations" -#: agenda_culturel/forms.py:986 +#: agenda_culturel/forms.py:988 msgid "Add a comment" msgstr "Ajouter un commentaire" -#: agenda_culturel/forms.py:1011 agenda_culturel/models.py:3188 +#: agenda_culturel/forms.py:1013 agenda_culturel/models.py:3188 msgid "Period type" msgstr "Type de période" -#: agenda_culturel/forms.py:1015 +#: agenda_culturel/forms.py:1017 msgid "ICAL file" msgstr "Fichier ICAL" @@ -899,11 +899,11 @@ msgstr "import récurrent" msgid "a non authenticated user" msgstr "un utilisateur non connecté" -#: agenda_culturel/models.py:1781 +#: agenda_culturel/models.py:1786 msgid "Your event has been published" msgstr "Ton événement a été publié" -#: agenda_culturel/models.py:1786 +#: agenda_culturel/models.py:1791 msgid "Your message has not been retained" msgstr "Ton événement n'a pas été retenu" @@ -1404,43 +1404,43 @@ msgstr " au " msgid "French" msgstr "français" -#: agenda_culturel/views.py:173 +#: agenda_culturel/views.py:175 msgid "Recurrent import name" msgstr "Nome de l'import récurrent" -#: agenda_culturel/views.py:174 +#: agenda_culturel/views.py:176 msgid "Add another" msgstr "Ajouter un autre" -#: agenda_culturel/views.py:175 +#: agenda_culturel/views.py:177 msgid "Browse..." msgstr "Naviguer..." -#: agenda_culturel/views.py:176 +#: agenda_culturel/views.py:178 msgid "No file selected." msgstr "Pas de fichier sélectionné." -#: agenda_culturel/views.py:194 +#: agenda_culturel/views.py:196 msgid ": error 500" msgstr ": erreur 500" -#: agenda_culturel/views.py:195 +#: agenda_culturel/views.py:197 msgid "An internal error has occurred on site {} at address {}." msgstr "Une erreur interne s'est produite sur le site {} à l'adresse {}." -#: agenda_culturel/views.py:234 +#: agenda_culturel/views.py:236 msgid "Moderation rules" msgstr "Règles de modération" -#: agenda_culturel/views.py:243 +#: agenda_culturel/views.py:245 msgid "Import requirements" msgstr "Besoins pour l'import" -#: agenda_culturel/views.py:449 +#: agenda_culturel/views.py:451 msgid "The static content has been successfully updated." msgstr "Le contenu statique a été modifié avec succès." -#: agenda_culturel/views.py:460 +#: agenda_culturel/views.py:462 msgid "" "The event cannot be updated because the import process is not available for " "the referenced sources." @@ -1448,21 +1448,21 @@ msgstr "" "La mise à jour de l'événement n'est pas possible car le processus d'import " "n'est pas disponible pour les sources référencées." -#: agenda_culturel/views.py:473 +#: agenda_culturel/views.py:475 msgid "The event update has been queued and will be completed shortly." msgstr "" "La mise à jour de l'événement a été mise en attente et sera effectuée sous " "peu." -#: agenda_culturel/views.py:502 agenda_culturel/views.py:586 +#: agenda_culturel/views.py:504 agenda_culturel/views.py:588 msgid " A message has been sent to the person who proposed the event." msgstr " Un message a été envoyé à la personne qui a proposé l'événement." -#: agenda_culturel/views.py:506 +#: agenda_culturel/views.py:508 msgid "The event has been successfully modified." msgstr "L'événement a été modifié avec succès." -#: agenda_culturel/views.py:530 +#: agenda_culturel/views.py:532 msgid "" "Changes will be visible on a local copy of the event. The version identical " "to the imported source will be hidden." @@ -1470,19 +1470,19 @@ msgstr "" "Les modifications seront visibles sur une copie locale de l'événement. La " "version fidèle à la source importée sera masquée." -#: agenda_culturel/views.py:591 +#: agenda_culturel/views.py:593 msgid "The event {} has been moderated with success." msgstr "L'événement {} a été modéré avec succès." -#: agenda_culturel/views.py:740 +#: agenda_culturel/views.py:742 msgid "The event has been successfully deleted." msgstr "L'événement a été supprimé avec succès." -#: agenda_culturel/views.py:820 +#: agenda_culturel/views.py:822 msgid "Comment" msgstr "Commentaire" -#: agenda_culturel/views.py:844 +#: agenda_culturel/views.py:846 msgid "" "The status has been successfully modified and a message has been sent to the " "person who proposed the event." @@ -1490,15 +1490,43 @@ msgstr "" "Le status a été modifié avec succès et un message a été envoyé à la personne " "qui a proposé l'événement." -#: agenda_culturel/views.py:848 +#: agenda_culturel/views.py:850 msgid "The status has been successfully modified." msgstr "Le status a été modifié avec succès." -#: agenda_culturel/views.py:888 +#: agenda_culturel/views.py:871 +msgid "" +"This type of address is known to the calendar, so an automatic import is " +"proposed." +msgstr "" +"Ce type d'adresse est connue du calendrier, alors un import automatique " +"est proposé." + +#: agenda_culturel/views.py:875 +msgid "" +"This type of address is unknown to the agenda. As a logged-in user, you can " +"still try to import the event, which may work if the page contains a google " +"calendar link, for example." +msgstr "" +"Ce type d'adresse est inconnu de l'agenda. En tant qu'utilisateur connecté, " +"tu peux tout de même tenter d'importer l'événement, ce qui peut fonctionner " +"lorsque la page contient un lien google agenda par exemple." + +#: agenda_culturel/views.py:878 +msgid "" +"This type of address is unknown to the calendar, so we suggest that you " +"enter the information for the event you wish to import, in addition to the " +"link you've provided." +msgstr "" +"Ce type d'adresse est inconnu de l'agenda, alors on te propose de saisir " +"les informations de l'événement que tu souhaites importer, pour compléter " +"l'adresse que tu nous as donnée." + +#: agenda_culturel/views.py:915 msgid "The event was created: {}." msgstr "L'événement a été créé: {}." -#: agenda_culturel/views.py:894 +#: agenda_culturel/views.py:921 msgid "" "The event has been submitted and will be published as soon as it has been " "validated by the moderation team." @@ -1506,99 +1534,99 @@ 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:908 +#: agenda_culturel/views.py:935 msgid "during the creation process" msgstr "pendant le processus d'import" -#: agenda_culturel/views.py:931 +#: agenda_culturel/views.py:958 msgid "A message has been sent to the person who proposed the initial event." msgstr "" "Un message a été envoyé à la personne qui a proposé l'événement initial." -#: agenda_culturel/views.py:1024 agenda_culturel/views.py:1102 +#: agenda_culturel/views.py:1051 agenda_culturel/views.py:1120 msgid "{} has not been submitted since its already known: {}." msgstr "{} n'a pas été soumis car il est déjà connu: {}." -#: agenda_culturel/views.py:1033 agenda_culturel/views.py:1111 +#: agenda_culturel/views.py:1060 agenda_culturel/views.py:1129 msgid "" "{} has not been submitted since its already known and currently into " "moderation process." msgstr "{} n'a pas été soumis car il est déjà connu et en cours de modération" -#: agenda_culturel/views.py:1045 +#: agenda_culturel/views.py:1072 msgid "Integrating {} url(s) into our import process." msgstr "Intégration de {} url(s) dans notre processus d'import." -#: agenda_culturel/views.py:1120 +#: agenda_culturel/views.py:1138 msgid "Integrating {} into our import process." msgstr "Intégration de {} dans notre processus d'import." -#: agenda_culturel/views.py:1236 +#: agenda_culturel/views.py:1260 msgid "Your message has been sent successfully." msgstr "Votre message a été envoyé avec succès." -#: agenda_culturel/views.py:1269 +#: agenda_culturel/views.py:1293 msgid "Reporting the event {} on {}" msgstr "Signaler l'événement {} du {}" -#: agenda_culturel/views.py:1279 +#: agenda_culturel/views.py:1303 msgid "The contact message has been successfully deleted." msgstr "Le message de contact a été supprimé avec succès." -#: agenda_culturel/views.py:1295 +#: agenda_culturel/views.py:1319 msgid "The contact message properties has been successfully modified." msgstr "Les propriétés du message de contact ont été modifié avec succès." -#: agenda_culturel/views.py:1473 +#: agenda_culturel/views.py:1497 msgid "Spam has been successfully deleted." msgstr "Le spam a été supprimé avec succès" -#: agenda_culturel/views.py:1650 +#: agenda_culturel/views.py:1674 msgid "The import has been run successfully." msgstr "L'import a été lancé avec succès" -#: agenda_culturel/views.py:1672 +#: agenda_culturel/views.py:1696 msgid "The import has been canceled." msgstr "L'import a été annulé" -#: agenda_culturel/views.py:1695 +#: agenda_culturel/views.py:1719 msgid "The orphan event update has been launched." msgstr "La mise à jour de l'événement orphelin a été lancée." -#: agenda_culturel/views.py:1791 +#: agenda_culturel/views.py:1815 msgid "The recurrent import has been successfully modified." msgstr "L'import récurrent a été modifié avec succès." -#: agenda_culturel/views.py:1803 +#: agenda_culturel/views.py:1827 msgid "The recurrent import has been successfully deleted." msgstr "L'import récurrent a été supprimé avec succès" -#: agenda_culturel/views.py:1849 +#: agenda_culturel/views.py:1873 msgid "The import has been launched." msgstr "L'import a été lancé" -#: agenda_culturel/views.py:1876 +#: agenda_culturel/views.py:1900 msgid "Imports has been launched." msgstr "Les imports ont été lancés" -#: agenda_culturel/views.py:1898 +#: agenda_culturel/views.py:1922 msgid "Facebook imports has been launched." msgstr "Les imports Facebook ont été lancés" -#: agenda_culturel/views.py:1961 +#: agenda_culturel/views.py:1985 msgid "Update successfully completed." msgstr "Mise à jour réalisée avec succès." -#: agenda_culturel/views.py:2029 +#: agenda_culturel/views.py:2053 msgid "Creation of a merged event has been successfully completed." msgstr "Création d'un événement fusionné réalisée avec succès." -#: agenda_culturel/views.py:2066 +#: agenda_culturel/views.py:2090 msgid "Events have been marked as unduplicated." msgstr "Les événements ont été marqués comme non dupliqués." -#: agenda_culturel/views.py:2083 agenda_culturel/views.py:2100 -#: agenda_culturel/views.py:2129 +#: agenda_culturel/views.py:2107 agenda_culturel/views.py:2124 +#: agenda_culturel/views.py:2153 msgid "" "The selected item is no longer included in the list of duplicates. Someone " "else has probably modified the list in the meantime." @@ -1606,23 +1634,23 @@ msgstr "" "L'élément sélectionné ne fait plus partie de la liste des dupliqués. Une " "autre personne a probablement modifié la liste entre temps." -#: agenda_culturel/views.py:2090 +#: agenda_culturel/views.py:2114 msgid "The selected event has been set as representative" msgstr "L'événement sélectionné a été défini comme representatif." -#: agenda_culturel/views.py:2115 +#: agenda_culturel/views.py:2139 msgid "The event has been withdrawn from the group and made independent." msgstr "L'événement a été retiré du groupe et rendu indépendant." -#: agenda_culturel/views.py:2165 +#: agenda_culturel/views.py:2189 msgid "Cleaning up duplicates: {} item(s) fixed." msgstr "Nettoyage des dupliqués: {} élément(s) corrigé(s)." -#: agenda_culturel/views.py:2214 +#: agenda_culturel/views.py:2238 msgid "The event was successfully duplicated." msgstr "L'événement a été marqué dupliqué avec succès." -#: agenda_culturel/views.py:2222 +#: agenda_culturel/views.py:2246 msgid "" "The event has been successfully flagged as a duplicate. The moderation team " "will deal with your suggestion shortly." @@ -1630,32 +1658,32 @@ msgstr "" "L'événement a été signalé comme dupliqué avec succès. Votre suggestion sera " "prochainement prise en charge par l'équipe de modération." -#: agenda_culturel/views.py:2284 +#: agenda_culturel/views.py:2308 msgid "The categorisation rule has been successfully modified." msgstr "La règle de catégorisation a été modifiée avec succès." -#: agenda_culturel/views.py:2296 +#: agenda_culturel/views.py:2320 msgid "The categorisation rule has been successfully deleted." msgstr "La règle de catégorisation a été supprimée avec succès" -#: agenda_culturel/views.py:2318 +#: agenda_culturel/views.py:2342 msgid "The rules were successfully applied and 1 event was categorised." msgstr "" "Les règles ont été appliquées avec succès et 1 événement a été catégorisé" -#: agenda_culturel/views.py:2325 +#: agenda_culturel/views.py:2349 msgid "The rules were successfully applied and {} events were categorised." msgstr "" "Les règles ont été appliquées avec succès et {} événements ont été " "catégorisés" -#: agenda_culturel/views.py:2332 agenda_culturel/views.py:2396 +#: agenda_culturel/views.py:2356 agenda_culturel/views.py:2420 msgid "The rules were successfully applied and no events were categorised." msgstr "" "Les règles ont été appliquées avec succès et aucun événement n'a été " "catégorisé" -#: agenda_culturel/views.py:2382 +#: agenda_culturel/views.py:2406 msgid "" "The rules were successfully applied and 1 event with default category was " "categorised." @@ -1663,7 +1691,7 @@ msgstr "" "Les règles ont été appliquées avec succès et 1 événement avec catégorie par " "défaut a été catégorisé" -#: agenda_culturel/views.py:2389 +#: agenda_culturel/views.py:2413 msgid "" "The rules were successfully applied and {} events with default category were " "categorised." @@ -1671,59 +1699,59 @@ msgstr "" "Les règles ont été appliquées avec succès et {} événements avec catégorie " "par défaut ont été catégorisés" -#: agenda_culturel/views.py:2495 agenda_culturel/views.py:2557 -#: agenda_culturel/views.py:2601 +#: agenda_culturel/views.py:2519 agenda_culturel/views.py:2581 +#: agenda_culturel/views.py:2625 msgid "{} events have been updated." msgstr "{} événements ont été mis à jour." -#: agenda_culturel/views.py:2498 agenda_culturel/views.py:2559 -#: agenda_culturel/views.py:2604 +#: agenda_culturel/views.py:2522 agenda_culturel/views.py:2583 +#: agenda_culturel/views.py:2628 msgid "1 event has been updated." msgstr "1 événement a été mis à jour" -#: agenda_culturel/views.py:2500 agenda_culturel/views.py:2561 -#: agenda_culturel/views.py:2606 +#: agenda_culturel/views.py:2524 agenda_culturel/views.py:2585 +#: agenda_culturel/views.py:2630 msgid "No events have been modified." msgstr "Aucun événement n'a été modifié." -#: agenda_culturel/views.py:2509 +#: agenda_culturel/views.py:2533 msgid "The place has been successfully updated." msgstr "Le lieu a été modifié avec succès." -#: agenda_culturel/views.py:2518 +#: agenda_culturel/views.py:2542 msgid "The place has been successfully created." msgstr "Le lieu a été créé avec succès." -#: agenda_culturel/views.py:2586 +#: agenda_culturel/views.py:2610 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:2593 +#: agenda_culturel/views.py:2617 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:2720 +#: agenda_culturel/views.py:2744 msgid "The organisation has been successfully updated." msgstr "L'organisme a été modifié avec succès." -#: agenda_culturel/views.py:2727 +#: agenda_culturel/views.py:2751 msgid "The organisation has been successfully created." msgstr "L'organisme a été créé avec succès." -#: agenda_culturel/views.py:2746 +#: agenda_culturel/views.py:2770 msgid "The tag has been successfully updated." msgstr "L'étiquette a été modifiée avec succès." -#: agenda_culturel/views.py:2753 +#: agenda_culturel/views.py:2777 msgid "The tag has been successfully created." msgstr "L'étiquette a été créée avec succès." -#: agenda_culturel/views.py:2853 +#: agenda_culturel/views.py:2877 msgid "You have not modified the tag name." msgstr "Vous n'avez pas modifié le nom de l'étiquette." -#: agenda_culturel/views.py:2868 +#: agenda_culturel/views.py:2892 msgid "" "This tag {} is already in use, and is described by different information " "from the current tag. You can force renaming by checking the corresponding " @@ -1736,7 +1764,7 @@ msgstr "" "sera supprimée, et tous les événements associés à l'étiquette {} seront " "associés à l'étiquette {}." -#: agenda_culturel/views.py:2882 +#: agenda_culturel/views.py:2906 msgid "" "This tag {} is already in use. You can force renaming by checking the " "corresponding option." @@ -1744,55 +1772,55 @@ msgstr "" "Cette étiquette {} est déjà utilisée. Vous pouvez forcer le renommage en " "cochant l'option correspondante." -#: agenda_culturel/views.py:2915 +#: agenda_culturel/views.py:2939 msgid "The tag {} has been successfully renamed to {}." msgstr "L'étiquette {} a été renommée avec succès en {}." -#: agenda_culturel/views.py:2957 +#: agenda_culturel/views.py:2981 msgid "The tag {} has been successfully deleted." msgstr "L'événement {} a été supprimé avec succès." -#: agenda_culturel/views.py:3104 +#: agenda_culturel/views.py:3128 msgid "Cache successfully cleared." msgstr "Le cache a été vidé avec succès." -#: agenda_culturel/views.py:3124 +#: agenda_culturel/views.py:3148 msgid "Your user profile has been successfully modified." msgstr "Votre profil utilisateur a été modifié avec succès." -#: agenda_culturel/views.py:3142 +#: agenda_culturel/views.py:3166 msgid "The special period has been successfully created." msgstr "La période remarquable a été créée avec succès." -#: agenda_culturel/views.py:3163 +#: agenda_culturel/views.py:3187 msgid "The special period has been successfully deleted." msgstr "La période remarquable a été supprimée avec succès." -#: agenda_culturel/views.py:3174 +#: agenda_culturel/views.py:3198 msgid "The special period has been successfully updated." msgstr "La période remarquable a été modifiée avec succès." -#: agenda_culturel/views.py:3191 +#: agenda_culturel/views.py:3215 #, python-format msgid "%(nb_created)d interval inserted." msgid_plural "%(nb_created)d intervals inserted." msgstr[0] "%(nb_created)d intervalle inséré." msgstr[1] "%(nb_created)d intervalles insérés." -#: agenda_culturel/views.py:3202 +#: agenda_culturel/views.py:3226 #, python-format msgid "%(nb_overlap)d insersion was not possible due to overlap." msgid_plural "%(nb_overlap)d insersion were not possible due to overlap." msgstr[0] "%(nb_overlap)d insersion impossible à cause d'une intersection." msgstr[1] "%(nb_overlap)d insersions impossibles à cause d'une intersection." -#: agenda_culturel/views.py:3213 +#: agenda_culturel/views.py:3237 #, python-format msgid "%(nb_error)d error while reading ical file." msgid_plural "%(nb_error)d error while reading ical file." msgstr[0] "%(nb_error)d erreur pendant la lecture du fichier ical." msgstr[1] "%(nb_error)d erreurs pendant la lecture du fichier ical." -#: agenda_culturel/views.py:3221 +#: agenda_culturel/views.py:3245 msgid "Error during file reading: {}" msgstr "Erreur pendant la lecture du fichier: {}" diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index dcf3223..8bfae36 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -2053,9 +2053,8 @@ class Event(models.Model): def get_updateable_uuid(self): if self.uuids and len(self.uuids) > 0: for s in self.uuids: - for e in Extractor.get_default_extractors(True): - if e.is_known_url(s): - return s + if Extractor.is_known_url_default_extractors(s): + return s return None def is_updateable(self): diff --git a/src/agenda_culturel/static/style.scss b/src/agenda_culturel/static/style.scss index 7a18397..612a0ee 100644 --- a/src/agenda_culturel/static/style.scss +++ b/src/agenda_culturel/static/style.scss @@ -1088,7 +1088,7 @@ form .buttons [role="button"] { } .large { - margin: 2em auto; + margin: 1em auto; } .min-y-grid { diff --git a/src/agenda_culturel/templates/agenda_culturel/event_form.html b/src/agenda_culturel/templates/agenda_culturel/event_form.html index d78cf55..091208d 100644 --- a/src/agenda_culturel/templates/agenda_culturel/event_form.html +++ b/src/agenda_culturel/templates/agenda_culturel/event_form.html @@ -146,9 +146,6 @@

Ajuster l'événement importé

{% else %}

Ajouter un événement

-

- Si l'événement est déjà décrit en ligne (par exemple sur Facebook), vous pouvez tenter un import automatique. -

{% endif %} {% endif %} diff --git a/src/agenda_culturel/templates/agenda_culturel/event_import.html b/src/agenda_culturel/templates/agenda_culturel/event_import.html index 718c89c..35e9156 100644 --- a/src/agenda_culturel/templates/agenda_culturel/event_import.html +++ b/src/agenda_culturel/templates/agenda_culturel/event_import.html @@ -1,4 +1,5 @@ {% extends "agenda_culturel/page.html" %} +{% load utils_extra %} {% block title %} {% block og_title %}Ajouter un événement{% endblock %} {% endblock %} @@ -13,25 +14,32 @@ {% block content %}
+ +

Ajouter un événement

{% url 'event_import' as local_url %} {% include "agenda_culturel/static_content.html" with name="import_proxy" url_path=local_url %}

- On peut importer automatiquement un événement depuis d'autres sites internet (principalement depuis Facebook pour - l'instant), à partir de l'adresse (url) de la page de l'événement. + Tu peux importer automatiquement un événement depuis d'autres sites internet, à partir de l'adresse (url) de la page de l'événement.

- Importer un événement depuis son url - Importer des événements depuis leurs urls -

- Si l'événement n'est pas disponible en ligne, ou si l'import ne fonctionne pas, on peut - ajouter un événement en utilisant un formulaire complet. -

- Remplir le formulaire d'événement - -
+
+ {% csrf_token %} + {{ form.as_p }} + +
+ + + {% endblock %} diff --git a/src/agenda_culturel/templates/agenda_culturel/import.html b/src/agenda_culturel/templates/agenda_culturel/import.html index 6567cff..caa16e2 100644 --- a/src/agenda_culturel/templates/agenda_culturel/import.html +++ b/src/agenda_culturel/templates/agenda_culturel/import.html @@ -3,6 +3,7 @@ {% block og_title %}Importer un événement{% endblock %} {% endblock %} {% load static %} +{% load utils_extra %} {% block fluid %}{% endblock %} {% block ajouter-bouton %} {% block ajouter-menu %}{% endblock %} @@ -10,11 +11,10 @@ {% block content %}
-

Importer un événement

+

Importer un événement

{% url 'event_import_url' as local_url %} {% include "agenda_culturel/static_content.html" with name="import" url_path=local_url %}
-
{% csrf_token %} {{ form.media }} @@ -22,11 +22,11 @@

- Si tu as plein d'événements à ajouter, tu peux les ajouter par lots. + Si tu doutes que l'import automatique fonctionne, tu peux + choisir de renseigner l'événement manuellement.

- Si l'import automatique ne marche pas, ou si l'événement n'est pas en ligne, tu peux - tout de même ajouter l'événement en le décrivant sur la page d'ajout d'événement. + Si tu as plein d'événements à ajouter, tu peux aussi les ajouter par lots.

diff --git a/src/agenda_culturel/views.py b/src/agenda_culturel/views.py index 67e3867..1388d00 100644 --- a/src/agenda_culturel/views.py +++ b/src/agenda_culturel/views.py @@ -87,6 +87,7 @@ from .forms import ( UserProfileForm, SpecialPeriodForm, SpecialPeriodFileForm, + URLSubmissionSimpleForm, ) from .import_tasks.extractor import Extractor from .models import ( @@ -107,6 +108,7 @@ from .models import ( SpecialPeriod, ) from .utils import PlaceGuesser +from urllib.parse import quote logger = logging.getLogger(__name__) @@ -861,7 +863,26 @@ def change_status_event(request, pk, status): def import_event_proxy(request): - return render(request, "agenda_culturel/event_import.html") + if request.method == "POST": + form = URLSubmissionSimpleForm(request.POST, request.FILES) + if form.is_valid(): + url = form.cleaned_data["url"] + if Extractor.is_known_url_default_extractors(url): + messages.info(request, _("This type of address is known to the calendar, so an automatic import is proposed.")) + return HttpResponseRedirect(reverse_lazy("add_event_url") + "?url=" + quote(url)) + else: + if request.user.is_authenticated: + messages.info(request, _("This type of address is unknown to the agenda. As a logged-in user, you can still try to import the event, which may work if the page contains a google calendar link, for example.")) + return HttpResponseRedirect(reverse_lazy("add_event_url") + "?url=" + quote(url)) + else: + messages.info(request, _("This type of address is unknown to the calendar, so we suggest that you enter the information for the event you wish to import, in addition to the link you've provided.")) + return HttpResponseRedirect(reverse_lazy("add_event_details") + "?url=" + quote(url)) + else: + form = URLSubmissionSimpleForm() + return render( + request, "agenda_culturel/event_import.html", {"form": form} + ) + class EventCreateView(SuccessMessageMixin, CreateView): @@ -873,6 +894,12 @@ class EventCreateView(SuccessMessageMixin, CreateView): kwargs["is_authenticated"] = self.request.user.is_authenticated return kwargs + def get_initial(self): + initial = super().get_initial() + initial['reference_urls'] = [self.request.GET.get('url', '')] + logger.warning("avec références") + return initial + def get_success_url(self): if self.request.user.is_authenticated: if "save_and_next" in self.request.POST: @@ -1073,15 +1100,6 @@ def import_from_urls(request): def import_from_url(request): - form = URLSubmissionFormWithContact(is_authenticated=request.user.is_authenticated) - - initial = { - "start_day": date.today() + timedelta(days=1), - "start_time": "20:00", - "end_time": "22:00", - } - - form_event = EventForm(initial=initial) # if the form has been sent if request.method == "POST": @@ -1128,11 +1146,17 @@ def import_from_url(request): comments=form.cleaned_data.get("comments"), ) return HttpResponseRedirect(reverse("thank_you")) + else: + url = request.GET.get('url', '') if request.method == "GET" else "" + initial = { + "url": url + } + form = URLSubmissionFormWithContact(is_authenticated=request.user.is_authenticated, initial=initial) return render( request, "agenda_culturel/import.html", - context={"form": form, "form_event": form_event}, + context={"form": form}, )