parent
466f883d34
commit
a60c4ba173
61 changed files with 340 additions and 1944 deletions
@ -1,8 +1,9 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django.conf.urls import patterns, url |
||||
|
||||
urlpatterns = patterns('', |
||||
url(r'^add/$', 'article.views.article_add'), |
||||
url(r'^change/(.*)/$', 'article.views.article_change'), |
||||
url(r'^all/$', 'article.views.article_all'), |
||||
urlpatterns = patterns('article.views', |
||||
url(r'^add/$', 'article_add'), |
||||
url(r'^delete/(?P<url>.*)/$', 'article_delete'), |
||||
url(r'^change/(.*)/$', 'article_change'), |
||||
url(r'^all/$', 'article_all'), |
||||
) |
||||
@ -1,8 +1,9 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django.conf.urls import patterns, include, url |
||||
|
||||
urlpatterns = patterns('', |
||||
url(r'^add.*/$', 'company.views.company_add'), |
||||
url(r'^change/(?P<company_id>\d+).*/$', 'company.views.company_change'), |
||||
url(r'^all/$', 'company.views.company_all'), |
||||
urlpatterns = patterns('company.views', |
||||
url(r'^add.*/$', 'company_add'), |
||||
url(r'^delete/(?P<company_id>\d+)/$', 'company_delete'), |
||||
url(r'^change/(?P<company_id>\d+).*/$', 'company_change'), |
||||
url(r'^all/$', 'company_all'), |
||||
) |
||||
@ -1,8 +1,9 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django.conf.urls import patterns, include, url |
||||
|
||||
urlpatterns = patterns('', |
||||
url(r'^add.*/$', 'conference.views.conference_add'), |
||||
url(r'^change/(.*)/$', 'conference.views.conference_change'), |
||||
url(r'^all/$', 'conference.views.conference_all'), |
||||
urlpatterns = patterns('conference.views', |
||||
url(r'^add.*/$', 'conference_add'), |
||||
url(r'^delete/(?P<url>.*)$', 'conference_delete'), |
||||
url(r'^change/(?P<url>.*)/$', 'conference_change'), |
||||
url(r'^all/$', 'conference_all'), |
||||
) |
||||
@ -1,8 +1,9 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django.conf.urls import patterns, include, url |
||||
|
||||
urlpatterns = patterns('', |
||||
url(r'^add.*/$', 'exposition.views.exposition_add'), |
||||
url(r'^change/(.*)/$', 'exposition.views.exposition_change'), |
||||
url(r'^all/$', 'exposition.views.exposition_all'), |
||||
urlpatterns = patterns('exposition.views', |
||||
url(r'^add.*/$', 'exposition_add'), |
||||
url(r'^delete/(?P<url>.*)/$', 'exposition_delete'), |
||||
url(r'^change/(?P<url>.*)/$', 'exposition_change'), |
||||
url(r'^all/$', 'exposition_all'), |
||||
) |
||||
|
||||
@ -1,13 +0,0 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django.contrib import admin |
||||
from hvad.admin import TranslatableAdmin |
||||
from models import PlaceConference, PlaceExposition |
||||
|
||||
class PlaceConferenceAdmin(TranslatableAdmin): |
||||
pass |
||||
|
||||
class PlaceExpositionAdmin(TranslatableAdmin): |
||||
pass |
||||
|
||||
admin.site.register(PlaceConference, PlaceConferenceAdmin) |
||||
admin.site.register(PlaceExposition, PlaceExpositionAdmin) |
||||
@ -1,541 +0,0 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django import forms |
||||
from django.conf import settings |
||||
from ckeditor.widgets import CKEditorWidget |
||||
from django.core.exceptions import ValidationError |
||||
from django.core.validators import validate_email, URLValidator |
||||
#models |
||||
from models import PlaceConference, PlaceExposition, Hall, EXPOSITION_TYPE, CONFERENCE_TYPE |
||||
from file.models import FileModel, TmpFile |
||||
from country.models import Country |
||||
from city.models import City |
||||
from proj.models import Settings |
||||
#functions |
||||
from functions.translate import populate_all, fill_trans_fields_all |
||||
from functions.files import check_tmp_files |
||||
from functions.form_check import is_positive_integer |
||||
|
||||
|
||||
|
||||
|
||||
class ConferenceForm(forms.Form): |
||||
types = [(item1, item2) for item1, item2 in CONFERENCE_TYPE] |
||||
type = forms.ChoiceField(label='Краткое описание', required=False, choices=types)#2 |
||||
#city = forms.ChoiceField(label='Город',choices=((None, 'Выберите страну'),)) |
||||
city = forms.CharField(label='Город', |
||||
widget=forms.Select(choices=[('','')])) |
||||
|
||||
latitude = forms.CharField(label='Широта')#7 |
||||
longitude = forms.CharField(label='Долгота')#7 |
||||
phone = forms.CharField(label='Телефон', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Введите телефон'}))#8 |
||||
fax = forms.CharField(label='Факс', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Введите факс'}))#9 |
||||
web_page = forms.CharField(label='Веб-сайт', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Введите адрес сайта'}))#10 |
||||
email = forms.CharField(label='Email', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Введите email'}))#11 |
||||
total_capacity = forms.CharField(label='Общая вместимость', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Общая вместимость'}))#12 |
||||
amount_halls = forms.CharField(label='Количество залов', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Количество залов'}))#13 |
||||
|
||||
#halls information |
||||
hall_name = forms.CharField(label='Название зала', required=False) |
||||
hall_number = forms.IntegerField(label='Номер зала', min_value=1, initial='1', required=False) |
||||
hall_capacity = forms.IntegerField(label='Вместимость зала', min_value='1', required=False) |
||||
# |
||||
exposition_hall = forms.BooleanField(label='Выставочный зал', required=False)#14 |
||||
exp_hall_area = forms.CharField(label='Площадь выст. зала', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Площадь выст. зала'}))#15 |
||||
# |
||||
wifi = forms.BooleanField(label='Wi-fi', required=False) |
||||
multimedia_equipment = forms.BooleanField(label='Мультимедийное оборудование', required=False) |
||||
conference_call = forms.BooleanField(label='Конференц-связь', required=False) |
||||
translate_equipment = forms.BooleanField(label='Оборудование для синхронного перевода', required=False) |
||||
banquet_hall = forms.BooleanField(label='Банкетный зал', required=False) |
||||
catering = forms.BooleanField(label='Кейтеринг', required=False) |
||||
hotel = forms.BooleanField(label='Гостиница', required=False) |
||||
# |
||||
key = forms.CharField(required=False, widget=forms.HiddenInput()) |
||||
|
||||
def __init__(self, *args, **kwargs): |
||||
super(ConferenceForm, self).__init__(*args, **kwargs) |
||||
# creates translated form fields, example: name_ru, name_en |
||||
# len(10) is a hack for detect if settings.LANGUAGES is not configured it return all langs |
||||
if len(settings.LANGUAGES) in range(10): |
||||
for lid, (code, name) in enumerate(settings.LANGUAGES): |
||||
# using enumerate for detect iteration number |
||||
# first iteration is a default lang so it required fields |
||||
required = True if lid == 0 else False |
||||
self.fields['name_%s' % code] = forms.CharField(label='Название', required=required) #1 |
||||
self.fields['description_%s' % code] = forms.CharField(label='Полное описание', required=False, widget=CKEditorWidget)#5 |
||||
self.fields['adress_%s' % code] = forms.CharField(label='Адрес', required=False, max_length=255, |
||||
widget=forms.TextInput(attrs={'style':'width: 550px'})) |
||||
capacity_tmpl = Settings.objects.get(key='hall_template') |
||||
self.fields['hall_capacity_%s' % code] = forms.CharField(label='Шаблон вместимости', initial= capacity_tmpl.get_value(code), |
||||
widget=forms.TextInput(attrs={'style':'width: 550px'}), required=False) |
||||
#meta data |
||||
self.fields['title_%s' % code] = forms.CharField(label='Тайтл', required=required, max_length=255, |
||||
widget=forms.TextInput(attrs={'style':'width: 550px'})) |
||||
self.fields['keywords_%s' % code] = forms.CharField(label='Дескрипшен', required=required, max_length=255, |
||||
widget=forms.TextInput(attrs={'style':'width: 550px'})) |
||||
self.fields['descriptions_%s' % code] = forms.CharField(label='Кейвордс', required=required, max_length=255, |
||||
widget=forms.TextInput(attrs={'style':'width: 550px'})) |
||||
|
||||
countries = [(item.id, item.name) for item in Country.objects.all()] |
||||
|
||||
self.fields['country'] = forms.ChoiceField(label='Страна', choices=countries)#3 |
||||
|
||||
|
||||
|
||||
|
||||
def save(self, id=None): |
||||
|
||||
data = self.cleaned_data |
||||
|
||||
if not id: |
||||
place_conference = PlaceConference() |
||||
else: |
||||
place_conference = PlaceConference.objects.get(id=id) |
||||
|
||||
#simple fields |
||||
place_conference.type = data['type'] |
||||
place_conference.google_latitude = data['latitude'] |
||||
place_conference.google_longitude = data['longitude'] |
||||
place_conference.phone = data['phone'] |
||||
place_conference.fax = data['fax'] |
||||
place_conference.web_page = data['web_page'] |
||||
place_conference.email = data['email'] |
||||
place_conference.total_capacity = data['total_capacity'] |
||||
place_conference.amount_halls = data['amount_halls'] |
||||
place_conference.exposition_hall = data['exposition_hall'] |
||||
place_conference.exp_hall_area = data['exp_hall_area'] |
||||
place_conference.wifi = data['wifi'] |
||||
place_conference.multimedia_equipment = data['multimedia_equipment'] |
||||
place_conference.conference_call = data['conference_call'] |
||||
place_conference.translate_equipment = data['translate_equipment'] |
||||
place_conference.banquet_hall = data['banquet_hall'] |
||||
place_conference.catering = data['catering'] |
||||
place_conference.hotel = data['hotel'] |
||||
if data.get('country'): |
||||
place_conference.country = Country.objects.get(id=data['country']) |
||||
if data.get('city'): |
||||
place_conference.city = City.objects.get(id=data['city']) |
||||
|
||||
# uses because in the next loop data will be overwritten |
||||
place_conference.save() |
||||
#will be saved populated fields |
||||
zero_fields = {} |
||||
#fills all translated fields with data |
||||
#if saves new object, will fill city object. otherwise existing object of City model |
||||
fill_trans_fields_all(PlaceConference, place_conference, data, id, zero_fields) |
||||
#autopopulate |
||||
#populate empty fields and fields which was already populated |
||||
place_conference_id = getattr(place_conference, 'id') |
||||
populate_all(PlaceConference, data, place_conference_id, zero_fields) |
||||
#save files |
||||
check_tmp_files(place_conference, data['key']) |
||||
|
||||
|
||||
return PlaceConference.objects.get(id=place_conference_id) |
||||
|
||||
|
||||
|
||||
def clean_latitude(self): |
||||
""" |
||||
latitude checking |
||||
""" |
||||
cleaned_data = super(ConferenceForm, self).clean() |
||||
latitude = cleaned_data.get('latitude') |
||||
latitude = latitude.replace(',', '.') |
||||
return latitude |
||||
|
||||
def clean_longitude(self): |
||||
""" |
||||
longitude checking |
||||
""" |
||||
cleaned_data = super(ConferenceForm, self).clean() |
||||
longitude = cleaned_data.get('longitude') |
||||
longitude = longitude.replace(',', '.') |
||||
return longitude |
||||
|
||||
def clean_web_page(self): |
||||
""" |
||||
web_page checking |
||||
""" |
||||
cleaned_data = super(ConferenceForm, self).clean() |
||||
web_page = cleaned_data.get('web_page') |
||||
if not web_page: |
||||
return '' |
||||
|
||||
validate = URLValidator() |
||||
try: |
||||
validate(web_page) |
||||
except(ValidationError),e: |
||||
raise ValidationError(e.messages[0]) |
||||
return web_page |
||||
|
||||
def clean_email(self): |
||||
""" |
||||
email checking |
||||
""" |
||||
cleaned_data = super(ConferenceForm, self).clean() |
||||
email = cleaned_data.get('email') |
||||
if not email: |
||||
return '' |
||||
try: |
||||
validate_email(email) |
||||
except(ValidationError),e: |
||||
raise ValidationError(e.messages[0]) |
||||
return email |
||||
|
||||
def clean_phone(self): |
||||
""" |
||||
phone checking |
||||
""" |
||||
cleaned_data = super(ConferenceForm, self).clean() |
||||
phone = cleaned_data.get('phone') |
||||
if not phone: |
||||
return |
||||
|
||||
deduct = ('-','(',')','.',' ') |
||||
|
||||
for elem in deduct: |
||||
phone = phone.replace(elem, '') |
||||
|
||||
if phone.isdigit(): |
||||
return phone |
||||
else: |
||||
raise ValidationError('Введите правильный телефон') |
||||
|
||||
def clean_fax(self): |
||||
""" |
||||
fax checking |
||||
""" |
||||
cleaned_data = super(ConferenceForm, self).clean() |
||||
fax = cleaned_data.get('fax') |
||||
if not fax: |
||||
return |
||||
|
||||
deduct = ('-','(',')','.',' ') |
||||
|
||||
for elem in deduct: |
||||
fax = fax.replace(elem, '') |
||||
|
||||
if fax.isdigit(): |
||||
return fax |
||||
else: |
||||
raise ValidationError('Введите правильный факс') |
||||
|
||||
def clean_total_capacity(self): |
||||
""" |
||||
checking total_capacity |
||||
""" |
||||
cleaned_data = super(ConferenceForm, self).clean() |
||||
total_capacity = cleaned_data.get('total_capacity').strip() |
||||
return is_positive_integer(total_capacity) |
||||
|
||||
def clean_amount_halls(self): |
||||
""" |
||||
checking amount_halls |
||||
""" |
||||
cleaned_data = super(ConferenceForm, self).clean() |
||||
amount_halls = cleaned_data.get('amount_halls').strip() |
||||
return is_positive_integer(amount_halls) |
||||
|
||||
def clean_exp_hall_area(self): |
||||
""" |
||||
checking exp_hall_area |
||||
""" |
||||
cleaned_data = super(ConferenceForm, self).clean() |
||||
exp_hall_area = cleaned_data.get('exp_hall_area').strip() |
||||
return is_positive_integer(exp_hall_area) |
||||
|
||||
class HallForm(forms.ModelForm): |
||||
""" |
||||
form for Hall model |
||||
""" |
||||
number = forms.CharField(widget=forms.TextInput(attrs={'style': 'width:30px'}),required=False) |
||||
capacity = forms.CharField(widget=forms.TextInput(attrs={'style': 'width:60px'}), required=False) |
||||
name = forms.CharField(required=False) |
||||
class Meta: |
||||
model = Hall |
||||
exclude = ('place_conference',) |
||||
|
||||
def clean_number(self): |
||||
cleaned_data = super(HallForm, self).clean() |
||||
number = cleaned_data.get('number').strip() |
||||
return is_positive_integer(number) |
||||
|
||||
def clean_capacity(self): |
||||
cleaned_data = super(HallForm, self).clean() |
||||
capacity = cleaned_data.get('capacity').strip() |
||||
return is_positive_integer(capacity) |
||||
|
||||
|
||||
|
||||
class ExpositionForm(forms.Form): |
||||
types = [(item1, item2) for item1, item2 in EXPOSITION_TYPE] |
||||
type = forms.ChoiceField(required=False, choices=types) |
||||
|
||||
latitude = forms.CharField(label='Широта') |
||||
longitude = forms.CharField(label='Долгота') |
||||
|
||||
phone = forms.CharField(label='Телефон', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Введите телефон'})) |
||||
fax = forms.CharField(label='Факс', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Введите факс'})) |
||||
web_page = forms.CharField(label='Веб-сайт', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Введите адрес сайта'}))# |
||||
email = forms.CharField(label='Email', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Введите email'}))# |
||||
# |
||||
foundation_year = forms.CharField(label='Год основания', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Год основания'})) |
||||
total_area = forms.CharField(label='Общая выставочная площадь', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Общая выст. площадь'})) |
||||
closed_area = forms.CharField(label='Закрытая выствочная площадь', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Закр. выст. площадь'})) |
||||
open_area = forms.CharField(label='Открытая выставочная площадь', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Откр. выст. площадь'})) |
||||
total_pavilions = forms.CharField(label='Количество павильонов', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Количество павильонов'})) |
||||
total_halls = forms.CharField(label='Количество конференц залов', required=False, |
||||
widget=forms.TextInput(attrs={'placeholder': 'Конференц залы'})) |
||||
# |
||||
wifi = forms.BooleanField(label='Wi-fi', required=False) |
||||
bank = forms.BooleanField(label='Банк/Банкоматы', required=False) |
||||
children_room = forms.BooleanField(label='Детская комната', required=False) |
||||
disabled_service = forms.BooleanField(label='Сервис для инвалидов', required=False) |
||||
conference_centre = forms.BooleanField(label='Конгресс-центр', required=False) |
||||
business_centre = forms.BooleanField(label='Бизнес центр', required=False) |
||||
online_registration = forms.BooleanField(label='Онлайн регистрация', required=False) |
||||
cafe = forms.BooleanField(label='Кафе', required=False) |
||||
terminals = forms.BooleanField(label='Информационые терминалы', required=False) |
||||
parking = forms.BooleanField(label='Парковка', required=False) |
||||
press_centre = forms.BooleanField(label='Пресс-центр', required=False) |
||||
mobile_application = forms.BooleanField(label='Мобильное приложение', required=False) |
||||
# |
||||
key = forms.CharField(required=False, widget=forms.HiddenInput()) |
||||
|
||||
def __init__(self, *args, **kwargs): |
||||
super(ExpositionForm, self).__init__(*args, **kwargs) |
||||
# creates translated form fields, example: name_ru, name_en |
||||
# len(10) is a hack for detect if settings.LANGUAGES is not configured it return all langs |
||||
if len(settings.LANGUAGES) in range(10): |
||||
for lid, (code, name) in enumerate(settings.LANGUAGES): |
||||
# using enumerate for detect iteration number |
||||
# first iteration is a default lang so it required fields |
||||
required = True if lid == 0 else False |
||||
self.fields['name_%s' % code] = forms.CharField(label='Название', required=required) |
||||
self.fields['description_%s' % code] = forms.CharField(label='Полное описание', required=False, widget=CKEditorWidget) |
||||
self.fields['adress_%s' % code] = forms.CharField(label='Адрес', required=False, max_length=255, |
||||
widget=forms.TextInput(attrs={'style':'width: 550px'})) |
||||
# |
||||
self.fields['total_year_action_%s' % code] = forms.CharField(label='Количество мероприятий в год', required=False, widget=CKEditorWidget) |
||||
#meta data |
||||
self.fields['title_%s' % code] = forms.CharField(label='Тайтл', required=required, max_length=255, |
||||
widget=forms.TextInput(attrs={'style':'width: 550px'})) |
||||
self.fields['keywords_%s' % code] = forms.CharField(label='Дескрипшен', required=required, max_length=255, |
||||
widget=forms.TextInput(attrs={'style':'width: 550px'})) |
||||
self.fields['descriptions_%s' % code] = forms.CharField(label='Кейвордс', required=required, max_length=255, |
||||
widget=forms.TextInput(attrs={'style':'width: 550px'})) |
||||
|
||||
countries = [(item.id, item.name) for item in Country.objects.all()] |
||||
self.fields['country'] = forms.ChoiceField(label='Страна', choices=countries)#3 |
||||
|
||||
cities = [(item.id, item.name) for item in City.objects.all()] |
||||
self.fields['city'] = forms.ChoiceField(label='Город', choices=cities) |
||||
|
||||
def save(self, id=None): |
||||
data = self.cleaned_data |
||||
|
||||
if not id: |
||||
place_exposition = PlaceExposition() |
||||
else: |
||||
place_exposition = PlaceExposition.objects.get(id=id) |
||||
|
||||
place_exposition.type = data['type'] |
||||
place_exposition.google_latitude = data['latitude'] |
||||
place_exposition.google_longitude = data['longitude'] |
||||
place_exposition.phone = data['phone'] |
||||
place_exposition.fax = data['fax'] |
||||
place_exposition.web_page = data['web_page'] |
||||
place_exposition.email = data['email'] |
||||
place_exposition.foundation_year = data['foundation_year'] |
||||
place_exposition.total_area = data['total_area'] |
||||
place_exposition.closed_area = data['closed_area'] |
||||
place_exposition.open_area = data['open_area'] |
||||
place_exposition.total_pavilions = data['total_pavilions'] |
||||
place_exposition.total_halls = data['total_halls'] |
||||
place_exposition.wifi = data['wifi'] |
||||
place_exposition.bank = data['bank'] |
||||
place_exposition.children_room = data['children_room'] |
||||
place_exposition.disabled_service = data['disabled_service'] |
||||
place_exposition.conference_centre = data['conference_centre'] |
||||
place_exposition.business_centre = data['business_centre'] |
||||
place_exposition.online_registration = data['online_registration'] |
||||
place_exposition.cafe = data['cafe'] |
||||
place_exposition.terminals = data['terminals'] |
||||
place_exposition.parking = data['parking'] |
||||
place_exposition.press_centre = data['press_centre'] |
||||
place_exposition.mobile_application = data['mobile_application'] |
||||
|
||||
if data.get('country'): |
||||
place_exposition.country = Country.objects.get(id=data['country']) |
||||
if data.get('city'): |
||||
place_exposition.city = City.objects.get(id=data['city']) |
||||
|
||||
# uses because in the next loop data will be overwritten |
||||
place_exposition.save() |
||||
#will be saved populated fields |
||||
zero_fields = {} |
||||
#fills all translated fields with data |
||||
#if saves new object, will fill city object. otherwise existing object of City model |
||||
fill_trans_fields_all(PlaceExposition, place_exposition, data, id, zero_fields) |
||||
#autopopulate |
||||
#populate empty fields and fields which was already populated |
||||
place_exposition_id = getattr(place_exposition, 'id') |
||||
populate_all(PlaceConference, data, place_exposition_id, zero_fields) |
||||
#save files |
||||
check_tmp_files(place_exposition, data['key']) |
||||
|
||||
return PlaceExposition.objects.get(id=place_exposition_id) |
||||
|
||||
|
||||
def clean_latitude(self): |
||||
""" |
||||
latitude checking |
||||
""" |
||||
cleaned_data = super(ExpositionForm, self).clean() |
||||
latitude = cleaned_data.get('latitude') |
||||
latitude = latitude.replace(',', '.') |
||||
return latitude |
||||
|
||||
def clean_longitude(self): |
||||
""" |
||||
longitude checking |
||||
""" |
||||
cleaned_data = super(ExpositionForm, self).clean() |
||||
longitude = cleaned_data.get('longitude') |
||||
longitude = longitude.replace(',', '.') |
||||
return longitude |
||||
|
||||
def clean_web_page(self): |
||||
""" |
||||
web_page checking |
||||
""" |
||||
cleaned_data = super(ExpositionForm, self).clean() |
||||
web_page = cleaned_data.get('web_page') |
||||
if not web_page: |
||||
return '' |
||||
|
||||
validate = URLValidator() |
||||
try: |
||||
validate(web_page) |
||||
except(ValidationError),e: |
||||
raise ValidationError(e.messages[0]) |
||||
return web_page |
||||
|
||||
def clean_email(self): |
||||
""" |
||||
email checking |
||||
""" |
||||
cleaned_data = super(ExpositionForm, self).clean() |
||||
email = cleaned_data.get('email') |
||||
if not email: |
||||
return '' |
||||
try: |
||||
validate_email(email) |
||||
except(ValidationError),e: |
||||
raise ValidationError(e.messages[0]) |
||||
return email |
||||
|
||||
def clean_phone(self): |
||||
""" |
||||
phone checking |
||||
""" |
||||
cleaned_data = super(ExpositionForm, self).clean() |
||||
phone = cleaned_data.get('phone') |
||||
if not phone: |
||||
return |
||||
|
||||
deduct = ('-','(',')','.',' ') |
||||
|
||||
for elem in deduct: |
||||
phone = phone.replace(elem, '') |
||||
|
||||
if phone.isdigit(): |
||||
return phone |
||||
else: |
||||
raise ValidationError('Введите правильный телефон') |
||||
|
||||
def clean_fax(self): |
||||
""" |
||||
fax checking |
||||
""" |
||||
cleaned_data = super(ExpositionForm, self).clean() |
||||
fax = cleaned_data.get('fax') |
||||
if not fax: |
||||
return |
||||
|
||||
deduct = ('-','(',')','.',' ') |
||||
|
||||
for elem in deduct: |
||||
fax = fax.replace(elem, '') |
||||
|
||||
if fax.isdigit(): |
||||
return fax |
||||
else: |
||||
raise ValidationError('Введите правильный факс') |
||||
|
||||
|
||||
|
||||
def clean_foundation_year(self): |
||||
""" |
||||
checking foundation_year |
||||
""" |
||||
cleaned_data = super(ExpositionForm, self).clean() |
||||
foundation_year = cleaned_data.get('foundation_year').strip() |
||||
return is_positive_integer(foundation_year) |
||||
|
||||
def clean_total_area(self): |
||||
""" |
||||
checking foundation_year |
||||
""" |
||||
cleaned_data = super(ExpositionForm, self).clean() |
||||
total_area = cleaned_data.get('total_area').strip() |
||||
return is_positive_integer(total_area) |
||||
|
||||
def clean_closed_area(self): |
||||
""" |
||||
checking closed_area |
||||
""" |
||||
cleaned_data = super(ExpositionForm, self).clean() |
||||
closed_area = cleaned_data.get('closed_area').strip() |
||||
return is_positive_integer(closed_area) |
||||
|
||||
def clean_open_area(self): |
||||
""" |
||||
checking open_area |
||||
""" |
||||
cleaned_data = super(ExpositionForm, self).clean() |
||||
open_area = cleaned_data.get('open_area').strip() |
||||
return is_positive_integer(open_area) |
||||
|
||||
def clean_total_pavilions(self): |
||||
""" |
||||
checking total_pavilions |
||||
""" |
||||
cleaned_data = super(ExpositionForm, self).clean() |
||||
total_pavilions = cleaned_data.get('total_pavilions').strip() |
||||
return is_positive_integer(total_pavilions) |
||||
|
||||
def clean_total_halls(self): |
||||
""" |
||||
checking total_halls |
||||
""" |
||||
cleaned_data = super(ExpositionForm, self).clean() |
||||
total_halls = cleaned_data.get('total_halls').strip() |
||||
return is_positive_integer(total_halls) |
||||
@ -1,126 +0,0 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django.db import models |
||||
from django.contrib.contenttypes import generic |
||||
from hvad.models import TranslatableModel, TranslatedFields |
||||
from functions.custom_fields import EnumField |
||||
|
||||
|
||||
|
||||
|
||||
CONFERENCE_TYPE = (('Convention centre', 'Конгресс-центр'), ('Exposition centre', 'Конференц зал'),) |
||||
|
||||
class PlaceConference(TranslatableModel): |
||||
country = models.ForeignKey('country.Country', null=True) |
||||
city = models.ForeignKey('city.City', null=True) |
||||
#type uses EnumField for creating Enum type field in Mysql database |
||||
type = EnumField(values = [item1 for item1, item2 in CONFERENCE_TYPE]) |
||||
#information |
||||
google_latitude = models.FloatField() |
||||
google_longitude = models.FloatField() |
||||
phone = models.PositiveIntegerField(blank=True, null=True) |
||||
fax = models.PositiveIntegerField(blank=True, null=True) |
||||
# |
||||
web_page = models.URLField(blank=True) |
||||
email = models.EmailField(blank=True) |
||||
# |
||||
total_capacity = models.PositiveIntegerField(blank=True, null=True) |
||||
amount_halls = models.PositiveIntegerField(blank=True, null=True) |
||||
|
||||
exposition_hall = models.NullBooleanField() |
||||
exp_hall_area = models.PositiveIntegerField(blank=True, null=True) |
||||
# |
||||
wifi = models.NullBooleanField() |
||||
multimedia_equipment = models.NullBooleanField() |
||||
conference_call = models.NullBooleanField() |
||||
translate_equipment = models.NullBooleanField() |
||||
banquet_hall = models.NullBooleanField() |
||||
catering = models.NullBooleanField() |
||||
hotel = models.NullBooleanField() |
||||
# |
||||
files = generic.GenericRelation('file.FileModel',content_type_field='content_type', object_id_field='object_id') |
||||
# |
||||
created = models.DateTimeField(auto_now_add=True) |
||||
modified = models.DateTimeField(auto_now=True) |
||||
|
||||
#translations is translated fields |
||||
translations = TranslatedFields( |
||||
name = models.CharField(max_length=100), |
||||
description = models.TextField(blank=True), |
||||
adress = models.TextField(blank=True), |
||||
# |
||||
hall_capacity = models.CharField(max_length=255, blank=True), |
||||
#-----meta data |
||||
title = models.CharField(max_length=250), |
||||
descriptions = models.CharField(max_length=250), |
||||
keywords = models.CharField(max_length=250), |
||||
) |
||||
|
||||
def __unicode__(self): |
||||
return self.lazy_translation_getter('name', unicode(self.pk)) |
||||
|
||||
class Hall(models.Model): |
||||
place_conference = models.ForeignKey(PlaceConference) |
||||
name = models.CharField(max_length=100, blank=True) |
||||
number = models.PositiveIntegerField(blank=True, null=True) |
||||
capacity = models.PositiveIntegerField(blank=True, null=True) |
||||
|
||||
EXPOSITION_TYPE = (('Exposition complex', 'Выставочный комплекс'), ('Convention centre', 'Конгессо-выставочный центр'), |
||||
('Exposition centre', 'Выставочный центр'),) |
||||
|
||||
class PlaceExposition(TranslatableModel): |
||||
# |
||||
country = models.ForeignKey('country.Country') |
||||
city = models.ForeignKey('city.City') |
||||
#type uses EnumField for creating Enum type field in Mysql database |
||||
type = EnumField(values = [item1 for item1, item2 in EXPOSITION_TYPE]) |
||||
#information |
||||
google_latitude = models.FloatField() |
||||
google_longitude = models.FloatField() |
||||
phone = models.PositiveIntegerField(blank=True, null=True) |
||||
fax = models.PositiveIntegerField(blank=True, null=True) |
||||
# |
||||
web_page = models.URLField(blank=True) |
||||
email = models.EmailField(blank=True) |
||||
# |
||||
# |
||||
foundation_year = models.PositiveIntegerField(blank=True, null=True) |
||||
total_area = models.PositiveIntegerField(blank=True, null=True) |
||||
closed_area = models.PositiveIntegerField(blank=True, null=True) |
||||
open_area = models.PositiveIntegerField(blank=True, null=True) |
||||
total_pavilions = models.PositiveIntegerField(blank=True, null=True) |
||||
total_halls = models.PositiveIntegerField(blank=True, null=True) |
||||
# |
||||
wifi = models.NullBooleanField() |
||||
bank = models.NullBooleanField() |
||||
children_room = models.NullBooleanField() |
||||
disabled_service = models.NullBooleanField() |
||||
conference_centre = models.NullBooleanField() #change name here, in form, in template |
||||
business_centre = models.NullBooleanField() |
||||
online_registration = models.NullBooleanField() |
||||
cafe = models.NullBooleanField() |
||||
terminals = models.NullBooleanField() |
||||
parking = models.NullBooleanField() |
||||
press_centre = models.NullBooleanField() |
||||
mobile_application = models.NullBooleanField() |
||||
# |
||||
files = generic.GenericRelation('file.FileModel',content_type_field='content_type', object_id_field='object_id') |
||||
# |
||||
created = models.DateTimeField(auto_now_add=True) |
||||
modified = models.DateTimeField(auto_now=True) |
||||
|
||||
#translations is translated fields |
||||
translations = TranslatedFields( |
||||
name = models.CharField(max_length=100), |
||||
description = models.TextField(blank=True), |
||||
adress = models.TextField(blank=True), |
||||
#-----meta data |
||||
title = models.CharField(max_length=250), |
||||
descriptions = models.CharField(max_length=250), |
||||
keywords = models.CharField(max_length=250), |
||||
# |
||||
total_year_action = models.TextField(blank=True), |
||||
) |
||||
|
||||
def __unicode__(self): |
||||
return self.lazy_translation_getter('name', unicode(self.pk)) |
||||
|
||||
@ -1,379 +0,0 @@ |
||||
{% extends 'base.html' %} |
||||
{% load static %} |
||||
|
||||
{% block scripts %} |
||||
|
||||
<script src="{% static 'ckeditor/ckeditor/ckeditor.js' %}"></script> |
||||
{# selects #} |
||||
<link href="{% static 'js/select/select2.css' %}" rel="stylesheet"/> |
||||
<script src="{% static 'js/select/select2.js' %}"></script> |
||||
<script src="{% static 'custom_js/make_select.js' %}"></script> |
||||
<script src="{% static 'custom_js/formset_add.js' %}"></script> |
||||
<script src="{% static 'custom_js/place_city_ajax.js' %}"></script> |
||||
|
||||
|
||||
{% endblock %} |
||||
|
||||
{% block body %} |
||||
|
||||
<form method="post" class="form-horizontal" enctype="multipart/form-data" name="form1" id="form1"> {% csrf_token %} |
||||
<fieldset> |
||||
<legend><i class="icon-edit"></i> {% if conference_id %} Изменить {% else %} Добавить {% endif %}конференц зал</legend> |
||||
|
||||
<div class="box span8"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-pencil"></i> Основная информация</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
{# Hidden input uses for comparing with TmpFile objects #} |
||||
|
||||
{{ form.key }} |
||||
|
||||
{# name #} |
||||
{% with field='name' form=form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
{# type #} |
||||
<div class="control-group {% if form.type.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.type.label }}:</label> |
||||
<div class="controls">{{ form.type}} |
||||
<span class="help-inline">{{ form.type.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# country #} |
||||
<div class="control-group {% if form.country.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.country.label }}:</label> |
||||
<div class="controls">{{ form.country}} |
||||
<span class="help-inline">{{ form.country.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# city #} |
||||
<div class="control-group {% if form.city.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.city.label }}:</label> |
||||
<div class="controls">{{ form.city}} |
||||
<span class="help-inline">{{ form.city.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# total_capacity #} |
||||
<div class="control-group {% if form.total_capacity.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.total_capacity.label }}:</label> |
||||
<div class="controls">{{ form.total_capacity}} |
||||
<span class="help-inline">{{ form.total_capacity.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# amount_halls #} |
||||
<div class="control-group {% if form.amount_halls.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.amount_halls.label }}:</label> |
||||
<div class="controls">{{ form.amount_halls}} |
||||
<span class="help-inline">{{ form.amount_halls.errors }}</span> |
||||
</div> |
||||
</div> |
||||
|
||||
{# exposition_hall #} |
||||
<div class="control-group {% if form.exposition_hall.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.exposition_hall.label }}:</label> |
||||
<div class="controls">{{ form.exposition_hall}} |
||||
<span class="help-inline">{{ form.exposition_hall.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# exp_hall_area #} |
||||
<div class="control-group {% if form.exp_hall_area.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.exp_hall_area.label }}:</label> |
||||
<div class="controls">{{ form.exp_hall_area}} |
||||
<span class="help-inline">{{ form.exp_hall_area.errors }}</span> |
||||
</div> |
||||
</div> |
||||
|
||||
|
||||
</div> |
||||
</div> |
||||
|
||||
<div class="box span8"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-pencil"></i> Вместимость залов</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
{# hall_capacity #} |
||||
{% with field='hall_capacity' form=form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
<div class="control-group"> |
||||
<div class="controls"> |
||||
<p class="text-info">%(name)s: Название зала</p> |
||||
<p class="text-info">%(number)s: Номер зала</p> |
||||
<p class="text-info">%(capacity)s: Вместимость зала</p> |
||||
|
||||
</div> |
||||
</div> |
||||
<hr> |
||||
{# formset of halls #} |
||||
{{ formset.management_form }} |
||||
<div id="halls" style="padding-left: 160px;{% if conference_id %} {% else %}display: none;{% endif %}"> |
||||
<table class="table table-hover" style=" width: 100%;"> |
||||
<thead> |
||||
<tr> |
||||
<td>Название зала</td> |
||||
<td>Номер</td> |
||||
<td>Вместимость</td> |
||||
<td></td> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
|
||||
{% for form in formset.forms %} |
||||
|
||||
<tr class="item" {% if conference_id %}{% else %}style="display: NONE"{% endif %}> |
||||
<td>{{ form.name }}</td> |
||||
<td>{{ form.number }}</td> |
||||
<td>{{ form.capacity }}</td> |
||||
<td><a class="delete btn btn-danger" href="#"><i class="icon-trash icon-white"></i> Удалить</a></td> |
||||
</tr> |
||||
|
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
<p style=" padding-left: 20px"><a id="add" class="btn btn-success" href="#"><i class="icon-plus-sign icon-white"></i> Добавить зал</a></p> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="box span8"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-pencil"></i> Дополнительная информация</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
{# description #} |
||||
{% with field='description' form=form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
{# adress #} |
||||
{% with field='adress' form=form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
{# latitude #} |
||||
<div class="control-group {% if form.latitude.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.latitude.label }}:</label> |
||||
<div class="controls">{{ form.latitude}} |
||||
<span class="help-inline">{{ form.latitude.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# longitude #} |
||||
<div class="control-group {% if form.longitude.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.longitude.label }}:</label> |
||||
<div class="controls">{{ form.longitude}} |
||||
<span class="help-inline">{{ form.longitude.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# phone #} |
||||
<div class="control-group {% if form.phone.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.phone.label }}:</label> |
||||
<div class="controls">{{ form.phone}} |
||||
<span class="help-inline">{{ form.phone.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# fax #} |
||||
<div class="control-group {% if form.fax.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.fax.label }}:</label> |
||||
<div class="controls">{{ form.fax}} |
||||
<span class="help-inline">{{ form.fax.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# web_page #} |
||||
<div class="control-group {% if form.web_page.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.web_page.label }}:</label> |
||||
<div class="controls">{{ form.web_page}} |
||||
<span class="help-inline">{{ form.web_page.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# email #} |
||||
<div class="control-group {% if form.email.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.email.label }}:</label> |
||||
<div class="controls">{{ form.email}} |
||||
<span class="help-inline">{{ form.email.errors }}</span> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="box span8" id="file"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-pencil"></i> Файлы</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
|
||||
{# this div shows list of files and refreshes when new file added #} |
||||
<div id="file_list"> |
||||
<table class="table table-hover" style="padding-left: 50px"> |
||||
|
||||
<thead> |
||||
<tr> |
||||
<td>id</td> |
||||
<td>Файл</td> |
||||
<td>Имя</td> |
||||
<td>Назначение</td> |
||||
<td>Тип</td> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for file in files %} |
||||
|
||||
<tr> |
||||
<td>{{ file.id }}</td> |
||||
<td><img src="{{ file.file_path.url }}"></td> |
||||
<td>{{ file.file_name }}</td> |
||||
<td>{{ file.purpose }}</td> |
||||
<td>{{ file.file_type }}</td> |
||||
</tr> |
||||
|
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
{# button that shows modal window with file form #} |
||||
<p style="padding-left: 50px"> <a href="#myModal" id="file_add" role="button" class="btn btn-success" data-toggle="modal"> |
||||
<i class="icon-plus-sign icon-white"></i>Добавить файл</a></p> |
||||
|
||||
</div> |
||||
</div> |
||||
|
||||
|
||||
<div class="box span8"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-pencil"></i> Услуги</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
<div style="float: left"> |
||||
{# wifi #} |
||||
<div class="control-group {% if form.wifi.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.wifi.label }}:</label> |
||||
<div class="controls">{{ form.wifi}} |
||||
<span class="help-inline">{{ form.wifi.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# multimedia_equipment #} |
||||
<div class="control-group {% if form.multimedia_equipment.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.multimedia_equipment.label }}:</label> |
||||
<div class="controls">{{ form.multimedia_equipment}} |
||||
<span class="help-inline">{{ form.multimedia_equipment.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# conference_call #} |
||||
<div class="control-group {% if form.conference_call.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.conference_call.label }}:</label> |
||||
<div class="controls">{{ form.conference_call}} |
||||
<span class="help-inline">{{ form.conference_call.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# translate_equipment #} |
||||
<div class="control-group {% if form.translate_equipment.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.translate_equipment.label }}:</label> |
||||
<div class="controls">{{ form.translate_equipment }} |
||||
<span class="help-inline">{{ form.translate_equipment.errors }}</span> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div style="float: left"class="offset1"> |
||||
{# banquet_hall #} |
||||
<div class="control-group {% if form.banquet_hall.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.banquet_hall.label }}:</label> |
||||
<div class="controls">{{ form.banquet_hall}} |
||||
<span class="help-inline">{{ form.banquet_hall.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# catering #} |
||||
<div class="control-group {% if form.catering.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.catering.label }}:</label> |
||||
<div class="controls">{{ form.catering}} |
||||
<span class="help-inline">{{ form.catering.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# hotel #} |
||||
<div class="control-group {% if form.hotel.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.hotel.label }}:</label> |
||||
<div class="controls">{{ form.hotel}} |
||||
<span class="help-inline">{{ form.hotel.errors }}</span> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="box span8"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-pencil"></i> Мета даные</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
{# keywords #} |
||||
{% with field='keywords' form=form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
{# title #} |
||||
{% with field='title' form=form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
{# descriptions #} |
||||
{% with field='descriptions' form=form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="controls"> |
||||
<input class="btn btn-large btn-primary" type="submit" value="Добавить"> |
||||
<input class="btn btn-large" type="reset" value="Отмена"> |
||||
</div> |
||||
|
||||
</fieldset> |
||||
</form> |
||||
|
||||
{# modal window #} |
||||
<div class="modal hide fade" id="myModal" > |
||||
<div class="modal-header"> |
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" id="close">×</button> |
||||
<h3>Добавить файл</h3> |
||||
</div> |
||||
|
||||
<div id="form_body"> |
||||
<div class="modal-body"> |
||||
<form method="post" class="form-horizontal" enctype="multipart/form-data" name="file_form" id="file_form" > {% csrf_token %} |
||||
|
||||
{# hidden inputs uses for comparing with Country form key#} |
||||
{{ file_form.key }} |
||||
<input type="hidden" id="country_id" value="{{ country_id }}"> |
||||
{# file_path #} |
||||
<div class="control-group{% if file_form.file_path.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ file_form.file_path.label }}:</label> |
||||
<div class="controls">{{ file_form.file_path }} |
||||
<span class="help-inline">{{ file_form.file_path.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# file purpose #} |
||||
<div class="control-group{% if file_form.purpose.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ file_form.purpose.label }}:</label> |
||||
<div class="controls">{{ file_form.purpose }} |
||||
<span class="help-inline">{{ file_form.purpose.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# file_name #} |
||||
{% with field='file_name' form=file_form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
{# file_description #} |
||||
{% with field='description' form=file_form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
|
||||
</div> |
||||
|
||||
<div class="modal-footer"> |
||||
<div class="controls"> |
||||
<input class="btn btn-primary" type="submit" value="Добавить"> |
||||
<input type="reset" class="btn" value="Отменить" data-dismiss="modal"> |
||||
</form> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
||||
|
||||
{% endblock %} |
||||
@ -1,44 +0,0 @@ |
||||
{% extends 'base.html' %} |
||||
|
||||
{% block body %} |
||||
|
||||
<div class="box span8"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-arrow-down"></i>Места проведения конференций</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
<table class="table table-hover"> |
||||
<thead> |
||||
<tr> |
||||
<th>id</th> |
||||
<th>Название</th> |
||||
<th>Краткое описание</th> |
||||
<th>Страна</th> |
||||
<th>Город</th> |
||||
<th> </th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for item in conferences %} |
||||
<tr> |
||||
<td>{{ item.id }}</td> |
||||
<td>{{ item.name }}</td> |
||||
<td>{% ifnotequal item.type None %}{{ item.type }} {% endifnotequal %}</td> |
||||
<td>{% ifnotequal item.country None %}{{ item.country }} {% endifnotequal %}</td> |
||||
<td>{% ifnotequal item.city None %}{{ item.city }} {% endifnotequal %}</td> |
||||
<td class="center sorting_1"> |
||||
<a class="btn btn-info" href="/place/conference/change/{{ item.id }}"> |
||||
<i class="icon-edit icon-white"></i> Изменить |
||||
</a> |
||||
</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
<a class="btn btn-success" href="/place/conference/add"><i class="icon-plus-sign icon-white"></i> Добавить конферец зал</a> |
||||
</div> |
||||
|
||||
</div> |
||||
|
||||
|
||||
{% endblock %} |
||||
@ -1,406 +0,0 @@ |
||||
{% extends 'base.html' %} |
||||
{% load static %} |
||||
|
||||
{% block scripts %} |
||||
<script src="{% static 'ckeditor/ckeditor/ckeditor.js' %}"></script> |
||||
{# selects #} |
||||
<link href="{% static 'js/select/select2.css' %}" rel="stylesheet"/> |
||||
<script src="{% static 'js/select/select2.js' %}"></script> |
||||
<script src="{% static 'custom_js/make_select.js' %}"></script> |
||||
<script src="{% static 'custom_js/place_city_ajax.js' %}"></script> |
||||
<script src="{% static 'custom_js/country_ajax_post.js' %}"></script> |
||||
|
||||
<script> |
||||
$(document).ready(function(){ |
||||
$('#id_city').html('<option></option>') |
||||
$('#id_city').select2({ |
||||
placeholder: "Выберите страну", |
||||
allowClear: true, |
||||
width: 'element' |
||||
}); |
||||
|
||||
$('#id_country').change(function(){ |
||||
$.get( |
||||
"/place/conference/ajax_city/", {'id': $(this).val()}, function(j){ |
||||
|
||||
$('#id_city').html(j); |
||||
$('#id_city').attr('disabled', false); |
||||
|
||||
}); |
||||
$('#id_city').select2({ |
||||
placeholder: "Выберите страну" |
||||
}) |
||||
|
||||
|
||||
}); |
||||
}); |
||||
</script> |
||||
|
||||
{% endblock %} |
||||
|
||||
{% block body %} |
||||
|
||||
<form method="post" class="form-horizontal" enctype="multipart/form-data" name="form1" id="form1"> {% csrf_token %} |
||||
<fieldset> |
||||
<legend><i class="icon-edit"></i> {% if exposition_id %} Изменить {% else %} Добавить {% endif %}выставочный центр</legend> |
||||
|
||||
<div class="box span8"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-pencil"></i> Основная информация</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
|
||||
{# Hidden input uses for comparing with TmpFile objects #} |
||||
{{ form.key }} |
||||
{# name #} |
||||
{% with field='name' form=form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
{# type #} |
||||
<div class="control-group {% if form.type.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.type.label }}:</label> |
||||
<div class="controls">{{ form.type}} |
||||
<span class="help-inline">{{ form.type.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# country #} |
||||
<div class="control-group {% if form.country.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.country.label }}:</label> |
||||
<div class="controls">{{ form.country}} |
||||
<span class="help-inline">{{ form.country.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# city #} |
||||
<div class="control-group {% if form.city.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.city.label }}:</label> |
||||
<div class="controls">{{ form.city}} |
||||
<span class="help-inline">{{ form.city.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# foundation_year #} |
||||
<div class="control-group {% if form.foundation_year.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.foundation_year.label }}:</label> |
||||
<div class="controls">{{ form.foundation_year}} |
||||
<span class="help-inline">{{ form.foundation_year.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# total_year_action #} |
||||
{% with field='total_year_action' form=form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
{# total_area #} |
||||
<div class="control-group {% if form.total_area.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.total_area.label }}:</label> |
||||
<div class="controls">{{ form.total_area}} |
||||
<span class="help-inline">{{ form.total_area.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# closed_area #} |
||||
<div class="control-group {% if form.closed_area.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.closed_area.label }}:</label> |
||||
<div class="controls">{{ form.closed_area}} |
||||
<span class="help-inline">{{ form.closed_area.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# open_area #} |
||||
<div class="control-group {% if form.open_area.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.open_area.label }}:</label> |
||||
<div class="controls">{{ form.open_area}} |
||||
<span class="help-inline">{{ form.open_area.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# total_pavilions #} |
||||
<div class="control-group {% if form.total_pavilions.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.total_pavilions.label }}:</label> |
||||
<div class="controls">{{ form.total_pavilions}} |
||||
<span class="help-inline">{{ form.total_pavilions.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# total_halls #} |
||||
<div class="control-group {% if form.total_halls.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.total_halls.label }}:</label> |
||||
<div class="controls">{{ form.total_halls}} |
||||
<span class="help-inline">{{ form.total_halls.errors }}</span> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
||||
</div> |
||||
|
||||
<div class="box span8"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-pencil"></i> Дополнительная информация</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
|
||||
{# description #} |
||||
{% with field='description' form=form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
{# adress #} |
||||
{% with field='adress' form=form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
{# latitude #} |
||||
<div class="control-group {% if form.latitude.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.latitude.label }}:</label> |
||||
<div class="controls">{{ form.latitude}} |
||||
<span class="help-inline">{{ form.latitude.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# longitude #} |
||||
<div class="control-group {% if form.longitude.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.longitude.label }}:</label> |
||||
<div class="controls">{{ form.longitude}} |
||||
<span class="help-inline">{{ form.longitude.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# phone #} |
||||
<div class="control-group {% if form.phone.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.phone.label }}:</label> |
||||
<div class="controls">{{ form.phone}} |
||||
<span class="help-inline">{{ form.phone.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# fax #} |
||||
<div class="control-group {% if form.fax.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.fax.label }}:</label> |
||||
<div class="controls">{{ form.fax}} |
||||
<span class="help-inline">{{ form.fax.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# web_page #} |
||||
<div class="control-group {% if form.web_page.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.web_page.label }}:</label> |
||||
<div class="controls">{{ form.web_page}} |
||||
<span class="help-inline">{{ form.web_page.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# email #} |
||||
<div class="control-group {% if form.email.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.email.label }}:</label> |
||||
<div class="controls">{{ form.email}} |
||||
<span class="help-inline">{{ form.email.errors }}</span> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
||||
</div> |
||||
|
||||
<div class="box span8" id="file"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-pencil"></i> Файлы</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
{# button that shows modal window with file form #} |
||||
<a href="#myModal" id="file_add" role="button" class="btn btn-info" data-toggle="modal">Добавить файл</a> |
||||
{# this div shows list of files and refreshes when new file added #} |
||||
<div id="file_list"> |
||||
<table class="table table-hover"> |
||||
|
||||
<thead> |
||||
<tr> |
||||
<td>id</td> |
||||
<td>Файл</td> |
||||
<td>Имя</td> |
||||
<td>Назначение</td> |
||||
<td>Тип</td> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for file in files %} |
||||
|
||||
<tr> |
||||
<td>{{ file.id }}</td> |
||||
<td><img src="{{ file.file_path.url }}"></td> |
||||
<td>{{ file.file_name }}</td> |
||||
<td>{{ file.purpose }}</td> |
||||
<td>{{ file.file_type }}</td> |
||||
</tr> |
||||
|
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
|
||||
</div> |
||||
</div> |
||||
|
||||
<div class="box span8"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-pencil"></i> Услуги</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
<div style="float: left"> |
||||
{# wifi #} |
||||
<div class="control-group {% if form.wifi.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.wifi.label }}:</label> |
||||
<div class="controls">{{ form.wifi}} |
||||
<span class="help-inline">{{ form.wifi.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# bank #} |
||||
<div class="control-group {% if form.bank.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.bank.label }}:</label> |
||||
<div class="controls">{{ form.bank}} |
||||
<span class="help-inline">{{ form.bank.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# children_room #} |
||||
<div class="control-group {% if form.children_room.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.children_room.label }}:</label> |
||||
<div class="controls">{{ form.children_room}} |
||||
<span class="help-inline">{{ form.children_room.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# disabled_service #} |
||||
<div class="control-group {% if form.disabled_service.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.disabled_service.label }}:</label> |
||||
<div class="controls">{{ form.disabled_service}} |
||||
<span class="help-inline">{{ form.disabled_service.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# conference_centre #} |
||||
<div class="control-group {% if form.conference_centre.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.conference_centre.label }}:</label> |
||||
<div class="controls">{{ form.conference_centre}} |
||||
<span class="help-inline">{{ form.conference_centre.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# business_centre #} |
||||
<div class="control-group {% if form.business_centre.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.business_centre.label }}:</label> |
||||
<div class="controls">{{ form.business_centre}} |
||||
<span class="help-inline">{{ form.business_centre.errors }}</span> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div style="float: left" class="offset1"> |
||||
{# online_registration #} |
||||
<div class="control-group {% if form.online_registration.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.online_registration.label }}:</label> |
||||
<div class="controls">{{ form.online_registration}} |
||||
<span class="help-inline">{{ form.online_registration.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# cafe #} |
||||
<div class="control-group {% if form.cafe.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.cafe.label }}:</label> |
||||
<div class="controls">{{ form.cafe}} |
||||
<span class="help-inline">{{ form.cafe.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# terminals #} |
||||
<div class="control-group {% if form.terminals.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.terminals.label }}:</label> |
||||
<div class="controls">{{ form.terminals}} |
||||
<span class="help-inline">{{ form.terminals.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# parking #} |
||||
<div class="control-group {% if form.parking.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.parking.label }}:</label> |
||||
<div class="controls">{{ form.parking}} |
||||
<span class="help-inline">{{ form.parking.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# press_centre #} |
||||
<div class="control-group {% if form.press_centre.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.press_centre.label }}:</label> |
||||
<div class="controls">{{ form.press_centre}} |
||||
<span class="help-inline">{{ form.press_centre.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# mobile_application #} |
||||
<div class="control-group {% if form.mobile_application.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ form.mobile_application.label }}:</label> |
||||
<div class="controls">{{ form.mobile_application}} |
||||
<span class="help-inline">{{ form.mobile_application.errors }}</span> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
||||
</div> |
||||
|
||||
<div class="box span8"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-pencil"></i> Мета даные</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
|
||||
{# keywords #} |
||||
{% with field='keywords' form=form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
{# title #} |
||||
{% with field='title' form=form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
{# descriptions #} |
||||
{% with field='descriptions' form=form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
|
||||
</div> |
||||
</div> |
||||
|
||||
|
||||
<div class="controls"> |
||||
<input class="btn btn-large btn-primary" type="submit" value="Добавить"> |
||||
<input class="btn btn-large" type="reset" value="Отмена"> |
||||
</div> |
||||
|
||||
</fieldset> |
||||
</form> |
||||
|
||||
{# modal window #} |
||||
<div class="modal hide fade" id="myModal" > |
||||
<div class="modal-header"> |
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" id="close">×</button> |
||||
<h3>Добавить файл</h3> |
||||
</div> |
||||
|
||||
<div id="form_body"> |
||||
<div class="modal-body"> |
||||
<form method="post" class="form-horizontal" enctype="multipart/form-data" name="file_form" id="file_form" > {% csrf_token %} |
||||
|
||||
{# hidden inputs uses for comparing with Country form key#} |
||||
{{ file_form.key }} |
||||
<input type="hidden" id="country_id" value="{{ country_id }}"> |
||||
{# file_path #} |
||||
<div class="control-group{% if file_form.file_path.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ file_form.file_path.label }}:</label> |
||||
<div class="controls">{{ file_form.file_path }} |
||||
<span class="help-inline">{{ file_form.file_path.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# file purpose #} |
||||
<div class="control-group{% if file_form.purpose.errors %}error{% endif %}"> |
||||
<label class="control-label">{{ file_form.purpose.label }}:</label> |
||||
<div class="controls">{{ file_form.purpose }} |
||||
<span class="help-inline">{{ file_form.purpose.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{# file_name #} |
||||
{% with field='file_name' form=file_form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
{# file_description #} |
||||
{% with field='description' form=file_form languages=languages %} |
||||
{% include 'admin/forms/multilang.html' %} |
||||
{% endwith %} |
||||
|
||||
</div> |
||||
|
||||
<div class="modal-footer"> |
||||
<div class="controls"> |
||||
<input class="btn btn-primary" type="submit" value="Добавить"> |
||||
<input type="reset" class="btn" value="Отменить" data-dismiss="modal"> |
||||
</form> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
||||
{% endblock %} |
||||
@ -1,43 +0,0 @@ |
||||
{% extends 'base.html' %} |
||||
|
||||
{% block body %} |
||||
|
||||
<div class="box span8"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-arrow-down"></i>Места проведения выставок</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
<table class="table table-hover"> |
||||
<thead> |
||||
<tr> |
||||
<th>id</th> |
||||
<th>Название</th> |
||||
<th>Краткое описание</th> |
||||
<th>Страна</th> |
||||
<th>Город</th> |
||||
<th> </th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for item in expositions %} |
||||
<tr> |
||||
<td>{{ item.id }}</td> |
||||
<td>{{ item.name }}</td> |
||||
<td>{% ifnotequal item.type None %}{{ item.type }} {% endifnotequal %}</td> |
||||
<td>{% ifnotequal item.country None %}{{ item.country }} {% endifnotequal %}</td> |
||||
<td>{% ifnotequal item.city None %}{{ item.city }} {% endifnotequal %}</td> |
||||
<td class="center sorting_1"> |
||||
<a class="btn btn-info" href="/place/exposition/change/{{ item.id }}"> |
||||
<i class="icon-edit icon-white"></i> Изменить |
||||
</a> |
||||
</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
<a class="btn btn-success" href="/place/exposition/add"><i class="icon-plus-sign icon-white"></i> Добавить выставочный центр</a> |
||||
</div> |
||||
|
||||
</div> |
||||
|
||||
{% endblock %} |
||||
@ -1,3 +0,0 @@ |
||||
{% for item in objects %} |
||||
<option value="{{ item.id }}">{{ item.name }}</option> |
||||
{% endfor %} |
||||
@ -1,16 +0,0 @@ |
||||
""" |
||||
This file demonstrates writing tests using the unittest module. These will pass |
||||
when you run "manage.py test". |
||||
|
||||
Replace this with more appropriate tests for your application. |
||||
""" |
||||
|
||||
from django.test import TestCase |
||||
|
||||
|
||||
class SimpleTest(TestCase): |
||||
def test_basic_addition(self): |
||||
""" |
||||
Tests that 1 + 1 always equals 2. |
||||
""" |
||||
self.assertEqual(1 + 1, 2) |
||||
@ -1,13 +0,0 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django.conf.urls import patterns, include, url |
||||
|
||||
urlpatterns = patterns('', |
||||
url(r'^conference/add.*/$', 'place.views.conference_add'), |
||||
url(r'^exposition/add.*/$', 'place.views.exposition_add'), |
||||
url(r'^conference/change/(?P<conference_id>\d+).*/$', 'place.views.conference_change'), |
||||
url(r'^exposition/change/(?P<exposition_id>\d+).*/$', 'place.views.exposition_change'), |
||||
url(r'^conference/all/$', 'place.views.conference_all'), |
||||
url(r'^exposition/all/$', 'place.views.exposition_all'), |
||||
url(r'^conference/ajax_city/$', 'place.views.ajax_city'), |
||||
|
||||
) |
||||
@ -1,221 +0,0 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django.shortcuts import render_to_response |
||||
from django.http import HttpResponseRedirect, HttpResponse |
||||
from django.core.context_processors import csrf |
||||
from django.conf import settings |
||||
from django.forms.formsets import BaseFormSet, formset_factory |
||||
from django.forms.models import modelformset_factory |
||||
from django.contrib.contenttypes.models import ContentType |
||||
from django.contrib.auth.decorators import login_required |
||||
#models and forms |
||||
from forms import * |
||||
from models import PlaceConference, PlaceExposition, Hall |
||||
from city.models import City |
||||
from file.models import FileModel, TmpFile |
||||
from file.forms import FileModelForm |
||||
import random |
||||
|
||||
|
||||
# This class is used to make empty formset forms required |
||||
# See http://stackoverflow.com/questions/2406537/django-formsets-make-first-required/4951032#4951032 |
||||
class RequiredFormSet(BaseFormSet): |
||||
def __init__(self, *args, **kwargs): |
||||
super(RequiredFormSet, self).__init__(*args, **kwargs) |
||||
for form in self.forms: |
||||
form.empty_permitted = False |
||||
|
||||
@login_required |
||||
def conference_add(request): |
||||
HallFormSet = formset_factory(HallForm) |
||||
if request.POST.get('key'): |
||||
key = request.POST['key'] |
||||
else: |
||||
key = random.getrandbits(128) |
||||
file_form = FileModelForm(initial={'key': key}) |
||||
|
||||
if request.POST: |
||||
form = ConferenceForm(request.POST) |
||||
formset = HallFormSet(request.POST) |
||||
if form.is_valid() and formset.is_valid(): |
||||
place_conference = form.save() |
||||
|
||||
for item in formset.forms: |
||||
if item.is_valid() and item.has_changed(): |
||||
hall = item.save(commit=False) |
||||
hall.place_conference = place_conference |
||||
hall.save() |
||||
|
||||
return HttpResponseRedirect ('/place/conference/all') |
||||
else: |
||||
form = ConferenceForm(initial={'key': key}) |
||||
formset = HallFormSet() |
||||
|
||||
args = {} |
||||
args.update(csrf(request)) |
||||
|
||||
args['languages'] = settings.LANGUAGES |
||||
args['form'] = form |
||||
args['formset'] = formset |
||||
args['file_form'] = file_form |
||||
args['files'] = TmpFile.objects.filter(key=key) |
||||
|
||||
return render_to_response('place_conference_add.html', args) |
||||
|
||||
@login_required |
||||
def exposition_add(request): |
||||
if request.POST.get('key'): |
||||
key = request.POST['key'] |
||||
else: |
||||
key = random.getrandbits(128) |
||||
file_form = FileModelForm(initial={'key': key}) |
||||
|
||||
if request.POST: |
||||
form = ExpositionForm(request.POST) |
||||
if form.is_valid(): |
||||
form.save() |
||||
return HttpResponseRedirect('/place/exposition/all') |
||||
else: |
||||
form = ExpositionForm(initial={'key': key}) |
||||
|
||||
args = {} |
||||
args.update(csrf(request)) |
||||
|
||||
args['languages'] = settings.LANGUAGES |
||||
args['form'] = form |
||||
args['file_form'] = file_form |
||||
args['files'] = TmpFile.objects.filter(key=key) |
||||
|
||||
return render_to_response('place_exposition_add.html', args) |
||||
|
||||
@login_required |
||||
def conference_change(request, conference_id): |
||||
if request.POST: |
||||
HallFormSet = formset_factory(HallForm) |
||||
form = ConferenceForm(request.POST) |
||||
form.fields['city'].widget.choices = [(item.id, item.name) for item in City.objects.filter(country=request.POST['country'])] |
||||
formset = HallFormSet(request.POST) |
||||
if form.is_valid() and formset.is_valid(): |
||||
place_conference = form.save(conference_id) |
||||
Hall.objects.filter(place_conference=conference_id).delete() |
||||
for item in formset.forms: |
||||
if item.is_valid() and item.has_changed(): |
||||
hall = item.save(commit=False) |
||||
hall.place_conference = place_conference |
||||
hall.save() |
||||
|
||||
return HttpResponseRedirect('/place/conference/all') |
||||
else: |
||||
#check if conference_id exists else redirect to the list of place of conference |
||||
#try: |
||||
HallFormSet = modelformset_factory(Hall, form=HallForm, exclude=('place_conference',)) |
||||
place = PlaceConference.objects.get(id=conference_id) |
||||
|
||||
#fill form with data from database |
||||
data = {'type': place.type, 'latitude': place.google_latitude, 'longitude': place.google_longitude, |
||||
'phone': place.phone, 'fax': place.fax, 'web_page': place.web_page, 'email': place.email, |
||||
'total_capacity': place.total_capacity, 'amount_halls': place.amount_halls, |
||||
'exposition_hall': place.exposition_hall, 'exp_hall_area': place.exp_hall_area, |
||||
'wifi': place.wifi, 'multimedia_equipment': place.multimedia_equipment, 'conference_call':place.conference_call, |
||||
'translate_equipment': place.translate_equipment, 'banquet_hall': place.banquet_hall, |
||||
'catering': place.catering, 'hotel': place.hotel} |
||||
|
||||
if place.country: |
||||
data['country'] = place.country.id |
||||
if place.city: |
||||
data['city'] = place.city.id |
||||
#data from translated fields |
||||
for code, name in settings.LANGUAGES: |
||||
obj = PlaceConference._meta.translations_model.objects.get(language_code = code,master__id=conference_id) #access to translated fields |
||||
data['name_%s'%code] = obj.name |
||||
data['description_%s'%code] = obj.description |
||||
data['adress_%s'%code] = obj.adress |
||||
data['hall_capacity_%s'%code] = obj.hall_capacity |
||||
data['title_%s'%code] = obj.title |
||||
data['keywords_%s'%code] = obj.keywords |
||||
data['descriptions_%s'%code] = obj.descriptions |
||||
|
||||
form = ConferenceForm(data) |
||||
form.fields['city'].widget.choices = [(item.id, item.name) for item in City.objects.filter(country=place.country.id)] |
||||
|
||||
halls = Hall.objects.filter(place_conference=conference_id) |
||||
formset = HallFormSet(queryset=halls) |
||||
|
||||
#except: |
||||
# return HttpResponseRedirect('/place/conference/all') |
||||
|
||||
args = {} |
||||
args.update(csrf(request)) |
||||
args['languages'] = settings.LANGUAGES |
||||
args['form'] = form |
||||
args['formset'] = formset |
||||
args['conference_id'] = conference_id |
||||
|
||||
return render_to_response('place_conference_add.html', args) |
||||
|
||||
@login_required |
||||
def exposition_change(request, exposition_id): |
||||
if request.POST: |
||||
form = ExpositionForm(request.POST) |
||||
if form.is_valid(): |
||||
form.save(exposition_id) |
||||
return HttpResponseRedirect('/place/exposition/all') |
||||
else: |
||||
#check if conference_id exists else redirect to the list of place of conference |
||||
try: |
||||
place = PlaceExposition.objects.get(id=exposition_id) |
||||
|
||||
#fill form with data from database |
||||
data= {'type': place.type, 'latitude': place.google_latitude, 'longitude': place.google_longitude, |
||||
'phone': place.phone, 'fax': place.fax, 'web_page': place.web_page, 'email': place.email, |
||||
'foundation_year': place.foundation_year, 'total_area': place.total_area, |
||||
'closed_area': place.closed_area, 'open_area': place.open_area, |
||||
'total_pavilions': place.total_pavilions, 'total_halls': place.total_halls, 'wifi':place.wifi, |
||||
'bank': place.bank, 'children_room': place.children_room, |
||||
'disabled_service': place.disabled_service, 'conference_centre': place.conference_centre, |
||||
'business_centre': place.business_centre, 'online_registration': place.online_registration, |
||||
'cafe': place.cafe, 'terminals': place.terminals, 'parking': place.parking, |
||||
'press_centre': place.press_centre, 'mobile_application': place.mobile_application} |
||||
|
||||
if place.country: |
||||
data['country'] = place.country.id |
||||
if place.city: |
||||
data['city'] = place.city.id |
||||
#data from translated fields |
||||
for code, name in settings.LANGUAGES: |
||||
obj = PlaceExposition._meta.translations_model.objects.get(language_code = code,master__id=exposition_id) #access to translated fields |
||||
data['name_%s'%code] = obj.name |
||||
data['description_%s'%code] = obj.description |
||||
data['adress_%s'%code] = obj.adress |
||||
data['total_year_action_%s'%code] = obj.total_year_action |
||||
data['title_%s'%code] = obj.title |
||||
data['keywords_%s'%code] = obj.keywords |
||||
data['descriptions_%s'%code] = obj.descriptions |
||||
|
||||
form = ExpositionForm(data) |
||||
except: |
||||
return HttpResponseRedirect('/place/exposition/all') |
||||
|
||||
args = {} |
||||
args.update(csrf(request)) |
||||
|
||||
args['languages'] = settings.LANGUAGES |
||||
args['form'] = form |
||||
args['exposition_id'] = exposition_id |
||||
|
||||
return render_to_response('place_exposition_add.html', args) |
||||
|
||||
@login_required |
||||
def conference_all(request): |
||||
conferences = PlaceConference.objects.all() |
||||
return render_to_response('place_conference_all.html', {'conferences': conferences}) |
||||
|
||||
@login_required |
||||
def exposition_all(request): |
||||
expositions = PlaceExposition.objects.all() |
||||
return render_to_response('place_exposition_all.html', {'expositions': expositions}) |
||||
|
||||
@login_required |
||||
def ajax_city(request): |
||||
cities = City.objects.filter(country=request.GET['id']) |
||||
return render_to_response('select.html', {'cities': cities}) |
||||
|
||||
@ -1,12 +1,9 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django.conf.urls import patterns, include, url |
||||
|
||||
urlpatterns = patterns('', |
||||
url(r'^add.*/$', 'place_conference.views.conference_add'), |
||||
url(r'^change/(.*)/$', 'place_conference.views.conference_change'), |
||||
url(r'^all/$', 'place_conference.views.conference_all'), |
||||
|
||||
|
||||
url(r'^conference/ajax_city/$', 'place.views.ajax_city'), |
||||
|
||||
urlpatterns = patterns('place_conference.views', |
||||
url(r'^add.*/$', 'conference_add'), |
||||
url(r'^delete/(?P<url>.*)/$', 'conference_delete'), |
||||
url(r'^change/(?P<url>.*)/$', 'conference_change'), |
||||
url(r'^all/$', 'conference_all'), |
||||
) |
||||
@ -1,12 +1,9 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django.conf.urls import patterns, include, url |
||||
|
||||
urlpatterns = patterns('', |
||||
url(r'^add.*/$', 'place_exposition.views.exposition_add'), |
||||
url(r'^change/(.*)/$', 'place_exposition.views.exposition_change'), |
||||
url(r'^all/$', 'place_exposition.views.exposition_all'), |
||||
|
||||
|
||||
url(r'^conference/ajax_city/$', 'place.views.ajax_city'), |
||||
|
||||
urlpatterns = patterns('place_exposition.views', |
||||
url(r'^add.*/$', 'exposition_add'), |
||||
url(r'^delete/(?P<url>.*)/$', 'exposition_delete'), |
||||
url(r'^change/(?P<url>.*)/$', 'exposition_change'), |
||||
url(r'^all/$', 'exposition_all'), |
||||
) |
||||
@ -1,8 +1,9 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django.conf.urls import patterns, include, url |
||||
|
||||
urlpatterns = patterns('', |
||||
url(r'^add.*/$', 'seminar.views.seminar_add'), |
||||
url(r'^change/(.*)/$', 'seminar.views.seminar_change'), |
||||
url(r'^all/$', 'seminar.views.seminar_all'), |
||||
urlpatterns = patterns('seminar.views', |
||||
url(r'^add.*/$', 'seminar_add'), |
||||
url(r'^delete/(?P<url>.*)/$', 'seminar_delete'), |
||||
url(r'^change/(?P<url>.*)/$', 'seminar_change'), |
||||
url(r'^all/$', 'seminar_all'), |
||||
) |
||||
@ -1,12 +1,13 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django.conf.urls import patterns, include, url |
||||
|
||||
urlpatterns = patterns('', |
||||
url(r'^add.*/$', 'service.views.service_add'), |
||||
url(r'^change/(.*)/$', 'service.views.service_change'), |
||||
url(r'^all/$', 'service.views.service_all'), |
||||
urlpatterns = patterns('service.views', |
||||
url(r'^add.*/$', 'service_add'), |
||||
url(r'^delete/(?P<url>.*)/$', 'service_delete'), |
||||
url(r'^change/(?P<url>.*)/$', 'service_change'), |
||||
url(r'^all/$', 'service_all'), |
||||
#ajax |
||||
url(r'^get_city/$', 'service.views.get_city'), |
||||
url(r'^get_country/$', 'service.views.get_country'), |
||||
url(r'^get_city/$', 'get_city'), |
||||
url(r'^get_country/$', 'get_country'), |
||||
|
||||
) |
||||
@ -1,11 +1,13 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django.conf.urls import patterns, include, url |
||||
|
||||
urlpatterns = patterns('', |
||||
url(r'^theme/add.*/$', 'theme.views.theme_add'), |
||||
url(r'^tag/add.*/$', 'theme.views.tag_add'), |
||||
url(r'^theme/change/(?P<theme_id>\d+).*/$', 'theme.views.theme_change'), |
||||
url(r'^tag/change/(?P<tag_id>\d+).*/$', 'theme.views.tag_change'), |
||||
url(r'^theme/all/$', 'theme.views.theme_all'), |
||||
url(r'^tag/all/$', 'theme.views.tag_all'), |
||||
urlpatterns = patterns('theme.views', |
||||
url(r'^theme/add.*/$', 'theme_add'), |
||||
url(r'^tag/add.*/$', 'tag_add'), |
||||
url(r'^theme/delete/(?P<theme_id>\d+)/$', 'theme_delete'), |
||||
url(r'^tag/delete/(?P<tag_id>\d+)/$', 'tag_delete'), |
||||
url(r'^theme/change/(?P<theme_id>\d+).*/$', 'theme_change'), |
||||
url(r'^tag/change/(?P<tag_id>\d+).*/$', 'tag_change'), |
||||
url(r'^theme/all/$', 'theme_all'), |
||||
url(r'^tag/all/$', 'tag_all'), |
||||
) |
||||
@ -1,8 +1,9 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django.conf.urls import patterns, include, url |
||||
|
||||
urlpatterns = patterns('', |
||||
url(r'^add.*/$', 'webinar.views.webinar_add'), |
||||
url(r'^change/(.*)/$', 'webinar.views.webinar_change'), |
||||
url(r'^all/$', 'webinar.views.webinar_all'), |
||||
urlpatterns = patterns('webinar.views', |
||||
url(r'^add.*/$', 'webinar_add'), |
||||
url(r'^delete/(?P<url>.*)/$', 'webinar_delete'), |
||||
url(r'^change/(?P<url>.*)/$', 'webinar_change'), |
||||
url(r'^all/$', 'webinar_all'), |
||||
) |
||||
|
||||
Loading…
Reference in new issue