Amélioration des formulaires (détails)
This commit is contained in:
parent
cd68d0039c
commit
e3648f703b
@ -112,6 +112,8 @@ class EventForm(ModelForm):
|
||||
if not is_authenticated:
|
||||
del self.fields["status"]
|
||||
self.fields['category'].queryset = self.fields['category'].queryset.order_by('name')
|
||||
self.fields['category'].empty_label = None
|
||||
self.fields['category'].initial = Category.get_default_category()
|
||||
|
||||
def clean_end_day(self):
|
||||
start_day = self.cleaned_data.get("start_day")
|
||||
|
@ -609,6 +609,11 @@ class EventCreateView(SuccessMessageMixin, CreateView):
|
||||
success_message = _("The event has been submitted and will be published as soon as it has been validated by the moderation team.")
|
||||
form_class = EventForm
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs["is_authenticated"] = self.request.user.is_authenticated
|
||||
return kwargs
|
||||
|
||||
|
||||
def import_from_details(request):
|
||||
form = EventForm(request.POST, is_authenticated=request.user.is_authenticated)
|
||||
|
Loading…
Reference in New Issue
Block a user