Эх сурвалжийг харах

[search] Edit collection link not pointing to the correct collection

Romain Rigaux 12 жил өмнө
parent
commit
033f27b

+ 5 - 8
apps/search/src/search/templates/search.mako

@@ -249,16 +249,13 @@ ${ commonheader(_('Search'), "search", user, "40px") | n,unicode }
 
     % if hue_collection:
       $(".current-collection").text("${ hue_collection.label }");
-    % endif
 
-    % if user.is_superuser:
-      $(".dropdown-collection").each(function () {
-        if ($(this).data("value") == $("select[name='collection']").val()) {
-          $(".change-settings").attr("href", $(this).data("settings-url"));
-        }
-      });
+      % if user.is_superuser:
+        var collectionUrl = $(".dropdown-collection[data-value=${ hue_collection.id }]").data("settings-url");
+        $(".change-settings").attr("href", collectionUrl);
+      % endif
     % endif
-
+    
     $(".dropdown-collection").click(function (e) {
       e.preventDefault();
       var collectionId = $(this).data("value");

+ 1 - 1
apps/search/src/search/views.py

@@ -58,7 +58,7 @@ 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', hue_collections[0].id)    
+      collection_id = request.COOKIES.get('hueSearchLastCollection', collection_id)    
     solr_query['q'] = search_form.cleaned_data['query']
     solr_query['fq'] = search_form.cleaned_data['fq']
     if search_form.cleaned_data['sort']: