On revisite l'interface de soumission d'url

Fix #376
This commit is contained in:
Jean-Marie Favreau 2025-04-12 21:31:01 +02:00
parent 530dbfc8e4
commit 0db2f0759c
10 changed files with 241 additions and 172 deletions

View File

@ -199,6 +199,8 @@ class SimpleContactForm(GroupFormMixin, Form):
del self.fields["email"] del self.fields["email"]
del self.fields["comments"] del self.fields["comments"]
class URLSubmissionSimpleForm(Form):
url = URLField(max_length=512)
class URLSubmissionForm(GroupFormMixin, Form): class URLSubmissionForm(GroupFormMixin, Form):
required_css_class = "required" required_css_class = "required"

View File

@ -335,6 +335,12 @@ class Extractor(ABC):
EventNotFoundExtractor, 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 # A class that only produce a not found event
class EventNotFoundExtractor(Extractor): class EventNotFoundExtractor(Extractor):

View File

@ -227,6 +227,7 @@ class FacebookEvent:
class CExtractor(Extractor): class CExtractor(Extractor):
pattern = r'^https?://(?:www\.|m\.)?facebook\.com/events/(\d+)(?:/(\d+))?(?:/([a-zA-Z0-9\-]+))?/?$'
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.has_2nd_method = True self.has_2nd_method = True
@ -298,11 +299,15 @@ class CExtractor(Extractor):
return url return url
def is_known_url(url, include_links=True): 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: if include_links:
url_list.append("fb.me") u = urlparse(url)
return u.netloc in url_list return u.netloc == "fb.me"
else:
return False
def extract( def extract(
self, self,

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: agenda_culturel\n" "Project-Id-Version: agenda_culturel\n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: 2023-10-29 14:16+0000\n"
"Last-Translator: Jean-Marie Favreau <jeanmarie.favreau@free.fr>\n" "Last-Translator: Jean-Marie Favreau <jeanmarie.favreau@free.fr>\n"
"Language-Team: Jean-Marie Favreau <jeanmarie.favreau@free.fr>\n" "Language-Team: Jean-Marie Favreau <jeanmarie.favreau@free.fr>\n"
@ -214,32 +214,32 @@ msgstr ""
msgid "Receive notification of publication or leave a message for moderation" msgid "Receive notification of publication or leave a message for moderation"
msgstr "Être notifié de la publication ou laisser un message à la modération" 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:883 agenda_culturel/models.py:2924
#: agenda_culturel/models.py:3035 #: agenda_culturel/models.py:3035
msgid "Category" msgid "Category"
msgstr "Catégorie" msgstr "Catégorie"
#: agenda_culturel/forms.py:214 agenda_culturel/forms.py:247 #: agenda_culturel/forms.py:216 agenda_culturel/forms.py:249
#: agenda_culturel/forms.py:293 agenda_culturel/forms.py:477 #: agenda_culturel/forms.py:295 agenda_culturel/forms.py:479
#: agenda_culturel/models.py:369 agenda_culturel/models.py:1000 #: agenda_culturel/models.py:369 agenda_culturel/models.py:1000
msgid "Tags" msgid "Tags"
msgstr "Étiquettes" 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 #: agenda_culturel/models.py:1130
msgid "Event" msgid "Event"
msgstr "Événement" 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." msgid "The '/' character is not allowed."
msgstr "Le caractère '/' n'est pas autorisé." 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" msgid "New tags"
msgstr "Nouvelles étiquettes" msgstr "Nouvelles étiquettes"
#: agenda_culturel/forms.py:281 agenda_culturel/forms.py:485 #: agenda_culturel/forms.py:283 agenda_culturel/forms.py:487
msgid "" msgid ""
"Create new labels (sparingly). Note: by starting your tag with the " "Create new labels (sparingly). Note: by starting your tag with the "
"characters “TW:”, youll create a “trigger warning” tag, and the associated " "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 " "étiquette “trigger warning”, et les événements associés seront annoncés "
"comme tels." "comme tels."
#: agenda_culturel/forms.py:353 #: agenda_culturel/forms.py:355
msgid "Main fields" msgid "Main fields"
msgstr "Champs principaux" msgstr "Champs principaux"
#: agenda_culturel/forms.py:356 #: agenda_culturel/forms.py:358
msgid "Start of event" msgid "Start of event"
msgstr "Début de l'événement" msgstr "Début de l'événement"
#: agenda_culturel/forms.py:360 #: agenda_culturel/forms.py:362
msgid "End of event" msgid "End of event"
msgstr "Fin de l'événement" msgstr "Fin de l'événement"
#: agenda_culturel/forms.py:366 #: agenda_culturel/forms.py:368
msgid "This is a recurring event" msgid "This is a recurring event"
msgstr "Cet événement est récurrent" msgstr "Cet événement est récurrent"
#: agenda_culturel/forms.py:378 #: agenda_culturel/forms.py:380
msgid "Details" msgid "Details"
msgstr "Détails" 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 #: agenda_culturel/models.py:2899
msgid "Location" msgid "Location"
msgstr "Localisation" 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 #: agenda_culturel/models.py:956
msgid "Illustration" msgid "Illustration"
msgstr "Illustration" msgstr "Illustration"
#: agenda_culturel/forms.py:392 #: agenda_culturel/forms.py:394
msgid "URLs" msgid "URLs"
msgstr "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" msgid "Meta information"
msgstr "Méta-informations" msgstr "Méta-informations"
#: agenda_culturel/forms.py:420 #: agenda_culturel/forms.py:422
msgid "The end date must be after the start date." msgid "The end date must be after the start date."
msgstr "La date de fin doit être après la date de début." 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." 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." 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." msgid "Select tags from existing ones."
msgstr "Sélectionner des étiquettes depuis celles existantes." 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." msgid "JSON in the format expected for the import."
msgstr "JSON dans le format attendu pour l'import" msgstr "JSON dans le format attendu pour l'import"
#: agenda_culturel/forms.py:561 #: agenda_culturel/forms.py:563
msgid " (locally modified version)" msgid " (locally modified version)"
msgstr " (version modifiée localement)" msgstr " (version modifiée localement)"
#: agenda_culturel/forms.py:565 #: agenda_culturel/forms.py:567
msgid " (synchronized on import version)" msgid " (synchronized on import version)"
msgstr " (version synchronisée sur l'import)" msgstr " (version synchronisée sur l'import)"
#: agenda_culturel/forms.py:569 #: agenda_culturel/forms.py:571
msgid "Select {} as representative version." msgid "Select {} as representative version."
msgstr "Sélectionner {} comme version représentative" 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)." msgid "Update {} using some fields from other versions (interactive mode)."
msgstr "" msgstr ""
"Mettre à jour {} en utilisant quelques champs des autres versions (mode " "Mettre à jour {} en utilisant quelques champs des autres versions (mode "
"interactif)." "interactif)."
#: agenda_culturel/forms.py:586 #: agenda_culturel/forms.py:588
msgid " Warning: a version is already locally modified." msgid " Warning: a version is already locally modified."
msgstr " Attention: une version a déjà été modifiée localement." 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)." msgid "Create a new version by merging (interactive mode)."
msgstr "Créer une nouvelle version par fusion (mode interactif)." msgstr "Créer une nouvelle version par fusion (mode interactif)."
#: agenda_culturel/forms.py:601 #: agenda_culturel/forms.py:603
msgid "Make {} independent." msgid "Make {} independent."
msgstr "Rendre {} indépendant." msgstr "Rendre {} indépendant."
#: agenda_culturel/forms.py:604 #: agenda_culturel/forms.py:606
msgid "Make all versions independent." msgid "Make all versions independent."
msgstr "Rendre toutes les versions indépendantes." 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 {}" msgid "Value of version {}"
msgstr "Valeur de la version {}" msgstr "Valeur de la version {}"
#: agenda_culturel/forms.py:681 #: agenda_culturel/forms.py:683
msgid "Value of the selected version" msgid "Value of the selected version"
msgstr "Valeur de la version sélectionnée" msgstr "Valeur de la version sélectionnée"
#: agenda_culturel/forms.py:851 #: agenda_culturel/forms.py:853
msgid "Apply category {} to the event {}" msgid "Apply category {} to the event {}"
msgstr "Appliquer la catégorie {} à l'événement {}" 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 #: agenda_culturel/models.py:3087
msgid "Place" msgid "Place"
msgstr "Lieu" msgstr "Lieu"
#: agenda_culturel/forms.py:870 #: agenda_culturel/forms.py:872
msgid "Create a missing place" msgid "Create a missing place"
msgstr "Créer un lieu manquant" msgstr "Créer un lieu manquant"
#: agenda_culturel/forms.py:880 #: agenda_culturel/forms.py:882
msgid "Add \"{}\" to the aliases of the place" msgid "Add \"{}\" to the aliases of the place"
msgstr "Ajouter « {} » aux alias du lieu" 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" msgid "On saving, use aliases to detect all matching events with missing place"
msgstr "" msgstr ""
"Lors de l'enregistrement, utiliser des alias pour détecter tous les " "Lors de l'enregistrement, utiliser des alias pour détecter tous les "
"événements correspondants dont la place est manquante." "événements correspondants dont la place est manquante."
#: agenda_culturel/forms.py:922 #: agenda_culturel/forms.py:924
msgid "Header" msgid "Header"
msgstr "Entête" 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" msgid "Address"
msgstr "Adresse" msgstr "Adresse"
#: agenda_culturel/forms.py:931 #: agenda_culturel/forms.py:933
msgid "Meta" msgid "Meta"
msgstr "Méta" msgstr "Méta"
#: agenda_culturel/forms.py:934 #: agenda_culturel/forms.py:936
msgid "Information" msgid "Information"
msgstr "Informations" msgstr "Informations"
#: agenda_culturel/forms.py:986 #: agenda_culturel/forms.py:988
msgid "Add a comment" msgid "Add a comment"
msgstr "Ajouter un commentaire" 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" msgid "Period type"
msgstr "Type de période" msgstr "Type de période"
#: agenda_culturel/forms.py:1015 #: agenda_culturel/forms.py:1017
msgid "ICAL file" msgid "ICAL file"
msgstr "Fichier ICAL" msgstr "Fichier ICAL"
@ -899,11 +899,11 @@ msgstr "import récurrent"
msgid "a non authenticated user" msgid "a non authenticated user"
msgstr "un utilisateur non connecté" msgstr "un utilisateur non connecté"
#: agenda_culturel/models.py:1781 #: agenda_culturel/models.py:1786
msgid "Your event has been published" msgid "Your event has been published"
msgstr "Ton événement a été publié" msgstr "Ton événement a été publié"
#: agenda_culturel/models.py:1786 #: agenda_culturel/models.py:1791
msgid "Your message has not been retained" msgid "Your message has not been retained"
msgstr "Ton événement n'a pas été retenu" msgstr "Ton événement n'a pas été retenu"
@ -1404,43 +1404,43 @@ msgstr " au "
msgid "French" msgid "French"
msgstr "français" msgstr "français"
#: agenda_culturel/views.py:173 #: agenda_culturel/views.py:175
msgid "Recurrent import name" msgid "Recurrent import name"
msgstr "Nome de l'import récurrent" msgstr "Nome de l'import récurrent"
#: agenda_culturel/views.py:174 #: agenda_culturel/views.py:176
msgid "Add another" msgid "Add another"
msgstr "Ajouter un autre" msgstr "Ajouter un autre"
#: agenda_culturel/views.py:175 #: agenda_culturel/views.py:177
msgid "Browse..." msgid "Browse..."
msgstr "Naviguer..." msgstr "Naviguer..."
#: agenda_culturel/views.py:176 #: agenda_culturel/views.py:178
msgid "No file selected." msgid "No file selected."
msgstr "Pas de fichier sélectionné." msgstr "Pas de fichier sélectionné."
#: agenda_culturel/views.py:194 #: agenda_culturel/views.py:196
msgid ": error 500" msgid ": error 500"
msgstr ": erreur 500" msgstr ": erreur 500"
#: agenda_culturel/views.py:195 #: agenda_culturel/views.py:197
msgid "An internal error has occurred on site {} at address {}." msgid "An internal error has occurred on site {} at address {}."
msgstr "Une erreur interne s'est produite sur le site {} à l'adresse {}." 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" msgid "Moderation rules"
msgstr "Règles de modération" msgstr "Règles de modération"
#: agenda_culturel/views.py:243 #: agenda_culturel/views.py:245
msgid "Import requirements" msgid "Import requirements"
msgstr "Besoins pour l'import" msgstr "Besoins pour l'import"
#: agenda_culturel/views.py:449 #: agenda_culturel/views.py:451
msgid "The static content has been successfully updated." msgid "The static content has been successfully updated."
msgstr "Le contenu statique a été modifié avec succès." msgstr "Le contenu statique a été modifié avec succès."
#: agenda_culturel/views.py:460 #: agenda_culturel/views.py:462
msgid "" msgid ""
"The event cannot be updated because the import process is not available for " "The event cannot be updated because the import process is not available for "
"the referenced sources." "the referenced sources."
@ -1448,21 +1448,21 @@ msgstr ""
"La mise à jour de l'événement n'est pas possible car le processus d'import " "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." "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." msgid "The event update has been queued and will be completed shortly."
msgstr "" msgstr ""
"La mise à jour de l'événement a été mise en attente et sera effectuée sous " "La mise à jour de l'événement a été mise en attente et sera effectuée sous "
"peu." "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." 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." 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." msgid "The event has been successfully modified."
msgstr "L'événement a été modifié avec succès." msgstr "L'événement a été modifié avec succès."
#: agenda_culturel/views.py:530 #: agenda_culturel/views.py:532
msgid "" msgid ""
"Changes will be visible on a local copy of the event. The version identical " "Changes will be visible on a local copy of the event. The version identical "
"to the imported source will be hidden." "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 " "Les modifications seront visibles sur une copie locale de l'événement. La "
"version fidèle à la source importée sera masquée." "version fidèle à la source importée sera masquée."
#: agenda_culturel/views.py:591 #: agenda_culturel/views.py:593
msgid "The event <a href=\"{}\">{}</a> has been moderated with success." msgid "The event <a href=\"{}\">{}</a> has been moderated with success."
msgstr "L'événement <a href=\"{}\">{}</a> a été modéré avec succès." msgstr "L'événement <a href=\"{}\">{}</a> a été modéré avec succès."
#: agenda_culturel/views.py:740 #: agenda_culturel/views.py:742
msgid "The event has been successfully deleted." msgid "The event has been successfully deleted."
msgstr "L'événement a été supprimé avec succès." msgstr "L'événement a été supprimé avec succès."
#: agenda_culturel/views.py:820 #: agenda_culturel/views.py:822
msgid "Comment" msgid "Comment"
msgstr "Commentaire" msgstr "Commentaire"
#: agenda_culturel/views.py:844 #: agenda_culturel/views.py:846
msgid "" msgid ""
"The status has been successfully modified and a message has been sent to the " "The status has been successfully modified and a message has been sent to the "
"person who proposed the event." "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 " "Le status a été modifié avec succès et un message a été envoyé à la personne "
"qui a proposé l'événement." "qui a proposé l'événement."
#: agenda_culturel/views.py:848 #: agenda_culturel/views.py:850
msgid "The status has been successfully modified." msgid "The status has been successfully modified."
msgstr "Le status a été modifié avec succès." 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: <a href=\"{}\">{}</a>." msgid "The event was created: <a href=\"{}\">{}</a>."
msgstr "L'événement a été créé: <a href=\"{}\">{}</a>." msgstr "L'événement a été créé: <a href=\"{}\">{}</a>."
#: agenda_culturel/views.py:894 #: agenda_culturel/views.py:921
msgid "" msgid ""
"The event has been submitted and will be published as soon as it has been " "The event has been submitted and will be published as soon as it has been "
"validated by the moderation team." "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'événement a été soumis et sera publié dès qu'il aura été validé par "
"l'équipe de modération." "l'équipe de modération."
#: agenda_culturel/views.py:908 #: agenda_culturel/views.py:935
msgid "during the creation process" msgid "during the creation process"
msgstr "pendant le processus d'import" 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." msgid "A message has been sent to the person who proposed the initial event."
msgstr "" msgstr ""
"Un message a été envoyé à la personne qui a proposé l'événement initial." "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: {}." msgid "{} has not been submitted since its already known: {}."
msgstr "{} n'a pas été soumis car il est déjà connu: {}." 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 "" msgid ""
"{} has not been submitted since its already known and currently into " "{} has not been submitted since its already known and currently into "
"moderation process." "moderation process."
msgstr "{} n'a pas été soumis car il est déjà connu et en cours de modération" 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." msgid "Integrating {} url(s) into our import process."
msgstr "Intégration de {} url(s) dans notre processus d'import." 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." msgid "Integrating {} into our import process."
msgstr "Intégration de {} dans notre processus d'import." 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." msgid "Your message has been sent successfully."
msgstr "Votre message a été envoyé avec succès." msgstr "Votre message a été envoyé avec succès."
#: agenda_culturel/views.py:1269 #: agenda_culturel/views.py:1293
msgid "Reporting the event {} on {}" msgid "Reporting the event {} on {}"
msgstr "Signaler l'événement {} du {}" msgstr "Signaler l'événement {} du {}"
#: agenda_culturel/views.py:1279 #: agenda_culturel/views.py:1303
msgid "The contact message has been successfully deleted." msgid "The contact message has been successfully deleted."
msgstr "Le message de contact a été supprimé avec succès." 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." msgid "The contact message properties has been successfully modified."
msgstr "Les propriétés du message de contact ont été modifié avec succès." 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." msgid "Spam has been successfully deleted."
msgstr "Le spam a été supprimé avec succès" 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." msgid "The import has been run successfully."
msgstr "L'import a été lancé avec succès" 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." msgid "The import has been canceled."
msgstr "L'import a été annulé" msgstr "L'import a été annulé"
#: agenda_culturel/views.py:1695 #: agenda_culturel/views.py:1719
msgid "The orphan event update has been launched." msgid "The orphan event update has been launched."
msgstr "La mise à jour de l'événement orphelin a été lancée." 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." msgid "The recurrent import has been successfully modified."
msgstr "L'import récurrent a été modifié avec succès." 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." msgid "The recurrent import has been successfully deleted."
msgstr "L'import récurrent a été supprimé avec succès" 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." msgid "The import has been launched."
msgstr "L'import a été lancé" msgstr "L'import a été lancé"
#: agenda_culturel/views.py:1876 #: agenda_culturel/views.py:1900
msgid "Imports has been launched." msgid "Imports has been launched."
msgstr "Les imports ont été lancés" msgstr "Les imports ont été lancés"
#: agenda_culturel/views.py:1898 #: agenda_culturel/views.py:1922
msgid "Facebook imports has been launched." msgid "Facebook imports has been launched."
msgstr "Les imports Facebook ont été lancés" msgstr "Les imports Facebook ont été lancés"
#: agenda_culturel/views.py:1961 #: agenda_culturel/views.py:1985
msgid "Update successfully completed." msgid "Update successfully completed."
msgstr "Mise à jour réalisée avec succès." 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." msgid "Creation of a merged event has been successfully completed."
msgstr "Création d'un événement fusionné réalisée avec succès." 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." msgid "Events have been marked as unduplicated."
msgstr "Les événements ont été marqués comme non dupliqués." 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:2107 agenda_culturel/views.py:2124
#: agenda_culturel/views.py:2129 #: agenda_culturel/views.py:2153
msgid "" msgid ""
"The selected item is no longer included in the list of duplicates. Someone " "The selected item is no longer included in the list of duplicates. Someone "
"else has probably modified the list in the meantime." "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 " "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." "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" msgid "The selected event has been set as representative"
msgstr "L'événement sélectionné a été défini comme representatif." 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." 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." 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." msgid "Cleaning up duplicates: {} item(s) fixed."
msgstr "Nettoyage des dupliqués: {} élément(s) corrigé(s)." 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." msgid "The event was successfully duplicated."
msgstr "L'événement a été marqué dupliqué avec succès." msgstr "L'événement a été marqué dupliqué avec succès."
#: agenda_culturel/views.py:2222 #: agenda_culturel/views.py:2246
msgid "" msgid ""
"The event has been successfully flagged as a duplicate. The moderation team " "The event has been successfully flagged as a duplicate. The moderation team "
"will deal with your suggestion shortly." "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 " "L'événement a été signalé comme dupliqué avec succès. Votre suggestion sera "
"prochainement prise en charge par l'équipe de modération." "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." msgid "The categorisation rule has been successfully modified."
msgstr "La règle de catégorisation a été modifiée avec succès." 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." msgid "The categorisation rule has been successfully deleted."
msgstr "La règle de catégorisation a été supprimée avec succès" 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." msgid "The rules were successfully applied and 1 event was categorised."
msgstr "" msgstr ""
"Les règles ont été appliquées avec succès et 1 événement a été catégorisé" "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." msgid "The rules were successfully applied and {} events were categorised."
msgstr "" msgstr ""
"Les règles ont été appliquées avec succès et {} événements ont été " "Les règles ont été appliquées avec succès et {} événements ont été "
"catégorisés" "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." msgid "The rules were successfully applied and no events were categorised."
msgstr "" msgstr ""
"Les règles ont été appliquées avec succès et aucun événement n'a été " "Les règles ont été appliquées avec succès et aucun événement n'a été "
"catégorisé" "catégorisé"
#: agenda_culturel/views.py:2382 #: agenda_culturel/views.py:2406
msgid "" msgid ""
"The rules were successfully applied and 1 event with default category was " "The rules were successfully applied and 1 event with default category was "
"categorised." "categorised."
@ -1663,7 +1691,7 @@ msgstr ""
"Les règles ont été appliquées avec succès et 1 événement avec catégorie par " "Les règles ont été appliquées avec succès et 1 événement avec catégorie par "
"défaut a été catégorisé" "défaut a été catégorisé"
#: agenda_culturel/views.py:2389 #: agenda_culturel/views.py:2413
msgid "" msgid ""
"The rules were successfully applied and {} events with default category were " "The rules were successfully applied and {} events with default category were "
"categorised." "categorised."
@ -1671,59 +1699,59 @@ msgstr ""
"Les règles ont été appliquées avec succès et {} événements avec catégorie " "Les règles ont été appliquées avec succès et {} événements avec catégorie "
"par défaut ont été catégorisés" "par défaut ont été catégorisés"
#: agenda_culturel/views.py:2495 agenda_culturel/views.py:2557 #: agenda_culturel/views.py:2519 agenda_culturel/views.py:2581
#: agenda_culturel/views.py:2601 #: agenda_culturel/views.py:2625
msgid "{} events have been updated." msgid "{} events have been updated."
msgstr "{} événements ont été mis à jour." msgstr "{} événements ont été mis à jour."
#: agenda_culturel/views.py:2498 agenda_culturel/views.py:2559 #: agenda_culturel/views.py:2522 agenda_culturel/views.py:2583
#: agenda_culturel/views.py:2604 #: agenda_culturel/views.py:2628
msgid "1 event has been updated." msgid "1 event has been updated."
msgstr "1 événement a été mis à jour" msgstr "1 événement a été mis à jour"
#: agenda_culturel/views.py:2500 agenda_culturel/views.py:2561 #: agenda_culturel/views.py:2524 agenda_culturel/views.py:2585
#: agenda_culturel/views.py:2606 #: agenda_culturel/views.py:2630
msgid "No events have been modified." msgid "No events have been modified."
msgstr "Aucun événement n'a été modifié." 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." msgid "The place has been successfully updated."
msgstr "Le lieu a été modifié avec succès." 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." msgid "The place has been successfully created."
msgstr "Le lieu a été créé avec succès." msgstr "Le lieu a été créé avec succès."
#: agenda_culturel/views.py:2586 #: agenda_culturel/views.py:2610
msgid "" msgid ""
"The selected place has been assigned to the event <a href=\"{}\">{}</a>." "The selected place has been assigned to the event <a href=\"{}\">{}</a>."
msgstr "Le lieu sélectionné a été assigné à l'événement <a href=\"{}\">{}</a>." msgstr "Le lieu sélectionné a été assigné à l'événement <a href=\"{}\">{}</a>."
#: agenda_culturel/views.py:2593 #: agenda_culturel/views.py:2617
msgid "A new alias has been added to the selected place." msgid "A new alias has been added to the selected place."
msgstr "Un nouvel alias a été créé pour le lieu sélectionné." 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." msgid "The organisation has been successfully updated."
msgstr "L'organisme a été modifié avec succès." 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." msgid "The organisation has been successfully created."
msgstr "L'organisme a été créé avec succès." 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." msgid "The tag has been successfully updated."
msgstr "L'étiquette a été modifiée avec succès." 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." msgid "The tag has been successfully created."
msgstr "L'étiquette a été créée avec succès." 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." msgid "You have not modified the tag name."
msgstr "Vous n'avez pas modifié le nom de l'étiquette." msgstr "Vous n'avez pas modifié le nom de l'étiquette."
#: agenda_culturel/views.py:2868 #: agenda_culturel/views.py:2892
msgid "" msgid ""
"This tag {} is already in use, and is described by different information " "This tag {} is already in use, and is described by different information "
"from the current tag. You can force renaming by checking the corresponding " "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 " "sera supprimée, et tous les événements associés à l'étiquette {} seront "
"associés à l'étiquette {}." "associés à l'étiquette {}."
#: agenda_culturel/views.py:2882 #: agenda_culturel/views.py:2906
msgid "" msgid ""
"This tag {} is already in use. You can force renaming by checking the " "This tag {} is already in use. You can force renaming by checking the "
"corresponding option." "corresponding option."
@ -1744,55 +1772,55 @@ msgstr ""
"Cette étiquette {} est déjà utilisée. Vous pouvez forcer le renommage en " "Cette étiquette {} est déjà utilisée. Vous pouvez forcer le renommage en "
"cochant l'option correspondante." "cochant l'option correspondante."
#: agenda_culturel/views.py:2915 #: agenda_culturel/views.py:2939
msgid "The tag {} has been successfully renamed to {}." msgid "The tag {} has been successfully renamed to {}."
msgstr "L'étiquette {} a été renommée avec succès en {}." 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." msgid "The tag {} has been successfully deleted."
msgstr "L'événement {} a été supprimé avec succès." msgstr "L'événement {} a été supprimé avec succès."
#: agenda_culturel/views.py:3104 #: agenda_culturel/views.py:3128
msgid "Cache successfully cleared." msgid "Cache successfully cleared."
msgstr "Le cache a été vidé avec succès." 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." msgid "Your user profile has been successfully modified."
msgstr "Votre profil utilisateur a été modifié avec succès." 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." msgid "The special period has been successfully created."
msgstr "La période remarquable a été créée avec succès." 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." msgid "The special period has been successfully deleted."
msgstr "La période remarquable a été supprimée avec succès." 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." msgid "The special period has been successfully updated."
msgstr "La période remarquable a été modifiée avec succès." msgstr "La période remarquable a été modifiée avec succès."
#: agenda_culturel/views.py:3191 #: agenda_culturel/views.py:3215
#, python-format #, python-format
msgid "%(nb_created)d interval inserted." msgid "%(nb_created)d interval inserted."
msgid_plural "%(nb_created)d intervals inserted." msgid_plural "%(nb_created)d intervals inserted."
msgstr[0] "%(nb_created)d intervalle inséré." msgstr[0] "%(nb_created)d intervalle inséré."
msgstr[1] "%(nb_created)d intervalles insérés." msgstr[1] "%(nb_created)d intervalles insérés."
#: agenda_culturel/views.py:3202 #: agenda_culturel/views.py:3226
#, python-format #, python-format
msgid "%(nb_overlap)d insersion was not possible due to overlap." msgid "%(nb_overlap)d insersion was not possible due to overlap."
msgid_plural "%(nb_overlap)d insersion were 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[0] "%(nb_overlap)d insersion impossible à cause d'une intersection."
msgstr[1] "%(nb_overlap)d insersions impossibles à 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 #, python-format
msgid "%(nb_error)d error while reading ical file." msgid "%(nb_error)d error while reading ical file."
msgid_plural "%(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[0] "%(nb_error)d erreur pendant la lecture du fichier ical."
msgstr[1] "%(nb_error)d erreurs 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: {}" msgid "Error during file reading: {}"
msgstr "Erreur pendant la lecture du fichier: {}" msgstr "Erreur pendant la lecture du fichier: {}"

