@ -6,6 +6,7 @@ from models import Catalog, Tickets, Remote, Participation, Translation, Visit,
from exposition . models import Exposition
from exposition . models import Exposition
from conference . models import Conference
from conference . models import Conference
from seminar . models import Seminar
from seminar . models import Seminar
from django . conf import settings
class AbstractOrderForm ( forms . ModelForm ) :
class AbstractOrderForm ( forms . ModelForm ) :
@ -74,7 +75,7 @@ class AbstractOrderForm(forms.ModelForm):
if not phone :
if not phone :
return
return
deduct = ( ' - ' , ' ( ' , ' ) ' , ' . ' , ' ' )
deduct = ( ' - ' , ' ( ' , ' ) ' , ' . ' , ' ' , ' + ' )
for elem in deduct :
for elem in deduct :
phone = phone . replace ( elem , ' ' )
phone = phone . replace ( elem , ' ' )
if phone . isdigit ( ) :
if phone . isdigit ( ) :
@ -132,42 +133,43 @@ from theme.models import Theme
class TranslationForm ( AbstractOrderForm ) :
class TranslationForm ( AbstractOrderForm ) :
languages = forms . CharField ( required = False )
languages = forms . CharField ( required = False )
themes = forms . CharField ( required = False )
themes = forms . CharField ( required = False )
fr = forms . DateField ( widget = forms . DateInput ( attrs = { ' class ' : ' date dateFrom ' , ' placeholder ' : _ ( u ' дд.мм.гггг ' ) } ) , required = False )
fr = forms . DateField ( input_formats = settings . CLIENT_DATE_FORMAT ,
to = forms . DateField ( widget = forms . DateInput ( attrs = { ' class ' : ' date dateTo ' , ' placeholder ' : _ ( u ' дд.мм.гггг ' ) } ) , required = False )
widget = forms . DateInput ( attrs = { ' class ' : ' date dateFrom ' , ' placeholder ' : _ ( u ' дд.мм.гггг ' ) } ) )
to = forms . DateField ( input_formats = settings . CLIENT_DATE_FORMAT ,
widget = forms . DateInput ( attrs = { ' class ' : ' date dateTo ' , ' placeholder ' : _ ( u ' дд.мм.гггг ' ) } ) )
class Meta :
class Meta :
model = Translation
model = Translation
HOTEL_ADDITIONAL_CHOICES = [ ( ' ' , _ ( u ' Выберите ' ) ) , ( _ ( u ' Условие1 ' ) , _ ( u ' Условие1 ' ) ) ,
HOTEL_ADDITIONAL_CHOICES = [ ( ' ' , _ ( u ' Выберите ' ) ) , ( _ ( u ' Одноместное ' ) , _ ( u ' Одноместное ' ) ) ,
( _ ( u ' Условие2 ' ) , _ ( u ' Условие2 ' ) ) , ( _ ( u ' Условие3 ' ) , _ ( u ' Условие3 ' ) ) ]
( _ ( u ' Двухместное ' ) , _ ( u ' Двухместное ' ) ) , ( _ ( u ' Трехместное ' ) , _ ( u ' Трехместное ' ) ) ]
AVIA_TYPE_CHOICES = [ ( _ ( u ' Прямой ' ) , _ ( u ' Прямой ' ) ) , ( _ ( u ' С пересадкой ' ) , _ ( u ' С пересадкой ' ) ) ,
AVIA_TYPE_CHOICES = [ ( _ ( u ' Прямой ' ) , _ ( u ' Прямой ' ) ) , ( _ ( u ' С пересадкой ' ) , _ ( u ' С пересадкой ' ) ) ,
( _ ( u ' Бизнес-класс ' ) , _ ( u ' Бизнес-класс ' ) ) , ( _ ( u ' Эконом-класс ' ) , _ ( u ' Эконом-класс ' ) ) ]
( _ ( u ' Бизнес-класс ' ) , _ ( u ' Бизнес-класс ' ) ) , ( _ ( u ' Эконом-класс ' ) , _ ( u ' Эконом-класс ' ) ) ]
HOTEL_LOCATION_CHOICES = [ ( ' ' , _ ( u ' Выберите ' ) ) , ( _ ( u ' Расположение1 ' ) , _ ( u ' Расположение1 ' ) ) ,
HOTEL_LOCATION_CHOICES = [ ( ' ' , _ ( u ' Выберите ' ) ) , ( _ ( u ' Любое ' ) , _ ( u ' Любое ' ) ) ,
( _ ( u ' Расположение2 ' ) , _ ( u ' Расположение2 ' ) ) ]
( _ ( u ' Рядом с выставкой ' ) , _ ( u ' Рядом с выставкой ' ) ) ,
( _ ( u ' В центре ' ) , _ ( u ' В центре ' ) ) ]
HOTEL_BUDGET_ADD = [ ( ' ' , _ ( u ' Выберите ' ) ) , ( _ ( u ' В сутки ' ) , _ ( u ' В сутки ' ) ) , ( _ ( u ' В неделю ' ) , _ ( u ' В неделю ' ) ) ]
HOTEL_BUDGET_ADD = [ ( _ ( u ' В сутки ' ) , _ ( u ' В сутки ' ) ) , ( _ ( u ' За весь период ' ) , _ ( u ' За весь период ' ) ) ]
class VisitForm ( AbstractOrderForm ) :
class VisitForm ( AbstractOrderForm ) :
fr = forms . DateField ( widget = forms . DateInput ( attrs = { ' class ' : ' date dateFrom ' , ' placeholder ' : _ ( u ' дд.мм.гггг ' ) } ) )
fr = forms . DateField ( input_formats = settings . CLIENT_DATE_FORMAT , required = False ,
to = forms . DateField ( widget = forms . DateInput ( attrs = { ' class ' : ' date dateTo ' , ' placeholder ' : _ ( u ' дд.мм.гггг ' ) } ) )
widget = forms . DateInput ( attrs = { ' class ' : ' date dateFrom ' , ' placeholder ' : _ ( u ' дд.мм.гггг ' ) } ) )
to = forms . DateField ( input_formats = settings . CLIENT_DATE_FORMAT , required = False ,
widget = forms . DateInput ( attrs = { ' class ' : ' date dateTo ' , ' placeholder ' : _ ( u ' дд.мм.гггг ' ) } ) )
hotel_additional = forms . ChoiceField ( choices = HOTEL_ADDITIONAL_CHOICES , required = False )
hotel_additional = forms . ChoiceField ( choices = HOTEL_ADDITIONAL_CHOICES , required = False )
hotel_stars = forms . MultipleChoiceField ( widget = forms . CheckboxSelectMultiple ( ) ,
hotel_stars = forms . MultipleChoiceField ( widget = forms . CheckboxSelectMultiple ( ) , required = False ,
choices = [ ( ' 1 ' , ' 1 ' ) , ( ' 2 ' , ' 2 ' ) , ( ' 3 ' , ' 3 ' ) , ( ' 4 ' , ' 4 ' ) , ( ' 5 ' , ' 5 ' ) ] )
choices = [ ( ' 1 ' , ' 1 ' ) , ( ' 2 ' , ' 2 ' ) , ( ' 3 ' , ' 3 ' ) , ( ' 4 ' , ' 4 ' ) , ( ' 5 ' , ' 5 ' ) ] )
hotel_location = forms . ChoiceField ( choices = HOTEL_LOCATION_CHOICES , required = False )
hotel_location = forms . ChoiceField ( choices = HOTEL_LOCATION_CHOICES , required = False )
hotel_budget_add = forms . ChoiceField ( choices = HOTEL_BUDGET_ADD , required = False )
hotel_budget_add = forms . ChoiceField ( choices = HOTEL_BUDGET_ADD , required = False )
languages = forms . MultipleChoiceField ( widget = forms . CheckboxSelectMultiple ( ) ,
languages = forms . CharField ( required = False , widget = forms . TextInput ( attrs = { ' placeholder ' : _ ( u ' Знание языков ' ) } ) )
choices = LANGS )
themes = forms . CharField ( required = False , widget = forms . TextInput ( attrs = { ' placeholder ' : _ ( u ' Тематика ' ) } ) )
themes = forms . MultipleChoiceField ( widget = forms . CheckboxSelectMultiple ( ) ,
choices = [ ( theme . name , theme . name ) for theme in Theme . objects . all ( ) ] )
avia_type = forms . MultipleChoiceField ( widget = forms . CheckboxSelectMultiple ( ) ,
avia_type = forms . MultipleChoiceField ( widget = forms . CheckboxSelectMultiple ( ) ,
choices = AVIA_TYPE_CHOICES )
choices = AVIA_TYPE_CHOICES , required = False )
class Meta :
class Meta :
model = Visit
model = Visit
@ -178,20 +180,6 @@ class VisitForm(AbstractOrderForm):
else :
else :
return ' , ' . join ( hotel_stars )
return ' , ' . join ( hotel_stars )
def clean_languages ( self ) :
languages = self . cleaned_data . get ( ' languages ' )
if not languages :
return ' '
else :
return ' , ' . join ( languages )
def clean_themes ( self ) :
themes = self . cleaned_data . get ( ' themes ' )
if not themes :
return ' '
else :
return ' , ' . join ( themes )
def clean_avia_type ( self ) :
def clean_avia_type ( self ) :
avia_type = self . cleaned_data . get ( ' avia_type ' )
avia_type = self . cleaned_data . get ( ' avia_type ' )
if not avia_type :
if not avia_type :