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.
56 lines
2.3 KiB
56 lines
2.3 KiB
# -*- coding: utf-8 -*-
|
|
from django import forms
|
|
from django.conf import settings
|
|
|
|
languages = [code for code in settings.LANGUAGES]
|
|
|
|
|
|
|
|
class ImportEventForm(forms.Form):
|
|
excel_file = forms.FileField(label='Выберите файл')
|
|
event = forms.ChoiceField(label='Выберите тип события', choices=[('exposition.Exposition', 'Выставка'),
|
|
('conference.Conference', 'Конференция'),
|
|
('seminar.Seminar', 'Семинар'),
|
|
('webinar.Webinar', 'Вебинар')])
|
|
language = forms.ChoiceField(label='Выберите язык', choices=languages)
|
|
|
|
|
|
from theme.models import Theme
|
|
from country.models import Country
|
|
from django.db.models.loading import get_model
|
|
import StringIO
|
|
from functions.translate import get_all_fields, get_all_verbose_names
|
|
|
|
|
|
class ExportEventForm(forms.Form):
|
|
event = forms.ChoiceField(label='Выберите тип события', choices=[('exposition.Exposition', 'Выставка'),
|
|
('conference.Conference', 'Конференция'),
|
|
('seminar.Seminar', 'Семинар'),
|
|
('webinar.Webinar', 'Вебинар')])
|
|
language = forms.ChoiceField(label='Выберите язык', choices=languages)
|
|
date_from = forms.DateField(label='С')
|
|
date_to = forms.DateField(label='До')
|
|
theme = forms.ModelMultipleChoiceField(label='Направление', queryset=Theme.objects.all(), required=False)
|
|
country = forms.ModelMultipleChoiceField(label='Страны', queryset=Country.objects.all(), required=False)
|
|
|
|
|
|
def clean_theme(self):
|
|
"""
|
|
Set all themes if no theme selected
|
|
"""
|
|
theme = self.cleaned_data.get('theme')
|
|
if not theme:
|
|
theme = Theme.objects.all()
|
|
|
|
return theme
|
|
|
|
|
|
def clean_country(self):
|
|
"""
|
|
Set all countries if no country selected
|
|
"""
|
|
country = self.cleaned_data.get('country')
|
|
if not country:
|
|
country = Country.objects.all()
|
|
|
|
return country |