]> git.parisson.com Git - telemeta.git/commitdiff
Optimize search_indexes for Telemeta actual database
authorKaltar5679 <killian.mary@outlook.fr>
Fri, 22 May 2015 12:32:33 +0000 (14:32 +0200)
committerKaltar5679 <killian.mary@outlook.fr>
Fri, 22 May 2015 12:32:33 +0000 (14:32 +0200)
src/django-haystack
telemeta/forms/haystack_form.py
telemeta/search_indexes.py
telemeta/templates/search/indexes/telemeta/mediaitem_text.txt

index bd60745ce82318b1819768c9a31db0579228654d..cecb459ff4468a79a43cead3d09e213d0980c080 160000 (submodule)
@@ -1 +1 @@
-Subproject commit bd60745ce82318b1819768c9a31db0579228654d
+Subproject commit cecb459ff4468a79a43cead3d09e213d0980c080
index a3af191673e47dd9420133722e11bd2e8e8b1737..388c92a15b6b7b5f43b1231c53ad497d3ee4d429 100644 (file)
@@ -34,9 +34,9 @@ class HayAdvanceForm(SearchForm):
 #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():
@@ -47,10 +47,10 @@ class HayAdvanceForm(SearchForm):
             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():
@@ -75,11 +75,11 @@ class HayAdvanceForm(SearchForm):
         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():
@@ -105,8 +105,8 @@ class HayAdvanceForm(SearchForm):
             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)
@@ -133,7 +133,7 @@ class HayAdvanceForm(SearchForm):
             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():
@@ -144,9 +144,9 @@ class HayAdvanceForm(SearchForm):
             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):
index c5d29ec94e298af8b6e4b53009abceb315a66b49..cd3c526c2b656233cd4f8512ef996815ee0e6ea7 100644 (file)
@@ -78,8 +78,8 @@ class MediaCollectionIndex(indexes.SearchIndex, indexes.Indexable):
     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):
@@ -120,3 +120,15 @@ class MediaCollectionIndex(indexes.SearchIndex, indexes.Indexable):
                     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
index 7ccb3974d222da34463d18c62bdaaf5bfcdf2f52..bdcde2c28d7c9f0ee8413d41e1159a5da65492c7 100644 (file)
@@ -3,7 +3,6 @@
 {{ object.recorded_from_date }}
 {{ object.recorded_to_date }}
 {{ object.code }}
-{{ object.old_code }}
 {{ object.location }}
 {{ object.location.name }}
 {{ object.comment }}