2.1.9 get_splited_cargo_type
This commit is contained in:
@@ -63,6 +63,11 @@ class RouteForm(forms.ModelForm):
|
|||||||
'from_place', 'to_place', 'receive_msg_by_sms'
|
'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):
|
def clean(self):
|
||||||
# print('check')
|
# print('check')
|
||||||
cleaned_data = super(RouteForm, self).clean()
|
cleaned_data = super(RouteForm, self).clean()
|
||||||
|
|||||||
1
RoutesApp/templatetags/__init__.py
Normal file
1
RoutesApp/templatetags/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
__author__ = 'SDE'
|
||||||
21
RoutesApp/templatetags/routes_tags.py
Normal file
21
RoutesApp/templatetags/routes_tags.py
Normal file
@@ -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] + '<span>(' + splited_list[1] + ')</span>'
|
||||||
|
|
||||||
|
return mark_safe(s)
|
||||||
|
|
||||||
Reference in New Issue
Block a user