Explorar o código

[search] Disabled collection should not appear in the search page

Fix cookie bug of disabled collection
Romain Rigaux %!s(int64=12) %!d(string=hai) anos
pai
achega
4b8098f5eb

+ 0 - 1
apps/search/src/search/forms.py

@@ -45,7 +45,6 @@ class QueryForm(forms.Form):
     else:
       return self._initial_core(self.fields['collection'].choices)
 
-
   def _initial_core(self, choices):
     return choices and choices[0][0] or None
 

+ 0 - 1
apps/search/src/search/templates/search.mako

@@ -63,7 +63,6 @@ ${ commonheader(_('Search'), "search", user, "40px") | n,unicode }
     </div>
     <div class="input-append">
       ${ search_form | n,unicode }
-      <div class="icon-search" style="position: absolute;top: 7px;left: 11px;background-image: url('http://twitter.github.com/bootstrap/assets/img/glyphicons-halflings.png');"></div>
       <button type="submit" class="btn"><i class="icon-search"></i></button>
     </div>
   </form>

+ 4 - 2
apps/search/src/search/views.py

@@ -41,7 +41,7 @@ LOG = logging.getLogger(__name__)
 
 
 def index(request):
-  hue_collections = Collection.objects.all()
+  hue_collections = Collection.objects.filter(enabled=True)
 
   if not hue_collections:
     if request.user.is_superuser:
@@ -58,7 +58,9 @@ def index(request):
   if search_form.is_valid():
     collection_id = search_form.cleaned_data['collection']
     if request.GET.get('collection') is None:
-      collection_id = request.COOKIES.get('hueSearchLastCollection', collection_id)
+      cookie_collection_id = request.COOKIES.get('hueSearchLastCollection', collection_id)
+      if hue_collections.filter(id=cookie_collection_id).exists():
+        collection_id = cookie_collection_id
     solr_query['q'] = search_form.cleaned_data['query']
     solr_query['fq'] = search_form.cleaned_data['fq']
     if search_form.cleaned_data['sort']: