diff --git a/src/agenda_culturel/forms.py b/src/agenda_culturel/forms.py index 314ad20..16569d1 100644 --- a/src/agenda_culturel/forms.py +++ b/src/agenda_culturel/forms.py @@ -759,3 +759,4 @@ class ContactMessageForm(ModelForm): def __init__(self, *args, **kwargs): self.event = kwargs.pop("event", False) super().__init__(*args, **kwargs) + self.fields['related_event'].required = False diff --git a/src/agenda_culturel/templates/agenda_culturel/contactmessage_create_form.html b/src/agenda_culturel/templates/agenda_culturel/contactmessage_create_form.html index e91208d..a8ab063 100644 --- a/src/agenda_culturel/templates/agenda_culturel/contactmessage_create_form.html +++ b/src/agenda_culturel/templates/agenda_culturel/contactmessage_create_form.html @@ -31,7 +31,7 @@ Contact{% endif %}{% endblock %}{% endblock %} {% endif %} -
+ {% if form.event %}Tu nous contactes au sujet de l'événement « {{ form.event.title }} » du {{ form.event.start_day }}. N'hésites pas à nous indiquer le maximum de contexte et à nous laisser ton adresse diff --git a/src/agenda_culturel/views.py b/src/agenda_culturel/views.py index fa162c5..46d417b 100644 --- a/src/agenda_culturel/views.py +++ b/src/agenda_culturel/views.py @@ -752,6 +752,8 @@ class ContactMessageCreateView(SuccessMessageMixin, CreateView): self.event = get_object_or_404(Event, pk=self.kwargs["pk"]) result["related_event"] = self.event result["subject"] = _('Reporting the event {} on {}').format(self.event.title, self.event.start_day) + else: + result["related_event"] = None return result