2.1.17 route form
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user