from haystack.query import SearchQuerySet, SQ
from datetime import date
from django.utils.translation import ugettext_lazy as _
+from settings import FIRST_YEAR
import operator
+
# from telemeta.views.boolean_search import *
instruments = forms.CharField(required=False, label=(_('instruments')), widget=forms.TextInput(attrs={'class': 'form-control', 'type': 'search'}))
collectors = forms.CharField(required=False, label=(_('recordist')), widget=forms.TextInput(attrs={'class': 'form-control', 'type': 'search'}))
+ # @cached_property
+
+
# to create a dynamic list of publishing years
def list_recorded_year():
- list_all_year = []
- list_collect = MediaCollection.objects.all()
- for collect in list_collect:
- if collect.recorded_from_year != 0 and not collect.recorded_from_year in list_all_year:
- list_all_year.append(collect.recorded_from_year)
- if collect.recorded_to_year != 0 and not collect.recorded_to_year in list_all_year:
- list_all_year.append(collect.recorded_to_year)
- list_all_year.sort()
+ last_year = date.today().year
list_year = []
list_year.append(('', '----'))
- for year in list_all_year:
- list_year.append((str(year), year))
+ year=getattr(settings, 'FIRST_YEAR', '[A-Za-z0-9._-]*')
+ while(year<=last_year):
+ list_year.append((str(year),year))
+ year+=1
return list_year
recorded_from_date = forms.TypedChoiceField(
# to create a dynamic list of publishing years
def list_publish_year():
- list_all_year = []
- list_collect = MediaCollection.objects.all()
- for collect in list_collect:
- if collect.year_published != 0 and not collect.year_published in list_all_year:
- list_all_year.append(collect.year_published)
- list_all_year.sort()
+ last_year = date.today().year
list_year = []
- list_year.append((0, '----'))
- for year in list_all_year:
- list_year.append((year, year))
+ list_year.append(('', '----'))
+ year=getattr(settings, 'FIRST_YEAR', '[A-Za-z0-9._-]*')
+ while(year<=last_year):
+ list_year.append((str(year),year))
+ year+=1
return list_year
year_published_from = forms.TypedChoiceField(
if self.cleaned_data.get('physical_format') != '':
sqs = sqs.filter(physical_format=self.cleaned_data['physical_format'])
- return sqs
+ return sqs
\ No newline at end of file