Преглед изворни кода

[search] Changing name of a collection gives a 500

Romain Rigaux пре 12 година
родитељ
комит
e149058
2 измењених фајлова са 6 додато и 2 уклоњено
  1. 5 1
      apps/search/src/search/forms.py
  2. 1 1
      apps/search/src/search/views.py

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

@@ -59,12 +59,16 @@ class HighlightingForm(forms.Form):
 
 
 class CollectionForm(forms.ModelForm):
+  def __init__(self, *args, **kwargs):
+    self.user = kwargs.pop('user', None)
+    super(CollectionForm, self).__init__(*args, **kwargs)
+
   class Meta:
     model = Collection
     exclude = ('facets', 'result', 'sorting', 'properties', 'cores')
 
   def clean_name(self):
-    searcher = SearchController()
+    searcher = SearchController(self.user)
     name = self.cleaned_data['name']
     if not searcher.is_collection(name) and not searcher.is_core(name):
       raise forms.ValidationError(_('No live Solr collection or core by the name %s.') % name)

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

@@ -213,7 +213,7 @@ def admin_collection_properties(request, collection_id):
   solr_collection = SolrApi(SOLR_URL.get(), request.user).collection_or_core(hue_collection)
 
   if request.method == 'POST':
-    collection_form = CollectionForm(request.POST, instance=hue_collection)
+    collection_form = CollectionForm(request.POST, instance=hue_collection, user=request.user)
     if collection_form.is_valid():
       searcher = SearchController(request.user)
       hue_collection = collection_form.save(commit=False)