#begin create field
#to replace de basic search form field
- q = forms.CharField(required=False, label=('Title'), widget=forms.TextInput(attrs={'class': 'form-control','type': 'search'}))
+ q = forms.CharField(required=False, label=('Title'), widget=forms.TextInput(attrs={'class': 'form-control', 'type': 'search'}))
- location = forms.CharField(required=False, label=('Location'), widget=forms.TextInput(attrs={'class': 'form-control','type': 'search'}))
+ location = forms.CharField(required=False, label=('Location'), widget=forms.TextInput(attrs={'class': 'form-control', 'type': 'search'}))
# to create a dynamic list of ethnic group
def list_ethnic_group():
type_name.append((ethnic.value, ethnic.value))
return type_name
- ethnic_group = forms.CharField(required=False, label=('Population / social group'), widget=forms.Select(attrs={'style' : 'width:100%' }, choices=list_ethnic_group()))
+ ethnic_group = forms.CharField(required=False, label=('Population / social group'), widget=forms.Select(attrs={'style': 'width:100%'}, choices=list_ethnic_group()))
- 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'}))
+ 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'}))
#to create a dynamic list of publish year
def list_recorded_year():
list_year = []
list_year.append(('', '----'))
for year in list_all_year:
- list_year.append(("01/01/" + str(year), year))
+ list_year.append((str(year), year))
return list_year
- recorded_from_date = forms.DateField(required=False, label=('Recorded from'), widget=forms.Select(attrs={'style':'width:47%'},choices=list_recorded_year()))
- recorded_to_date = forms.DateField(required=False, label=('Recorded to'), widget=forms.Select(attrs={'style':'width:47%'},choices=list_recorded_year()))
+ recorded_from_date = forms.IntegerField(required=False, label=('Recorded from'), widget=forms.Select(attrs={'style': 'width:47%'}, choices=list_recorded_year()))
+ recorded_to_date = forms.IntegerField(required=False, label=('Recorded to'), widget=forms.Select(attrs={'style': 'width:47%'}, choices=list_recorded_year()))
#to create a dynamic list of publish year
def list_publish_year():
list_year.append((year, year))
return list_year
- year_published_from = forms.IntegerField(required=False, label=('Year published from'), widget=forms.Select(attrs={'style':'width:47%'},choices=list_publish_year()))
- year_published_to = forms.IntegerField(required=False, label=('Year published to'), widget=forms.Select(attrs={'style':'width:47%'},choices=list_publish_year()))
+ year_published_from = forms.IntegerField(required=False, label=('Year published from'), widget=forms.Select(attrs={'style': 'width:47%'}, choices=list_publish_year()))
+ year_published_to = forms.IntegerField(required=False, label=('Year published to'), widget=forms.Select(attrs={'style': 'width:47%'}, choices=list_publish_year()))
viewable_choice = (('1', 'no preference'), ('2', 'fichier dans le player + full'), ('3', 'fichier dans le player(j\'ai un compte)'))
viewable = forms.CharField(required=False, label=('Viewable'), widget=forms.RadioSelect(choices=viewable_choice), initial=1)
type_name.append((context.value, context.value))
return type_name
- recording_context = forms.CharField(required=False, label=('Recording Context'), widget=forms.Select(attrs={'style':'width:100%'},choices=list_recording_context()))
+ recording_context = forms.CharField(required=False, label=('Recording Context'), widget=forms.Select(attrs={'style': 'width:100%'}, choices=list_recording_context()))
#to create a dynamic list of physical format
def list_physical_format():
type_name.append((physical_format.value, physical_format.value))
return type_name
- physical_format = forms.CharField(required=False, label=('Physical Format'), widget=forms.Select(attrs={'style':'width:100%'},choices=list_physical_format()))
+ physical_format = forms.CharField(required=False, label=('Physical Format'), widget=forms.Select(attrs={'style': 'width:100%'}, choices=list_physical_format()))
- code = forms.CharField(required=False, label=('Code'), widget=forms.TextInput(attrs={'class': 'form-control','type': 'search'}))
+ code = forms.CharField(required=False, label=('Code'), widget=forms.TextInput(attrs={'class': 'form-control', 'type': 'search'}))
#end
def search(self):
ethnic_group = indexes.CharField(default='')
instruments = indexes.NgramField(default='')
collectors = indexes.NgramField(model_attr='collector', default='')
- recorded_from_date = indexes.DateField(model_attr='recorded_from_year', null='None')
- recorded_to_date = indexes.DateField(model_attr='recorded_to_year', null='None')
+ recorded_from_date = indexes.DateField(model_attr='recorded_from_year', null=True)
+ recorded_to_date = indexes.DateField(model_attr='recorded_to_year', null=True)
year_published = indexes.IntegerField(model_attr='year_published', default='')
def prepare_digitized(self, obj):
instruments.append(material.alias)
return "%s" % instruments
+
+ def prepare_recorded_from_date(self, obj):
+ if obj.recorded_from_year != 0:
+ return datetime.date(int(obj.recorded_from_year), 01, 01)
+ else:
+ return None
+
+ def prepare_recorded_to_date(self, obj):
+ if obj.recorded_to_year != 0:
+ return datetime.date(int(obj.recorded_to_year), 01, 01)
+ else:
+ return None
\ No newline at end of file