示例#1
0
文件: views.py 项目: guotielong/hue
def admin_collection_properties(request, collection_id):
  hue_collection = Collection.objects.get(id=collection_id)
  solr_collection = SolrApi(SOLR_URL.get()).collection_or_core(hue_collection)

  if request.method == 'POST':
    collection_form = CollectionForm(request.POST, instance=hue_collection)
    if collection_form.is_valid():
      hue_collection = collection_form.save()
      return redirect(reverse('search:admin_collection_properties', kwargs={'collection_id': hue_collection.id}))
    else:
      request.error(_('Errors on the form: %s') % collection_form.errors)
  else:
    collection_form = CollectionForm(instance=hue_collection)

  return render('admin_collection_properties.mako', request, {
    'solr_collection': solr_collection,
    'hue_collection': hue_collection,
    'collection_form': collection_form,
  })
示例#2
0
def admin_collection_properties(request, collection_id):
    hue_collection = Collection.objects.get(id=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)
        if collection_form.is_valid():
            searcher = SearchController(request.user)
            hue_collection = collection_form.save(commit=False)
            hue_collection.is_core_only = not searcher.is_collection(
                hue_collection.name)
            hue_collection.save()
            return redirect(
                reverse('search:admin_collection_properties',
                        kwargs={'collection_id': hue_collection.id}))
        else:
            request.error(
                _('Errors on the form: %s.') % collection_form.errors)
    else:
        collection_form = CollectionForm(instance=hue_collection)

    return render(
        'admin_collection_properties.mako', request, {
            'solr_collection': solr_collection,
            'hue_collection': hue_collection,
            'collection_form': collection_form,
        })
示例#3
0
文件: views.py 项目: Web5design/hue
def admin_collection_properties(request, collection_id):
  hue_collection = Collection.objects.get(id=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, user=request.user)
    if collection_form.is_valid(): # Check for autocomplete in data?
      searcher = SearchController(request.user)
      hue_collection = collection_form.save(commit=False)
      hue_collection.is_core_only = not searcher.is_collection(hue_collection.name)
      hue_collection.autocomplete = json.loads(request.POST.get('autocomplete'))
      hue_collection.save()
      return redirect(reverse('search:admin_collection_properties', kwargs={'collection_id': hue_collection.id}))
    else:
      request.error(_('Errors on the form: %s.') % collection_form.errors)
  else:
    collection_form = CollectionForm(instance=hue_collection)

  return render('admin_collection_properties.mako', request, {
    'solr_collection': solr_collection,
    'hue_collection': hue_collection,
    'collection_form': collection_form,
    'collection_properties': json.dumps(hue_collection.properties_dict)
  })