diff --git a/RoutesApp/forms.py b/RoutesApp/forms.py index 4ace543..1c79498 100644 --- a/RoutesApp/forms.py +++ b/RoutesApp/forms.py @@ -63,6 +63,11 @@ class RouteForm(forms.ModelForm): 'from_place', 'to_place', 'receive_msg_by_sms' ] + def __init__(self, *args, **kwargs): + super(RouteForm, self).__init__(*args, **kwargs) + self.fields['from_city'].required = True + self.fields['to_city'].required = True + def clean(self): # print('check') cleaned_data = super(RouteForm, self).clean() diff --git a/RoutesApp/templatetags/__init__.py b/RoutesApp/templatetags/__init__.py new file mode 100644 index 0000000..14c7ff2 --- /dev/null +++ b/RoutesApp/templatetags/__init__.py @@ -0,0 +1 @@ +__author__ = 'SDE' diff --git a/RoutesApp/templatetags/routes_tags.py b/RoutesApp/templatetags/routes_tags.py new file mode 100644 index 0000000..a3d94b0 --- /dev/null +++ b/RoutesApp/templatetags/routes_tags.py @@ -0,0 +1,21 @@ +__author__ = 'SDE' + +from django import template +from django.template.defaultfilters import stringfilter +from django.utils.safestring import mark_safe + +register = template.Library() + + +@register.filter +@stringfilter +def get_splited_cargo_type(value): + if not value or not '(' in value: + return value + + splited_list = value.split('(') + + s = splited_list[0] + '(' + splited_list[1] + ')' + + return mark_safe(s) +