Make simple wizard - add feature to upload few files

remotes/origin/1203
Ivan Kovalkovskyi 11 years ago
parent 5d4d737f14
commit ed1353299a
  1. 432
      templates/client/wizard/second_step.html
  2. 203
      templates/client/wizard/third_step.html
  3. 9
      wizard/forms.py
  4. 7
      wizard/models.py
  5. 7
      wizard/urls.py
  6. 150
      wizard/views.py

@ -6,305 +6,297 @@
<h1>Добавить событие</h1> <h1>Добавить событие</h1>
</div> </div>
<div class="page-body clearfix"> <div class="page-body clearfix">
{{ wizard.form.media }} <form action="" method="post">{% csrf_token %}
<div class="set-sect p-form adm-form passed">
<div class="set-sect-title clearfix">
<h3>Шаг 1. Основная информация</h3>
<div class="afh-right"> {{ wizard.form.media }}
<div class="set-sect p-form adm-form passed">
<div class="set-sect-title clearfix">
<h3>Шаг 1. Основная информация</h3>
<a class="button icon-edit" href="#">изменить</a> <div class="afh-right">
<button name="wizard_goto_step" type="submit" class="button icon-edit"
value="{{ wizard.steps.prev }}">изменить
</button>
</div>
</div> </div>
</div> </div>
</div>
<div class="set-sect p-form adm-form"> <div class="set-sect p-form adm-form">
<div class="set-sect-title clearfix"> <div class="set-sect-title clearfix">
<h3>Шаг 2. Статистика и условия участия</h3> <h3>Шаг 2. Статистика и условия участия</h3>
<div class="afh-right"> <div class="afh-right">
<div class="sst-info"><b>+ 0,9 баллов</b> к рейтингу</div> <div class="sst-info"><b>+ 0,9 баллов</b> к рейтингу</div>
</div>
</div> </div>
</div>
<form action="" method="post">{% csrf_token %} {{ wizard.management_form }}
{{ wizard.management_form }} {% if wizard.form.forms %}
{% if wizard.form.forms %} {{ wizard.form.management_form }}
{{ wizard.form.management_form }} {% for form in wizard.form.forms %}
{% for form in wizard.form.forms %} {{ form }}
{{ form }} {% endfor %}
{% endfor %} {% else %}
{% else %}
{% with wizard.form as form %} {% with wizard.form as form %}
<hr/> <hr/>
<div class="mfs-additional mf-stat"> <div class="mfs-additional mf-stat">
<div class="mf-line mf-prod mf-short-input"> <div class="mf-line mf-prod mf-short-input">
<label>Год основания:</label> <label>Год основания:</label>
{{ form.found_year }} {{ form.found_year }}
<div class="mf-field"> <div class="mf-field">
</div> </div>
</div> </div>
<div class="mf-stat-item"> <div class="mf-stat-item">
<hr/> <hr/>
<div class="mf-line mf-prod"> <div class="mf-line mf-prod">
<label class="h3">Статистика за</label> <label class="h3">Статистика за</label>
<div class="mf-field"> <div class="mf-field">
<div class="mf-year"> <div class="mf-year">
{{ form.statistic_year }} {{ form.statistic_year }}
</div> </div>
<div class="mf-stat-data"> <div class="mf-stat-data">
<div class="sd-visitors"> <div class="sd-visitors">
{{ form.visitors }} {{ form.visitors }}
</div> </div>
<div class="sd-participants"> <div class="sd-participants">
{{ form.partisipants }} {{ form.partisipants }}
</div> </div>
<div class="sd-area">
{{ form.square }}
м²
</div>
</div>
<div class="sd-area">
{{ form.square }}
м²
</div> </div>
</div> </div>
</div> <div class="mf-line mf-prod mf-stat-countries">
</div> <label>Страны:</label>
<div class="mf-line mf-prod mf-stat-countries">
<label>Страны:</label>
<div class="mf-field"> <div class="mf-field">
<div class="csb-selected-items"></div> <div class="csb-selected-items"></div>
<div class="csb-menu-wrap"> <div class="csb-menu-wrap">
<div class="scroll-container csb-menu"> <div class="scroll-container csb-menu">
<div class="scroll-content clearfix"> <div class="scroll-content clearfix">
{{ form.countries }} {{ form.countries }}
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
</div> </div>
<div class="mf-stat-add-button">
<a class="button big icon-add" href="#">добавить данные за другой период</a>
</div>
</div>
<hr/>
<h2>Стоимость посещения и участия</h2>
<div class="e-price-wrap"> <div class="mf-stat-add-button">
<div class="epr-layout"> <a class="button big icon-add" href="#">добавить данные за другой период</a>
</div>
<div class="eprl-col"> </div>
<div class="eprl-col-wrap">
<div class="epr-subtitle">Стоимость билетов</div> <hr/>
<div class="tp-wrap"> <h2>Стоимость посещения и участия</h2>
<ul class="pr-list"> <div class="e-price-wrap">
<div class="epr-layout">
<li> <div class="eprl-col">
{{ form.one_day }} <div class="eprl-col-wrap">
<select name="oneDayCurrency1">
<option value="rur">руб</option>
<option value="usd">usd</option>
<option value="eur">eur</option>
</select>
</li>
<li> <div class="epr-subtitle">Стоимость билетов</div>
{{ form.all_days }}
<select name="allDaysCurrency1">
<option value="rur">руб</option>
<option value="usd">usd</option>
<option value="eur">eur</option>
</select>
</li>
</ul> <div class="tp-wrap">
<div class="tp-descr">Предварительная регистрация</div> <ul class="pr-list">
</div> <li>
{{ form.one_day }}
<select name="oneDayCurrency1">
<option value="rur">руб</option>
<option value="usd">usd</option>
<option value="eur">eur</option>
</select>
</li>
<hr/> <li>
{{ form.all_days }}
<select name="allDaysCurrency1">
<option value="rur">руб</option>
<option value="usd">usd</option>
<option value="eur">eur</option>
</select>
</li>
<div class="tp-wrap"> </ul>
<ul class="pr-list"> <div class="tp-descr">Предварительная регистрация</div>
<li> </div>
{{ form.pre_one_day }}
<select name="oneDayCurrency2">
<option value="1">руб</option>
<option value="2">usd</option>
<option value="3">eur</option>
</select>
</li>
<li>
{{ form.pre_all_days }}
<select name="allDaysCurrency2">
<option value="1">руб</option>
<option value="2">usd</option>
<option value="3">eur</option>
</select>
</li>
</ul> <hr/>
<div class="tp-descr grey">Регистрация на&nbsp;стойке</div> <div class="tp-wrap">
</div> <ul class="pr-list">
</div> <li>
{{ form.pre_one_day }}
<select name="oneDayCurrency2">
<option value="1">руб</option>
<option value="2">usd</option>
<option value="3">eur</option>
</select>
</li>
</div> <li>
{{ form.pre_all_days }}
<select name="allDaysCurrency2">
<option value="1">руб</option>
<option value="2">usd</option>
<option value="3">eur</option>
</select>
</li>
<div class="eprl-col"> </ul>
<div class="eprl-col-wrap">
<div class="epr-subtitle">Стоимость аренды 1м²</div>
<ul class="pr-list">
<li>
{{ form.equiped }}
<select name="areaCurrency1">
<option value="1">руб</option>
<option value="2">usd</option>
<option value="3">eur</option>
</select>
</li>
<li>
{{ form.unequiped }}
<select name="areaCurrency2">
<option value="1">руб</option>
<option value="2">usd</option>
<option value="3">eur</option>
</select>
</li>
<li>
{{ form.open_square }}
<select name="areaCurrency3">
<option value="1">руб</option>
<option value="2">usd</option>
<option value="3">eur</option>
</select>
</li>
</ul>
<hr/> <div class="tp-descr grey">Регистрация на&nbsp;стойке</div>
<div class="mf-line mf-min-area"> </div>
<label>Минимальная площадь:</label>
<div class="mf-field">
{{ form.min_square }}
м²
</div> </div>
</div> </div>
<hr/> <div class="eprl-col">
<div class="eprl-col-wrap">
<div class="epr-subtitle">Стоимость аренды 1м²</div>
<ul class="pr-list">
<li>
{{ form.equiped }}
<select name="areaCurrency1">
<option value="1">руб</option>
<option value="2">usd</option>
<option value="3">eur</option>
</select>
</li>
<li>
{{ form.unequiped }}
<select name="areaCurrency2">
<option value="1">руб</option>
<option value="2">usd</option>
<option value="3">eur</option>
</select>
</li>
<li>
{{ form.open_square }}
<select name="areaCurrency3">
<option value="1">руб</option>
<option value="2">usd</option>
<option value="3">eur</option>
</select>
</li>
</ul>
<hr/>
<div class="mf-line mf-min-area">
<label>Минимальная площадь:</label>
<div class="mf-field">
{{ form.min_square }}
м²
</div>
</div>
<div class="mf-line mf-reg-payment"> <hr/>
<label>Регистрационный взнос:</label>
<div class="mf-field"> <div class="mf-line mf-reg-payment">
{{ form.registration_depos }} <label>Регистрационный взнос:</label>
<select name="areaCurrency3">
<option value="1">руб</option>
<option value="2">usd</option>
<option value="3">eur</option>
</select>
</div>
</div>
<hr/> <div class="mf-field">
{{ form.registration_depos }}
<select name="areaCurrency3">
<option value="1">руб</option>
<option value="2">usd</option>
<option value="3">eur</option>
</select>
</div>
</div>
<div class="mf-line mf-deadline"> <hr/>
<label>Крайний срок подачи заявки:</label>
<div class="mf-field"> <div class="mf-line mf-deadline">
<div class="period"> <label>Крайний срок подачи заявки:</label>
<div class="pwf-field">
{{ form.deadline_date }} <div class="mf-field">
<div class="period">
<div class="pwf-field">
{{ form.deadline_date }}
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> <hr/>
</div>
<hr/> <div class="a-bot-buttons-line clearfix">
<div class="a-bot-buttons-line clearfix"> <div class="abb-left">
<div class="mfpl-button-line">
{# <div class="mfpl-button">#}
{# <a class="button big grey a-more" href="#">пропустить этот шаг</a>#}
{# </div>#}
<div class="abb-left"> <div class="mfpl-text">
<div class="mfpl-button-line"> <p>более полная информация повышает рейтинг вашего мероприятия и позволяет
<div class="mfpl-button"> ранжировать
<a class="button big grey a-more" href="#">пропустить этот шаг</a> его выше других</p>
</div> </div>
</div>
<div class="mfpl-text">
<p>более полная информация повышает рейтинг вашего мероприятия и позволяет ранжировать
его выше других</p>
</div> </div>
</div> <button class="button big orange a-more" type="submit">Дале</button>
</div> </div>
{% if wizard.steps.prev %}
<button class="button big orange a-more" name="wizard_goto_step" type="submit"
value="{{ wizard.steps.first }}">"first step"
</button>
<button class="button big orange a-more" name="wizard_goto_step" type="submit"
value="{{ wizard.steps.prev }}"> "prev step"
</button>
{% endif %}
<button class="button big orange a-more" type="submit" >Дале</button>
</div> </div>
</form> <div class="set-sect p-form adm-form passed">
<div class="set-sect-title clearfix">
<h3>Шаг 3. Добавление фото</h3>
</div>
<div class="set-sect p-form adm-form passed">
<div class="set-sect-title clearfix">
<h3>Шаг 3. Добавление фото</h3>
<div class="afh-right"> </div>
<a class="button icon-edit" href="#">изменить</a>
</div> </div>
</div> </form>
</div> </div>
</div>
{% endwith %} {% endwith %}
{% endif %} {% endif %}
{% endblock %} {% endblock %}

@ -2,114 +2,147 @@
{% block styles %} {% block styles %}
<style> <style>
.thumb { .thumb {
height: 175px; height: 175px;
border: 1px solid #000; border: 1px solid #000;
} }
</style> </style>
{% endblock %} {% endblock %}
{% block content_list %} {% block content_list %}
{{ wizard.form.media }}
<div class="page-title">
<div class="page-title"> <h1>Добавить событие</h1>
<h1>Добавить событие</h1>
</div>
<div class="page-body clearfix">
<div class="set-sect p-form adm-form passed">
<div class="set-sect-title clearfix">
<h3>Шаг 1. Основная информация</h3>
<div class="afh-right">
<a class="button icon-edit" href="#">изменить</a>
</div>
</div>
</div> </div>
<div class="set-sect p-form adm-form passed">
<div class="set-sect-title clearfix">
<h3>Шаг 2. Статистика и условия участия</h3>
<div class="afh-right">
<a class="button icon-edit" href="#">изменить</a>
</div>
</div>
</div>
<div class="set-sect p-form adm-form">
<div class="set-sect-title clearfix">
<h3>Шаг 3. Добавление фото</h3>
<div class="afh-right">
<div class="sst-info"><b>+ 1,2 балла</b> к рейтингу</div>
</div>
</div>
<div class="page-body clearfix">
<form action="" method="post" enctype="multipart/form-data">{% csrf_token %} <form action="" method="post" enctype="multipart/form-data">{% csrf_token %}
<hr />
<div class="mf-photos-list">
<div class="mfpl-button-line">
<div class="mfpl-button">
<input class="button big icon-camera" value="выберите фотографии" type="file" id="files" name="files[]" multiple />
</div>
<div class="mfpl-text"> <div class="set-sect p-form adm-form passed">
<p>более полная информация повышает рейтинг вашего мероприятия и позволяет ранжировать его выше других</p> <div class="set-sect-title clearfix">
<h3>Шаг 1. Основная информация</h3>
<div class="afh-right">
<button name="wizard_goto_step" type="submit" class="button icon-edit"
value="{{ wizard.steps.first }}">изменить
</button>
</div> </div>
</div>
</div>
</div> </div>
<div class="set-sect p-form adm-form passed">
<ul id="list"></ul> <div class="set-sect-title clearfix">
<div class="a-bot-buttons-line clearfix"> <h3>Шаг 2. Статистика и условия участия</h3>
<div class="abb-left"> <div class="afh-right">
<a class="button big grey a-more" href="#">пропустить этот шаг</a> <button name="wizard_goto_step" type="submit" class="button icon-edit"
value="{{ wizard.steps.prev }}">изменить
</button>
</div>
</div> </div>
</div>
<div class="set-sect p-form adm-form">
<div class="set-sect-title clearfix">
<h3>Шаг 3. Добавление фото</h3>
<div class="abb-right"> <div class="afh-right">
<button class="button big orange a-more" type="submit">далее</button> <div class="sst-info"><b>+ 1,2 балла</b> к рейтингу</div>
</div>
</div> </div>
{{ form.errors }}
{{ wizard.management_form }}
{% if wizard.form.forms %}
{{ wizard.form.management_form }}
{% for form in wizard.form.forms %}
{{ form }}
{% endfor %}
{% else %}
{% with wizard.form as form %}
<hr/>
<div class="mf-photos-list">
<div class="mfpl-button-line">
<div class="mfpl-button">
{{ form.attachments }}
</div>
<div class="mfpl-text">
<p>более полная информация повышает рейтинг вашего мероприятия и позволяет
ранжировать его выше других</p>
</div>
</div>
</div> </div>
</form>
</div>
</div> <ul id="list"></ul>
<script type="text/javascript"> <div class="a-bot-buttons-line clearfix">
function handleFileSelect(evt) {
var files = evt.target.files; // FileList object
// Loop through the FileList and render image files as thumbnails. <div class="abb-left">
for (var i = 0, f; f = files[i]; i++) { <button class="button big grey a-more" type="submit">пропустить этот шаг</button>
</div>
// Only process image files. <div class="abb-right">
if (!f.type.match('image.*')) { <button id="next" class="button big orange a-more" type="submit">далее</button>
continue; </div>
} <div id="res"> </div>
var reader = new FileReader(); </div>
{% endwith %}
{% endif %}
</div>
</form>
// Closure to capture the file information. </div>
reader.onload = (function(theFile) { <!-- for response debugging -->
return function(e) { {% comment %} <script>
// Render thumbnail. $("#next").click(function(e){
var div = document.createElement('div'); e.preventDefault();
div.innerHTML = ['<li><div class="mfpli-pict"> <img class="thumb" src="', e.target.result, $.ajax({url: '/wizard/ajax/', success: function(result){
$("#res").html(result);
}});
});
</script>{% endcomment %}
<script type="text/javascript">
var cnt = 0;
function handleFileSelect(evt) {
var files = evt.target.files; // FileList object
// Loop through the FileList and render image files as thumbnails.
for (var i = 0, f; f = files[i]; i++) {
// Only process image files.
if (!f.type.match('image.*')) {
continue;
}
var reader = new FileReader();
// Closure to capture the file information.
reader.onload = (function (theFile) {
return function (e) {
// Render thumbnail.
var div = document.createElement('div');
div.innerHTML = ['<li><div class="mfpli-pict"> <img class="thumb" src="', e.target.result,
'" title="', theFile.name, '" title="', theFile.name,
'"/></div>','<div class="mfpli-body"> <div class="mf-line full-width"> <div class="mf-field"> <textarea name="pdescr', '"/></div>', '<div class="mfpli-body"> <div class="mf-line full-width"> <div class="mf-field"> <textarea name="pdescr_',
i.toString(),'" cols="30" rows="10" placeholder="Описание"></textarea></div></div>', cnt.toString(), '" cols="30" rows="10" placeholder="Описание"></textarea></div></div>',
'</li>'].join(''); '</li>'].join('');
document.getElementById('list').insertBefore(div, null); cnt +=1 ;
}; document.getElementById('list').insertBefore(div, null);
})(f); };
})(f);
// Read in the image file as a data URL.
reader.readAsDataURL(f); // Read in the image file as a data URL.
} reader.readAsDataURL(f);
} }
}
document.getElementById('files').addEventListener('change', handleFileSelect, false);
</script> document.getElementById('files').addEventListener('change', handleFileSelect, false);
</script>
{% endblock %} {% endblock %}

@ -4,6 +4,8 @@ from theme.models import Theme, Tag
from place_exposition.models import PlaceExposition from place_exposition.models import PlaceExposition
from city.models import City from city.models import City
from country.models import Country from country.models import Country
from multiupload.fields import MultiFileField, MultiFileInput
choices = ((0, ''), (1.0, u'Ежегодно'), (2.0, u'2 раза в год'), (3.0, u'3 раза в год'), (4.0, u'4 раза в год'), choices = ((0, ''), (1.0, u'Ежегодно'), (2.0, u'2 раза в год'), (3.0, u'3 раза в год'), (4.0, u'4 раза в год'),
(5.0, u'5 раз в год'), (0.5, u'Раз в 2 года'), ( (5.0, u'5 раз в год'), (0.5, u'Раз в 2 года'), (
@ -64,3 +66,10 @@ class ExpoForm2(forms.Form):
deadline_date = forms.DateField(widget=forms.TextInput(attrs={'placeholder':'дд.мм.гг'})) deadline_date = forms.DateField(widget=forms.TextInput(attrs={'placeholder':'дд.мм.гг'}))
class ExpoForm3(forms.Form):
attachments = MultiFileField(min_num=0, max_num=2, max_file_size=1024*1024*5, widget=MultiFileInput(
attrs={'class':'button big icon-camera', 'value':u'выберите фотографии', 'id':'files'}
))
formlist = [ExpoForm1, ExpoForm2, ExpoForm3]

@ -1,3 +1,8 @@
from django.db import models from django.db import models
from django.conf import settings
import os
# Create your models here. # Create your models here.
class Attachment(models.Model):
file = models.FileField(upload_to=os.path.join(settings.MEDIA_ROOT,'attachments_files'))

@ -1,9 +1,8 @@
from django.conf.urls import patterns, url, include from django.conf.urls import patterns, url, include
from wizard.forms import ExpoForm1, ExpoForm2 from wizard.views import wizard_view
from wizard.views import ExpoWizard, add_photo_view
urlpatterns = patterns('', urlpatterns = patterns('',
url(r'^add-photo/', add_photo_view, name="add-photo"), url(r'^ajax/$', 'wizard.views.ajax_view'),
url(r'^$', ExpoWizard.as_view([ExpoForm1, ExpoForm2])) url(r'^$', wizard_view)
) )

@ -1,65 +1,84 @@
from django.shortcuts import render_to_response, render
from django.contrib.formtools.wizard.views import SessionWizardView from django.contrib.formtools.wizard.views import SessionWizardView
from django.core.files.storage import FileSystemStorage from django.core.files.storage import FileSystemStorage
from django.http import HttpResponseRedirect
from django.conf import settings
import os import os
from proj import settings from photologue.models import Photo, Gallery
from wizard import forms
from exposition.models import Exposition, Statistic from exposition.models import Exposition, Statistic
from wizard.models import Attachment
from functions.form_check import translit_with_separator from functions.form_check import translit_with_separator
from django.http import HttpResponseRedirect
# defining different template for every form # defining different template for every form
TEMPLATES = {'0':'client/wizard/first_step.html', '1':'client/wizard/second_step.html'} TEMPLATES = {
'0': 'client/wizard/first_step.html',
'1': 'client/wizard/second_step.html',
'2': 'client/wizard/third_step.html'
}
post = None
files = None
# main view that handle all data from 3 forms(steps) and finally create an Exposition
class ExpoWizard(SessionWizardView): class ExpoWizard(SessionWizardView):
location=os.path.join(settings.MEDIA_ROOT, 'temp', 'files')
location = os.path.join(settings.MEDIA_ROOT, 'temp')
file_storage = FileSystemStorage(location, settings.MEDIA_URL) file_storage = FileSystemStorage(location, settings.MEDIA_URL)
def done(self, form_list, **kwargs): def done(self, form_list, **kwargs):
upload_file = form_list[0].cleaned_data['logo'] upload_logo = form_list[0].cleaned_data.get('logo')
upload_images = self.request.FILES.getlist(u'2-attachments')
data = self.get_all_cleaned_data() data = self.get_all_cleaned_data()
expo = Exposition.objects.language('ru').create(
name = data.get('name'), expo = Exposition.objects.language(self.request.LANGUAGE_CODE).create(
data_begin = data.get('date_start'), name=data.get('name'),
data_end = data.get('date_end'), data_begin=data.get('date_start'),
main_title = data.get('main_title'), data_end=data.get('date_end'),
description = data.get('description'), main_title=data.get('main_title'),
products = data.get('products'), description=data.get('description'),
country = data.get('country', 1), products=data.get('products'),
city = data.get('city', 1), country=data.get('country', 1),
place = data.get('place', 1), city=data.get('city', 1),
periodic = data.get('periodic'), place=data.get('place', 1),
web_page = data.get('web_site'), periodic=data.get('periodic'),
logo = data.get('logo'), web_page=data.get('web_site'),
logo=data.get('logo'),
foundation_year = data.get('found_year'),
area = data.get('square'), foundation_year=data.get('found_year'),
price_day = '%i %s'%(data.get('one_day'), self.request.POST['oneDayCurrency1']), area=data.get('square'),
price_all = '%i %s'%(data.get('all_days'), self.request.POST['allDaysCurrency1']), price_day=data.get('one_day'),
price_day_bar = '%i %s'%(data.get('pre_one_day'),self.request.POST['oneDayCurrency1']), price_all=data.get('all_days'),
price_all_bar = '%i %s'%(data.get('pre_all_days'),self.request.POST['allDaysCurrency1']), price_day_bar=data.get('pre_one_day'),
price_all_bar=data.get('pre_all_days'),
min_area = data.get('min_square'),
registration_payment = data.get('registration_depos'), min_area=data.get('min_square'),
application_deadline = data.get('deadline_date'), registration_payment=data.get('registration_depos'),
min_closed_area = data.get('unequiped'), application_deadline=data.get('deadline_date'),
min_open_area = data.get('open_square'), min_closed_area=data.get('unequiped'),
min_closed_equipped_area = data.get('equiped'), min_open_area=data.get('open_square'),
url = translit_with_separator(data.get('name')), min_closed_equipped_area=data.get('equiped'),
quality_label= 0, url=translit_with_separator(data.get('name')),
audience = 0 quality_label=0,
audience=0
) )
photos = []
for i, photo in enumerate(upload_images):
photos.append(Photo.objects.language(self.request.LANGUAGE_CODE).create(
image=photo,
title=data.get(u'pdescr_%i' % i, photo.name))
)
for photo in photos:
expo.upload_photo(photo)
expo.tag = [data.get('tag')] expo.tag = [data.get('tag')]
expo.theme = [data.get('theme')] expo.theme = [data.get('theme')]
if data['membership1']: if data['membership1']:
expo.quality_label = (expo.quality_label| Exposition.quality_label.exporating) expo.quality_label = (expo.quality_label | Exposition.quality_label.exporating)
if data['membership2']: if data['membership2']:
expo.quality_label = (expo.quality_label| Exposition.quality_label.rsva) expo.quality_label = (expo.quality_label | Exposition.quality_label.rsva)
if data['membership3']: if data['membership3']:
expo.quality_label = (expo.quality_label| Exposition.quality_label.ufi) expo.quality_label = (expo.quality_label | Exposition.quality_label.ufi)
if data['audience1']: if data['audience1']:
expo.audience = (expo.audience | Exposition.audience.experts) expo.audience = (expo.audience | Exposition.audience.experts)
@ -71,39 +90,34 @@ class ExpoWizard(SessionWizardView):
expo.save() expo.save()
Statistic.objects.language().create( Statistic.objects.language().create(
exposition = expo, exposition=expo,
year = data.get('statistic_year'), year=data.get('statistic_year'),
visitors = data.get('visitors'), visitors=data.get('visitors'),
members = data.get('partisipants'), members=data.get('partisipants'),
countries = data.get('countries'), countries=data.get('countries'),
area = data.get('square') area=data.get('square')
) )
if upload_file: if upload_logo:
self.file_storage.delete(upload_file.name) self.file_storage.delete(upload_logo.name)
if upload_images:
return HttpResponseRedirect("add-photo") for f in upload_images:
# return render_to_response('done.html', { self.file_storage.delete(f.name)
# 'form_data': [form.cleaned_data for form in form_list], return HttpResponseRedirect('/')
# })
def get_template_names(self): def get_template_names(self):
return [TEMPLATES[self.steps.current]] return [TEMPLATES[self.steps.current]]
from django.core.context_processors import csrf
import logging
loger = logging.getLogger(__name__)
PATH_TO_FILE = os.path.join(settings.MEDIA_ROOT, 'exposition_foto/') from wizard.forms import formlist
wizard_view = ExpoWizard.as_view(formlist)
from django.contrib.formtools.wizard.storage.session import SessionStorage
from django.http import HttpResponse
import json
def add_photo_view(request): def ajax_view(request):
if request.POST: form = formlist[2](post, files, prefix='2')
for key, file in request.FILES.items(): return HttpResponse(json.dumps({'posts':post,'files':files}), content_type='application/json')
loger.debug(key)
loger.debug(len(request.FILES))
context = {}
context.update(csrf(request))
return render(request, "client/wizard/third_step.html", context)

Loading…
Cancel
Save