|
|
|
@ -217,7 +217,6 @@ class ExpositionCreateForm(forms.Form): |
|
|
|
exposition.country = Country.objects.get(id=data['country']) |
|
|
|
exposition.country = Country.objects.get(id=data['country']) |
|
|
|
exposition.city = City.objects.get(id=data['city']) |
|
|
|
exposition.city = City.objects.get(id=data['city']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if data.get('place'): |
|
|
|
if data.get('place'): |
|
|
|
exposition.place = PlaceExposition.objects.get(id=data['place']) |
|
|
|
exposition.place = PlaceExposition.objects.get(id=data['place']) |
|
|
|
else: |
|
|
|
else: |
|
|
|
@ -239,6 +238,28 @@ class ExpositionCreateForm(forms.Form): |
|
|
|
return exposition |
|
|
|
return exposition |
|
|
|
|
|
|
|
|
|
|
|
def clean(self): |
|
|
|
def clean(self): |
|
|
|
|
|
|
|
from functions.default_texts import default_expo_descr, booking_url |
|
|
|
|
|
|
|
d = self.cleaned_data |
|
|
|
|
|
|
|
booking_url=booking_url.format(city_id=d['city'],code='ru', |
|
|
|
|
|
|
|
date1=d['data_begin'].strftime("%-d"), date2=d['data_begin'].strftime("%Y"), |
|
|
|
|
|
|
|
date3=d['data_end'].strftime("%-m"),date4=d['data_end'].strftime("%-d"), |
|
|
|
|
|
|
|
date5=d['data_end'].strftime("%Y"), date6=d['data_end'].strftime("%-m")) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if d['place']: |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
place = PlaceExposition.objects.language().get(id=int(d['place'])).name |
|
|
|
|
|
|
|
except PlaceExposition.DoesNotExist: |
|
|
|
|
|
|
|
place = u"" |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
place = u"" |
|
|
|
|
|
|
|
descr = d.get('description_ru') or d.get('description_en') |
|
|
|
|
|
|
|
if not descr: |
|
|
|
|
|
|
|
descr = default_expo_descr.format(name=d['name_ru'], date_fr=d['data_begin'].strftime("%d.%m.%Y"), |
|
|
|
|
|
|
|
date_to=d['data_end'].strftime("%d.%m.%Y"), city=City.objects.language().get(id=d['city']), |
|
|
|
|
|
|
|
country=Country.objects.language().get(id=d['country']), |
|
|
|
|
|
|
|
place=place, |
|
|
|
|
|
|
|
booking_url=booking_url) |
|
|
|
|
|
|
|
self.cleaned_data['description_ru'] = descr |
|
|
|
id = self.cleaned_data.get('exposition_id') |
|
|
|
id = self.cleaned_data.get('exposition_id') |
|
|
|
name_ru = self.cleaned_data.get('name_ru') |
|
|
|
name_ru = self.cleaned_data.get('name_ru') |
|
|
|
|
|
|
|
|
|
|
|
@ -359,7 +380,6 @@ class ExpositionCreateForm(forms.Form): |
|
|
|
price_catalog = cleaned_data.get('price_catalog').strip() |
|
|
|
price_catalog = cleaned_data.get('price_catalog').strip() |
|
|
|
return is_positive_integer(price_catalog) |
|
|
|
return is_positive_integer(price_catalog) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def clean_visitors(self): |
|
|
|
def clean_visitors(self): |
|
|
|
""" |
|
|
|
""" |
|
|
|
checking visitors |
|
|
|
checking visitors |
|
|
|
@ -449,6 +469,12 @@ class ExpositionCreateForm(forms.Form): |
|
|
|
discount = cleaned_data.get('discount').strip() |
|
|
|
discount = cleaned_data.get('discount').strip() |
|
|
|
return is_positive_integer(discount) |
|
|
|
return is_positive_integer(discount) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ExpositionDeleteForm(forms.ModelForm): |
|
|
|
class ExpositionDeleteForm(forms.ModelForm): |
|
|
|
url = forms.CharField(widget=forms.HiddenInput()) |
|
|
|
url = forms.CharField(widget=forms.HiddenInput()) |
|
|
|
|
|
|
|
|
|
|
|
|