From: mathieu Date: Mon, 18 Apr 2016 12:12:15 +0000 (+0200) Subject: Autocompletion sur cote, instruments (1 seul) et collecteur X-Git-Tag: 1.6.2^2~15^2~10^2~1 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=6875c2007030c1fce9f7df2107bd1e7247f3b92b;p=telemeta.git Autocompletion sur cote, instruments (1 seul) et collecteur Former-commit-id: 2c4cc503bee00074f101de0af6d691aa28b386f9 --- diff --git a/.gitignore b/.gitignore index 78da6b0f..09c020dd 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,5 @@ pip-log.txt #Mr Developer .mr.developer.cfg + +.idea/* diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/env/debug.env b/env/debug.env index a19e3477..7a9fbbcc 100644 --- a/env/debug.env +++ b/env/debug.env @@ -18,4 +18,4 @@ BROKER_URL=redis://broker:6379/0 # If this is True, all tasks will be executed locally by blocking until the task returns. CELERY_ALWAYS_EAGER=False -REINDEX=False +REINDEX=True diff --git a/modif telemeta b/modif telemeta index b9eb8197..0f0bdeca 100644 --- a/modif telemeta +++ b/modif telemeta @@ -1,19 +1,9 @@ -collecteur dans recherche indispo - -liste de lecture -> tableau de bord : periode enregistrement - pas assez d items dans recherche -autocompletion sur instruments/collecteur (listes fermees) - -date enregistrement : min 1900 mais date avant apparaissent FAIT ??? - -nb items qui ont instrument dans liste instruments + liste - -filtre inedits/edites pour les items : passer par la collection puis sa cote (I : inedit, E : edites) - filtres apparait 1 fois sur 2 +nb items enum + liste + FAIT : apres suppression collection dans liste de lecture : laisser ouvert par defaut celle qui a ete ouverte en dernier @@ -23,3 +13,17 @@ tri dans les liste de lecture partiellement dispo (seulement les 4 premieres) tri dans recherche avancee/simple page 643 erreur + +nb items qui ont instrument dans liste instruments + liste + +liste de lecture -> tableau de bord : periode enregistrement + +collecteur dans recherche indispo + +date enregistrement : min 1900 mais date avant apparaissent + +autocompletion sur instruments/collecteur (listes fermees) + +VERIF PROD : + +filtre inedits/edites pour les items : passer par la collection puis sa cote (I : inedit, E : edites) diff --git a/telemeta/forms/haystack_form.py b/telemeta/forms/haystack_form.py index 449d4a62..8a81d776 100644 --- a/telemeta/forms/haystack_form.py +++ b/telemeta/forms/haystack_form.py @@ -84,18 +84,11 @@ class HayAdvanceForm(SearchForm): 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: + 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: + 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() - if len(list_all_year) >= 2: - min_year = list_all_year[len(list_all_year) - 1] - for year in list_all_year: - if year != 0: - if year < min_year: - min_year = year - list_all_year = range(min_year, date.today().year + 1) list_year = [] list_year.append(('', '----')) for year in list_all_year: @@ -110,16 +103,9 @@ class HayAdvanceForm(SearchForm): 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: + 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() - if len(list_all_year) >= 2: - min_year = list_all_year[len(list_all_year) - 1] - for year in list_all_year: - if year != 0: - if year < min_year: - min_year = year - list_all_year = range(min_year, date.today().year + 1) list_year = [] list_year.append((0, '----')) for year in list_all_year: @@ -175,7 +161,7 @@ class HayAdvanceForm(SearchForm): return self.no_query_found() if self.cleaned_data.get('q'): - sqs = sqs.filter(title__exact=self.cleaned_data['q']) + sqs = sqs.filter(title__contains=self.cleaned_data['q']) if self.cleaned_data.get('code'): sqs = sqs.filter(code__contains=self.cleaned_data['code']) diff --git a/telemeta/search_indexes.py b/telemeta/search_indexes.py index 1480a9ce..b54084b3 100644 --- a/telemeta/search_indexes.py +++ b/telemeta/search_indexes.py @@ -20,6 +20,8 @@ from haystack import indexes from telemeta.models import * +class InstrumentField(indexes.CharField): + field_type = 'instrument' class MediaItemIndex(indexes.SearchIndex, indexes.Indexable): @@ -34,13 +36,12 @@ class MediaItemIndex(indexes.SearchIndex, indexes.Indexable): #advance search title = indexes.CharField(model_attr='title') - title_auto = indexes.NgramField(model_attr='title') code = indexes.CharField(model_attr='code', default='') location_principal = indexes.CharField(null='None', boost=1.05) location_relation = indexes.CharField() ethnic_group = indexes.CharField(model_attr='ethnic_group', default='') - instruments = indexes.NgramField(default='') - collectors = indexes.NgramField(model_attr='collector', default='') + instruments = InstrumentField(default='') + collectors = indexes.CharField(model_attr='collector', default='') recorded_from_date = indexes.DateField(model_attr='recorded_from_date', null='None') recorded_to_date = indexes.DateField(model_attr='recorded_to_date', null='None') year_published = indexes.IntegerField(model_attr='collection__year_published', default='') @@ -84,7 +85,7 @@ class MediaItemIndex(indexes.SearchIndex, indexes.Indexable): instruments.append(material.instrument.name) if material.alias is not None: instruments.append(material.alias.name) - return u"".join(' ' + instru for instru in instruments) + return u"".join('|' + instru for instru in instruments) def prepare_collectors(self, obj): collectors = [] @@ -106,13 +107,12 @@ class MediaCollectionIndex(indexes.SearchIndex, indexes.Indexable): #advance search title = indexes.CharField(model_attr='title') - title_auto = indexes.NgramField(model_attr='title') code = indexes.CharField(model_attr='code', default='') location_principal = indexes.CharField(default='', boost=1.05) location_relation = indexes.CharField() ethnic_group = indexes.CharField(default='') - instruments = indexes.NgramField(default='') - collectors = indexes.NgramField(model_attr='collector', default='') + instruments = InstrumentField(default='') + collectors = indexes.CharField(model_attr='collector', default='') 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='') @@ -161,7 +161,7 @@ class MediaCollectionIndex(indexes.SearchIndex, indexes.Indexable): if material.alias and not material.alias in instruments: instruments.append(material.alias.name) - return u"".join(' ' + instru for instru in instruments) + return u"".join('|' + instru for instru in instruments) def prepare_recorded_from_date(self, obj): if obj.recorded_from_year != 0: @@ -188,8 +188,8 @@ class MediaCorpusIndex(indexes.SearchIndex, indexes.Indexable): #content_auto = indexes.EdgeNgramField(model_attr='content') #advance search - title = indexes.NgramField(model_attr='title') - code = indexes.NgramField(model_attr='code', default='') + title = indexes.CharField(model_attr='title') + code = indexes.CharField(model_attr='code', default='') #location_principal = indexes.CharField(default='', boost=1.05) #location_relation = indexes.CharField() #ethnic_group = indexes.CharField(default='') @@ -218,8 +218,8 @@ class MediaFondsIndex(indexes.SearchIndex, indexes.Indexable): #content_auto = indexes.EdgeNgramField(model_attr='content') #advance search - title = indexes.NgramField(model_attr='title') - code = indexes.NgramField(model_attr='code', default='') + title = indexes.CharField(model_attr='title') + code = indexes.CharField(model_attr='code', default='') #location_principal = indexes.CharField(default='', boost=1.05) #location_relation = indexes.CharField() #ethnic_group = indexes.CharField(default='') diff --git a/telemeta/templates/search/advanceSearch.html b/telemeta/templates/search/advanceSearch.html index dcc86f36..49611ed7 100644 --- a/telemeta/templates/search/advanceSearch.html +++ b/telemeta/templates/search/advanceSearch.html @@ -253,7 +253,7 @@