* Ajout de l'import récurrent (manque la partie cron)

* Correction des textes en français. Fix #73
This commit is contained in:
Jean-Marie Favreau
2024-01-26 13:35:47 +01:00
parent 2bac3f29b5
commit 59c091a2f5
27 changed files with 1063 additions and 477 deletions

View File

@@ -2,7 +2,7 @@ from django.forms import ModelForm, ValidationError, TextInput, Form, URLField,
from datetime import date
from django_better_admin_arrayfield.forms.widgets import DynamicArrayWidget
from .models import Event, BatchImportation
from .models import Event, BatchImportation, RecurrentImport
from django.utils.translation import gettext_lazy as _
from string import ascii_uppercase as auc
from .templatetags.utils_extra import int_to_abc
@@ -25,6 +25,11 @@ class DynamicArrayWidgetURLs(DynamicArrayWidget):
class DynamicArrayWidgetTags(DynamicArrayWidget):
template_name = "agenda_culturel/widgets/widget-tags.html"
class RecurrentImportForm(ModelForm):
class Meta:
model = RecurrentImport
fields = '__all__'
class EventForm(ModelForm):
class Meta:
@@ -75,26 +80,8 @@ class EventForm(ModelForm):
class BatchImportationForm(ModelForm):
json = CharField(label="JSON (facultatif)", widget=Textarea(attrs={"rows":"10"}), help_text=_("JSON in the format expected for the import. If the JSON is provided here, we will ignore the URLs given above, and use the information provided by the json without importing any additional events from the URL."), required=False)
class Meta:
model = BatchImportation
fields = ['source', 'browsable_url']
def clean(self):
cleaned_data = super().clean()
json = cleaned_data.get("json")
source = cleaned_data.get("source")
browsable_url = cleaned_data.get("browsable_url")
if (not json or json == "") and (not source or source == "") and (not browsable_url or browsable_url == ""):
raise ValidationError(_("You need to fill in either the json or the source possibly supplemented by the navigable URL."))
# Always return a value to use as the new cleaned data, even if
# this method didn't change it.
return cleaned_data
class BatchImportationForm(Form):
json = CharField(label="JSON", widget=Textarea(attrs={"rows":"10"}), help_text=_("JSON in the format expected for the import."), required=True)
class FixDuplicates(Form):