|
|
|
|
@ -9,6 +9,7 @@ from country.models import Country |
|
|
|
|
from city.models import City |
|
|
|
|
from theme.models import Theme |
|
|
|
|
from place_exposition.models import PlaceExposition |
|
|
|
|
from place_conference.models import PlaceConference |
|
|
|
|
#functions |
|
|
|
|
from functions.translate import populate_all, fill_trans_fields_all |
|
|
|
|
from functions.form_check import is_positive_integer |
|
|
|
|
@ -24,9 +25,12 @@ class OrganiserForm(forms.Form): |
|
|
|
|
|
|
|
|
|
save function saves data in Organiser object. If it doesnt exist create new object |
|
|
|
|
""" |
|
|
|
|
url = forms.CharField(label='url', required=False) |
|
|
|
|
|
|
|
|
|
country = forms.ModelChoiceField(label='Страна', queryset=Country.objects.all(), empty_label=None) |
|
|
|
|
theme = forms.ModelMultipleChoiceField(label='Тематики', queryset=Theme.objects.all()) |
|
|
|
|
place = forms.ModelMultipleChoiceField(label='Место проведения', queryset=PlaceExposition.objects.all(), required=False) |
|
|
|
|
place_exposition = forms.ModelMultipleChoiceField(label='Места проведения выставок', queryset=PlaceExposition.objects.all(), required=False) |
|
|
|
|
place_conference = forms.ModelMultipleChoiceField(label='Места проведения конференций', queryset=PlaceConference.objects.all(), required=False) |
|
|
|
|
#creates select input with empty choices cause it will be filled with ajax |
|
|
|
|
city = forms.ChoiceField(label='Город', choices=[('','')]) |
|
|
|
|
tag = forms.MultipleChoiceField(label='Теги', required=False) |
|
|
|
|
@ -49,7 +53,6 @@ class OrganiserForm(forms.Form): |
|
|
|
|
widget=forms.TextInput(attrs={'placeholder': 'Количество'})) |
|
|
|
|
foundation = forms.CharField(label='Год основания', required=False, |
|
|
|
|
widget=forms.TextInput(attrs={'placeholder': 'Год основания'})) |
|
|
|
|
own_place = forms.BooleanField(label='Собственные площадки', required=False) |
|
|
|
|
#field for comparing tmp files |
|
|
|
|
key = forms.CharField(required=False, widget=forms.HiddenInput()) |
|
|
|
|
|
|
|
|
|
@ -98,9 +101,11 @@ class OrganiserForm(forms.Form): |
|
|
|
|
organiser = Organiser.objects.get(id=id) |
|
|
|
|
organiser.theme.clear() |
|
|
|
|
organiser.tag.clear() |
|
|
|
|
organiser.place.clear() |
|
|
|
|
organiser.place_conference.clear() |
|
|
|
|
organiser.place_exposition.clear() |
|
|
|
|
|
|
|
|
|
#simple fields |
|
|
|
|
organiser.url = data['url'] |
|
|
|
|
organiser.address = data['address'] |
|
|
|
|
organiser.phone = data['phone'] |
|
|
|
|
organiser.fax = data['fax'] |
|
|
|
|
@ -108,7 +113,6 @@ class OrganiserForm(forms.Form): |
|
|
|
|
organiser.email = data['email'] |
|
|
|
|
organiser.foundation = data['foundation'] |
|
|
|
|
organiser.social = data['social'] |
|
|
|
|
organiser.own_place = data['own_place'] |
|
|
|
|
organiser.staff_number = data['staff_number'] |
|
|
|
|
organiser.events_number = data['events_number'] |
|
|
|
|
|
|
|
|
|
@ -129,9 +133,11 @@ class OrganiserForm(forms.Form): |
|
|
|
|
for item in data['tag']: |
|
|
|
|
organiser.tag.add(item) |
|
|
|
|
|
|
|
|
|
for item in data['place_exposition']: |
|
|
|
|
organiser.place_exposition.add(item.id)#.id cause select uses queryset |
|
|
|
|
|
|
|
|
|
for item in data['place']: |
|
|
|
|
organiser.place.add(item.id)#.id cause select uses queryset |
|
|
|
|
for item in data['place_conference']: |
|
|
|
|
organiser.place_conference.add(item.id)#.id cause select uses queryset |
|
|
|
|
|
|
|
|
|
# uses because in the next loop data will be overwritten |
|
|
|
|
organiser.save() |
|
|
|
|
@ -148,6 +154,11 @@ class OrganiserForm(forms.Form): |
|
|
|
|
#save files |
|
|
|
|
check_tmp_files(organiser, data['key']) |
|
|
|
|
|
|
|
|
|
def clean_url(self): |
|
|
|
|
cleaned_data = super(OrganiserForm, self).clean() |
|
|
|
|
url = cleaned_data.get('url').strip() |
|
|
|
|
return url |
|
|
|
|
|
|
|
|
|
def clean_foundation(self): |
|
|
|
|
""" |
|
|
|
|
checking foundation |
|
|
|
|
|