From c34abe91589fd7d3220d9ad95b3cd60cbc1b6851 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Fri, 6 Dec 2024 23:24:31 +0100 Subject: [PATCH] Restructuration des champs du formulaire de lieu --- src/agenda_culturel/forms.py | 21 +++++++++++- src/agenda_culturel/static/style.scss | 34 +++++++++++++++++++ .../templates/agenda_culturel/place_form.html | 18 +++++++++- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/src/agenda_culturel/forms.py b/src/agenda_culturel/forms.py index b37c35d..30e3e85 100644 --- a/src/agenda_culturel/forms.py +++ b/src/agenda_culturel/forms.py @@ -726,7 +726,7 @@ class EventAddPlaceForm(Form): return self.instance -class PlaceForm(ModelForm): +class PlaceForm(GroupFormMixin, ModelForm): required_css_class = 'required' apply_to_all = BooleanField( @@ -742,6 +742,25 @@ class PlaceForm(ModelForm): fields = "__all__" widgets = {"location": TextInput()} + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + self.add_group('header', _('Header')) + self.fields['name'].group_id = 'header' + + + self.add_group('address', _('Address')) + self.fields['address'].group_id = 'address' + self.fields['postcode'].group_id = 'address' + self.fields['city'].group_id = 'address' + self.fields['location'].group_id = 'address' + + self.add_group('meta', _('Meta')) + self.fields['aliases'].group_id = 'meta' + + self.add_group('information', _('Information')) + self.fields['description'].group_id = 'information' + def as_grid(self): result = ('
' + super().as_p() diff --git a/src/agenda_culturel/static/style.scss b/src/agenda_culturel/static/style.scss index 160ab9d..260b4ee 100644 --- a/src/agenda_culturel/static/style.scss +++ b/src/agenda_culturel/static/style.scss @@ -1518,3 +1518,37 @@ label.required::after { .maskable_group .body_group.closed { display: none; } + +.form-place { + display: grid; + grid-template-columns: repeat(1, 1fr); + row-gap: .5em; + margin-bottom: 0.5em; + .map-widget { + grid-row: 3; + } + #group_address .body_group { + display: grid; + grid-template-columns: repear(2, 1fr); + + column-gap: .5em; + #div_id_address, #div_id_location { + grid-column: 1 / 3; + } + + } +} +@media only screen and (min-width: 992px) { + .form-place { + grid-template-columns: repeat(2, 1fr); + + .map-widget { + grid-column: 2 / 3; + grid-row: 1 / 3; + } + + #group_other { + grid-column: 1 / 3; + } + } +} \ No newline at end of file diff --git a/src/agenda_culturel/templates/agenda_culturel/place_form.html b/src/agenda_culturel/templates/agenda_culturel/place_form.html index c06d41b..b034fd2 100644 --- a/src/agenda_culturel/templates/agenda_culturel/place_form.html +++ b/src/agenda_culturel/templates/agenda_culturel/place_form.html @@ -25,7 +25,23 @@

Remarque : les champs ont été pré-remplis à partir de la description sous forme libre et n'est probablement pas parfaite.

{% endif %}
{% csrf_token %} - {{ form.as_grid }} +
+ {{ form }} +
+
+

Cliquez pour ajuster la position GPS

+ Verrouiller la position + +
+