From af800ac84c4aa8fd61eec90513986c4e12836d53 Mon Sep 17 00:00:00 2001 From: SDE Date: Tue, 5 Dec 2023 17:43:01 +0300 Subject: [PATCH] 0.8.36 check dates when route create --- RoutesApp/forms.py | 3 +++ templates/blocks/profile/b_new_route.html | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/RoutesApp/forms.py b/RoutesApp/forms.py index 1b67574..9fd301f 100644 --- a/RoutesApp/forms.py +++ b/RoutesApp/forms.py @@ -23,6 +23,9 @@ class RouteForm(forms.ModelForm): try: + if 'departure_DT' in cleaned_data and 'arrival_DT' in cleaned_data and cleaned_data['arrival_DT'] < cleaned_data['departure_DT']: + self.add_error('arrival_DT', _('Указана неверная дата прибытия')) + if 'from_place' in self.data and self.data['from_place'] not in [item[0] for item in self.fields['from_place'].choices]: cleaned_data['from_place'] = self.fields['from_place'].choices[0][0] diff --git a/templates/blocks/profile/b_new_route.html b/templates/blocks/profile/b_new_route.html index d0795ed..4b2a114 100644 --- a/templates/blocks/profile/b_new_route.html +++ b/templates/blocks/profile/b_new_route.html @@ -83,7 +83,7 @@ id="id_departure_DT" name="departure_DT" placeholder="{% translate "Выберите дату и время" %}" {% if form.initial.departure_DT %} - value="{{ form.initial.departure_DT|date:"y.m.d H:m" }}"{% endif %}/> + value="{{ form.initial.departure_DT|date:"d.m.Y H:m" }}"{% endif %}/>
{% if not errors_off and form.errors and form.errors.departure_DT %} @@ -112,7 +112,7 @@ id="id_arrival_DT" name="arrival_DT" placeholder="{% translate "Выберите дату и время" %}" {% if form.initial.arrival_DT %} - value="{{ form.initial.arrival_DT|date:"y.m.d H:m" }}"{% endif %}/> + value="{{ form.initial.arrival_DT|date:"d.m.Y H:m" }}"{% endif %}/>
{# end #}