2.1.17 route form

This commit is contained in:
SDE
2025-01-14 19:56:36 +03:00
parent a0b08a9a94
commit 8ac11d6234
9 changed files with 58 additions and 38 deletions

View File

@@ -3,6 +3,8 @@ from django import forms
from django.contrib.auth.forms import AuthenticationForm
from django.utils.translation import gettext_lazy as _
from django.core.exceptions import ValidationError
from .funcs import get_cargo_types_by_type_transport
from .models import *
import copy
@@ -26,10 +28,18 @@ class RouteForm(forms.ModelForm):
'from_place', 'to_place', 'receive_msg_by_sms'
]
def __init__(self, *args, **kwargs):
def __init__(self, owner_type, *args, **kwargs):
super(RouteForm, self).__init__(*args, **kwargs)
self.fields['from_city'].required = True
self.fields['to_city'].required = True
self.fields['type_transport'].required = True
if owner_type == 'mover':
self.fields['departure_DT'].required = True
self.fields['type_transport'].choices = type_transport_choices[:-1]
else:
self.fields['type_transport'].choices = type_transport_choices
def clean(self):
# print('check')