View File

@ -2053,9 +2053,8 @@ class Event(models.Model):
def get_updateable_uuid(self): def get_updateable_uuid(self):
if self.uuids and len(self.uuids) > 0: if self.uuids and len(self.uuids) > 0:
for s in self.uuids: for s in self.uuids:
for e in Extractor.get_default_extractors(True): if Extractor.is_known_url_default_extractors(s):
if e.is_known_url(s): return s
return s
return None return None
def is_updateable(self): def is_updateable(self):

View File

@ -1088,7 +1088,7 @@ form .buttons [role="button"] {
} }
.large { .large {
margin: 2em auto; margin: 1em auto;
} }
.min-y-grid { .min-y-grid {

View File

@ -146,9 +146,6 @@
<h1>Ajuster l'événement importé</h1> <h1>Ajuster l'événement importé</h1>
{% else %} {% else %}
<h1>Ajouter un événement</h1> <h1>Ajouter un événement</h1>
<p>
Si l'événement est déjà décrit en ligne (par exemple sur Facebook), vous pouvez tenter un <a href="{% url 'add_event_url' %}">import automatique</a>.
</p>
{% endif %} {% endif %}
{% endif %} {% endif %}
</header> </header>

View File

@ -1,4 +1,5 @@
{% extends "agenda_culturel/page.html" %} {% extends "agenda_culturel/page.html" %}
{% load utils_extra %}
{% block title %} {% block title %}
{% block og_title %}Ajouter un événement{% endblock %} {% block og_title %}Ajouter un événement{% endblock %}
{% endblock %} {% endblock %}
@ -13,25 +14,32 @@
{% block content %} {% block content %}
<article> <article>
<header> <header>
<div class="buttons slide-buttons">
<a href="{% url 'add_event_details' %}" role="button">Règles de modération {% picto_from_name "book-open" %}</a>
</div>
<h1>Ajouter un événement</h1> <h1>Ajouter un événement</h1>
{% url 'event_import' as local_url %} {% url 'event_import' as local_url %}
{% include "agenda_culturel/static_content.html" with name="import_proxy" url_path=local_url %} {% include "agenda_culturel/static_content.html" with name="import_proxy" url_path=local_url %}
</header> </header>
<p> <p>
On peut importer automatiquement un événement depuis d'autres sites internet (principalement depuis Facebook pour Tu peux importer automatiquement un événement depuis d'autres sites internet, à partir de l'adresse (url) de la page de l'événement.
l'instant), à partir de l'adresse (url) de la page de l'événement.
</p> </p>
<a href="{% url 'add_event_url' %}" role="button" class="large">Importer un événement depuis son url</a> <form method="post">
<a href="{% url 'add_event_urls' %}" role="button" class="large">Importer des événements depuis leurs urls</a> {% csrf_token %}
<p> {{ form.as_p }}
Si l'événement n'est pas disponible en ligne, ou si l'import ne fonctionne pas, on peut <input type="submit" value="Importer un événement depuis son url">
ajouter un événement en utilisant un formulaire complet. </form>
</p>
<a href="{% url 'add_event_details' %}" role="button" class="large">Remplir le formulaire d'événement</a> <footer>
<footer> <p>
<p> Si l'événement n'est pas disponible en ligne, tu peux ajouter un événement en utilisant un formulaire complet&nbsp;:
Voir les <a href="{% url 'moderation_rules' %}">règles de modération détaillées</a> en usage sur l'agenda. </p>
</p> <a href="{% url 'add_event_details' %}" role="button" class="large">Remplir le formulaire d'événement</a>
</footer>
</article> {% if user.is_authenticated %}
<p><strong>Post Scriptum&nbsp;:</strong> tu peux aussi <a href="{% url 'add_event_urls' %}">importer des événements en batches de plein d'urls</a>.</p>
{% endif %}
</footer>
</article>
{% endblock %} {% endblock %}

View File

@ -3,6 +3,7 @@
{% block og_title %}Importer un événement{% endblock %} {% block og_title %}Importer un événement{% endblock %}
{% endblock %} {% endblock %}
{% load static %} {% load static %}
{% load utils_extra %}
{% block fluid %}{% endblock %} {% block fluid %}{% endblock %}
{% block ajouter-bouton %} {% block ajouter-bouton %}
{% block ajouter-menu %}{% endblock %} {% block ajouter-menu %}{% endblock %}
@ -10,11 +11,10 @@
{% block content %} {% block content %}
<article> <article>
<header> <header>
<h1>Importer un événement</h1> <h1>Importer un événement</h1>
{% url 'event_import_url' as local_url %} {% url 'event_import_url' as local_url %}
{% include "agenda_culturel/static_content.html" with name="import" url_path=local_url %} {% include "agenda_culturel/static_content.html" with name="import" url_path=local_url %}
</header> </header>
<div id="container"></div>
<form method="post" action=""> <form method="post" action="">
{% csrf_token %} {% csrf_token %}
{{ form.media }} {{ form.media }}
@ -22,11 +22,11 @@
<input type="submit" value="Lancer l'import" id="import-button"> <input type="submit" value="Lancer l'import" id="import-button">
</form> </form>
<p> <p>
Si tu as plein d'événements à ajouter, tu peux les <a href="{% url 'add_event_urls' %}">ajouter par lots</a>. Si tu doutes que l'import automatique fonctionne, tu peux
choisir de <a href="{% url 'add_event_details' %}?url={{ form.url.value }}">renseigner l'événement manuellement</a>.
</p> </p>
<p> <p>
Si l'import automatique ne marche pas, ou si l'événement n'est pas en ligne, tu peux Si tu as plein d'événements à ajouter, tu peux aussi les <a href="{% url 'add_event_urls' %}">ajouter par lots</a>.
tout de même ajouter l'événement en le décrivant sur la page <a href="{% url 'add_event_details' %}">d'ajout d'événement</a>.
</p> </p>
</article> </article>
<script src="{% static 'choicejs/choices.min.js' %}"></script> <script src="{% static 'choicejs/choices.min.js' %}"></script>

View File

@ -87,6 +87,7 @@ from .forms import (
UserProfileForm, UserProfileForm,
SpecialPeriodForm, SpecialPeriodForm,
SpecialPeriodFileForm, SpecialPeriodFileForm,
URLSubmissionSimpleForm,
) )
from .import_tasks.extractor import Extractor from .import_tasks.extractor import Extractor
from .models import ( from .models import (
@ -107,6 +108,7 @@ from .models import (
SpecialPeriod, SpecialPeriod,
) )
from .utils import PlaceGuesser from .utils import PlaceGuesser
from urllib.parse import quote
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -861,7 +863,26 @@ def change_status_event(request, pk, status):
def import_event_proxy(request): 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): class EventCreateView(SuccessMessageMixin, CreateView):
@ -873,6 +894,12 @@ class EventCreateView(SuccessMessageMixin, CreateView):
kwargs["is_authenticated"] = self.request.user.is_authenticated kwargs["is_authenticated"] = self.request.user.is_authenticated
return kwargs 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): def get_success_url(self):
if self.request.user.is_authenticated: if self.request.user.is_authenticated:
if "save_and_next" in self.request.POST: if "save_and_next" in self.request.POST:
@ -1073,15 +1100,6 @@ def import_from_urls(request):
def import_from_url(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 the form has been sent
if request.method == "POST": if request.method == "POST":
@ -1128,11 +1146,17 @@ def import_from_url(request):
comments=form.cleaned_data.get("comments"), comments=form.cleaned_data.get("comments"),
) )
return HttpResponseRedirect(reverse("thank_you")) 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( return render(
request, request,
"agenda_culturel/import.html", "agenda_culturel/import.html",
context={"form": form, "form_event": form_event}, context={"form": form},
) )