You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
3.7 KiB
89 lines
3.7 KiB
from django.shortcuts import render_to_response
|
|
from django.contrib.formtools.wizard.views import SessionWizardView
|
|
from django.core.files.storage import default_storage, FileSystemStorage
|
|
import os
|
|
from proj import settings
|
|
from wizard import forms
|
|
from exposition.models import Exposition, Statistic
|
|
from functions.form_check import translit_with_separator
|
|
|
|
|
|
# defining different template for every form
|
|
TEMPLATES = {'0':'client/wizard/first_step.html', '1':'client/wizard/second_step.html'}
|
|
|
|
|
|
|
|
class ExpoWizard(SessionWizardView):
|
|
location=os.path.join(settings.MEDIA_ROOT, 'temp', 'files')
|
|
file_storage = FileSystemStorage(location, settings.MEDIA_URL)
|
|
|
|
def done(self, form_list, **kwargs):
|
|
upload_file = form_list[0].cleaned_data['logo']
|
|
data = self.get_all_cleaned_data()
|
|
expo = Exposition.objects.language('ru').create(
|
|
name = data.get('name'),
|
|
data_begin = data.get('date_start'),
|
|
data_end = data.get('date_end'),
|
|
main_title = data.get('main_title'),
|
|
description = data.get('description'),
|
|
products = data.get('products'),
|
|
country = data.get('country', 1),
|
|
city = data.get('city', 1),
|
|
place = data.get('place', 1),
|
|
periodic = data.get('periodic'),
|
|
web_page = data.get('web_site'),
|
|
logo = data.get('logo'),
|
|
|
|
foundation_year = data.get('found_year'),
|
|
area = data.get('square'),
|
|
price_day = '%i %s'%(data.get('one_day'), self.request.POST['oneDayCurrency1']),
|
|
price_all = '%i %s'%(data.get('all_days'), self.request.POST['allDaysCurrency1']),
|
|
price_day_bar = '%i %s'%(data.get('pre_one_day'),self.request.POST['oneDayCurrency1']),
|
|
price_all_bar = '%i %s'%(data.get('pre_all_days'),self.request.POST['allDaysCurrency1']),
|
|
|
|
min_area = data.get('min_square'),
|
|
registration_payment = data.get('registration_depos'),
|
|
application_deadline = data.get('deadline_date'),
|
|
min_closed_area = data.get('unequiped'),
|
|
min_open_area = data.get('open_square'),
|
|
min_closed_equipped_area = data.get('equiped'),
|
|
url = translit_with_separator(data.get('name')),
|
|
quality_label= 0,
|
|
audience = 0
|
|
)
|
|
expo.tag = [data.get('tag')]
|
|
expo.theme = [data.get('theme')]
|
|
if data['membership1']:
|
|
expo.quality_label = (expo.quality_label| Exposition.quality_label.exporating)
|
|
if data['membership2']:
|
|
expo.quality_label = (expo.quality_label| Exposition.quality_label.rsva)
|
|
if data['membership3']:
|
|
expo.quality_label = (expo.quality_label| Exposition.quality_label.ufi)
|
|
|
|
if data['audience1']:
|
|
expo.audience = (expo.audience | Exposition.audience.experts)
|
|
if data['audience2']:
|
|
expo.audience = expo.audience | getattr(Exposition.audience, 'experts and consumers')
|
|
if data['audience3']:
|
|
expo.audience = expo.audience | (getattr(Exposition.audience, 'general public'))
|
|
|
|
expo.save()
|
|
|
|
Statistic.objects.language().create(
|
|
exposition = expo,
|
|
year = data.get('statistic_year'),
|
|
visitors = data.get('visitors'),
|
|
members = data.get('partisipants'),
|
|
countries = data.get('countries'),
|
|
area = data.get('square')
|
|
)
|
|
|
|
if upload_file:
|
|
self.file_storage.delete(upload_file.name)
|
|
return render_to_response('done.html', {
|
|
'form_data': [form.cleaned_data for form in form_list],
|
|
})
|
|
|
|
def get_template_names(self):
|
|
return [TEMPLATES[self.steps.current]]
|
|
|
|
|