L'import des événements ne se fait plus côté Celery, mais directement en django, ce qui permet :
- aux internautes d'éditer le résultat de l'import avant de le soumettre. Fix #45 - de vérifier que l'url n'existe pas déjà. Fix #31 -
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
from django.forms import ModelForm, ValidationError, TextInput
|
||||
from django.views.generic import FormView
|
||||
from django.forms import ModelForm, ValidationError, TextInput, Form, URLField
|
||||
from datetime import date
|
||||
|
||||
|
||||
from .models import EventSubmissionForm, Event
|
||||
from .models import Event
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
class EventSubmissionModelForm(ModelForm):
|
||||
class Meta:
|
||||
model = EventSubmissionForm
|
||||
fields = ["url"]
|
||||
class EventSubmissionForm(Form):
|
||||
url = URLField(max_length=512)
|
||||
|
||||
|
||||
class EventForm(ModelForm):
|
||||
@@ -25,9 +22,9 @@ class EventForm(ModelForm):
|
||||
}
|
||||
|
||||
|
||||
def __init__(self, instance, *args, **kwargs):
|
||||
def __init__(self, *args, **kwargs):
|
||||
is_authenticated = kwargs.pop('is_authenticated', False)
|
||||
super().__init__(instance=instance, *args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
if not is_authenticated:
|
||||
del self.fields['status']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user