|
|
|
|
@ -31,6 +31,7 @@ from django.conf import settings |
|
|
|
|
from haystack.query import SearchQuerySet, RelatedSearchQuerySet, SQ |
|
|
|
|
|
|
|
|
|
from functions.model_utils import EnumChoices |
|
|
|
|
from functions.model_mixin import get_dates |
|
|
|
|
from exposition.models import Exposition |
|
|
|
|
from conference.models import Conference |
|
|
|
|
from theme.models import Theme, Tag |
|
|
|
|
@ -209,20 +210,6 @@ class FilterForm(forms.Form): |
|
|
|
|
city = CountModelMultipleChoiceField( |
|
|
|
|
label=_(u'Города'), required=False, cache_choices=True, |
|
|
|
|
queryset=City.objects.language().values('pk', 'name')) |
|
|
|
|
price = FilterTypedMultipleChoiceField( |
|
|
|
|
label=_(u'Стоимость'), coerce=int, |
|
|
|
|
choices=PRICE, |
|
|
|
|
required=False, widget=FilterCheckboxSelectMultiple(), |
|
|
|
|
# help_text=_(u'За 1 м<sub>2</sub> необорудованной площади') |
|
|
|
|
) |
|
|
|
|
members = FilterTypedMultipleChoiceField( |
|
|
|
|
label=_(u'Участники'), coerce=int, |
|
|
|
|
choices=MEMBERS, |
|
|
|
|
required=False, widget=FilterCheckboxSelectMultiple()) |
|
|
|
|
visitors = FilterTypedMultipleChoiceField( |
|
|
|
|
label=_(u'Посетители'), coerce=int, |
|
|
|
|
choices=VISITORS, |
|
|
|
|
required=False, widget=FilterCheckboxSelectMultiple()) |
|
|
|
|
year = forms.RegexField(r'^(?P<year>\d{4})$', max_length=4, min_length=4, |
|
|
|
|
required=False, widget=forms.HiddenInput()) |
|
|
|
|
default_month = forms.CharField(max_length=3, min_length=3, |
|
|
|
|
@ -239,6 +226,25 @@ class FilterForm(forms.Form): |
|
|
|
|
date_to = forms.DateField(required=False, input_formats=('%d.%m.%Y',), |
|
|
|
|
widget=forms.DateInput(attrs={'class': 'date', 'id': 'dateTo', |
|
|
|
|
'placeholder': _(u'дд.мм.гггг')})) |
|
|
|
|
price = FilterTypedMultipleChoiceField( |
|
|
|
|
label=_(u'Стоимость'), coerce=int, |
|
|
|
|
choices=PRICE, |
|
|
|
|
required=False, widget=FilterCheckboxSelectMultiple(), |
|
|
|
|
# help_text=_(u'За 1 м<sub>2</sub> необорудованной площади') |
|
|
|
|
) |
|
|
|
|
members = FilterTypedMultipleChoiceField( |
|
|
|
|
label=_(u'Участники'), coerce=int, |
|
|
|
|
choices=MEMBERS, |
|
|
|
|
required=False, widget=FilterCheckboxSelectMultiple()) |
|
|
|
|
visitors = FilterTypedMultipleChoiceField( |
|
|
|
|
label=_(u'Посетители'), coerce=int, |
|
|
|
|
choices=VISITORS, |
|
|
|
|
required=False, widget=FilterCheckboxSelectMultiple()) |
|
|
|
|
rating = FilterTypedMultipleChoiceField( |
|
|
|
|
label=_(u'Рейтинги'), coerce=int, |
|
|
|
|
choices=[], |
|
|
|
|
required=False, widget=FilterCheckboxSelectMultiple()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs): |
|
|
|
|
super(FilterForm, self).__init__(*args, **kwargs) |
|
|
|
|
@ -264,6 +270,11 @@ class FilterForm(forms.Form): |
|
|
|
|
else: |
|
|
|
|
self.fields[field].choice_cache = choices |
|
|
|
|
|
|
|
|
|
def get_dates(self): |
|
|
|
|
if not (self.cleaned_data.get('date_from') or self.cleaned_data.get('date_to')): |
|
|
|
|
return None |
|
|
|
|
return get_dates(self.cleaned_data.get('date_from'), self.cleaned_data.get('date_to')) |
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
def month_choices(cls): |
|
|
|
|
month = datetime.today().month |
|
|
|
|
|