本文整理汇总了Python中wagtail.wagtailsearch.backends.get_search_backends函数的典型用法代码示例。如果您正苦于以下问题:Python get_search_backends函数的具体用法?Python get_search_backends怎么用?Python get_search_backends使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_search_backends函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: edit
def edit(request, embed_video_id):
EmbedVideo = get_embed_video_model()
EmbedVideoForm = get_embed_video_form(EmbedVideo)
embed_video = get_object_or_404(EmbedVideo, id=embed_video_id)
if not embed_video.is_editable_by_user(request.user):
raise PermissionDenied
if request.POST:
form = EmbedVideoForm(request.POST, request.FILES, instance=embed_video)
if form.is_valid():
form.save()
# Reindex the embed_video to make sure all tags are indexed
for backend in get_search_backends():
backend.add(embed_video)
messages.success(request, _("Embed video '{0}' updated.").format(embed_video.title), buttons=[
messages.button(reverse('wagtail_embed_videos_edit_embed_video', args=(embed_video.id,)), _('Edit again'))
])
return redirect('wagtail_embed_videos_index')
else:
messages.error(request, _("The embed video could not be saved due to errors."))
else:
form = EmbedVideoForm(instance=embed_video)
return render(request, "wagtail_embed_videos/embed_videos/edit.html", {
'embed_video': embed_video,
'form': form,
})
开发者ID:MariusCC,项目名称:wagtail-embedvideos,代码行数:31,代码来源:embed_videos.py
示例2: chooser_upload
def chooser_upload(request):
if request.POST:
document = Document(uploaded_by_user=request.user)
form = DocumentForm(request.POST, request.FILES, instance=document)
if form.is_valid():
form.save()
# Reindex the document to make sure all tags are indexed
for backend in get_search_backends():
backend.add(document)
return render_modal_workflow(
request, None, 'wagtaildocs/chooser/document_chosen.js',
{'document_json': get_document_json(document)}
)
else:
form = DocumentForm()
documents = Document.objects.order_by('title')
return render_modal_workflow(
request, 'wagtaildocs/chooser/chooser.html', 'wagtaildocs/chooser/chooser.js',
{'documents': documents, 'uploadform': form}
)
开发者ID:WalterC87,项目名称:wagtail,代码行数:25,代码来源:chooser.py
示例3: chooser_upload
def chooser_upload(request):
Document = get_document_model()
DocumentForm = get_document_form(Document)
if request.POST:
document = Document(uploaded_by_user=request.user)
form = DocumentForm(request.POST, request.FILES, instance=document)
if form.is_valid():
form.save()
# Reindex the document to make sure all tags are indexed
for backend in get_search_backends():
backend.add(document)
return render_modal_workflow(
request, None, "wagtaildocs/chooser/document_chosen.js", {"document_json": get_document_json(document)}
)
else:
form = DocumentForm()
documents = Document.objects.order_by("title")
return render_modal_workflow(
request,
"wagtaildocs/chooser/chooser.html",
"wagtaildocs/chooser/chooser.js",
{"documents": documents, "uploadform": form},
)
开发者ID:thrawny,项目名称:wagtail,代码行数:29,代码来源:chooser.py
示例4: add
def add(request):
EmbedVideoModel = get_embed_video_model()
EmbedVideoForm = get_embed_video_form(EmbedVideoModel)
if request.POST:
embed_video = EmbedVideoModel(uploaded_by_user=request.user)
form = EmbedVideoForm(request.POST, request.FILES, instance=embed_video)
if form.is_valid():
form.save()
# Reindex the embed video to make sure all tags are indexed
for backend in get_search_backends():
backend.add(embed_video)
messages.success(request, _("Embed video '{0}' added.").format(embed_video.title), buttons=[
messages.button(reverse('wagtail_embed_videos_edit_embed_video', args=(embed_video.id,)), _('Edit'))
])
return redirect('wagtail_embed_videos_index')
else:
messages.error(request, _("The embed video could not be created due to errors."))
else:
form = EmbedVideoForm()
return render(request, "wagtail_embed_videos/embed_videos/add.html", {
'form': form,
})
开发者ID:MariusCC,项目名称:wagtail-embedvideos,代码行数:26,代码来源:embed_videos.py
示例5: form_valid
def form_valid(self, form):
"""
Processes a valid form submittal.
:param form: the form instance.
:rtype: django.http.HttpResponse.
"""
#noinspection PyAttributeOutsideInit
self.object = form.save()
meta = getattr(self.object, '_meta')
# Index the object.
for backend in get_search_backends():
backend.add(object)
#noinspection PyUnresolvedReferences
messages.success(
self.request,
_(u'{0} "{1}" saved.').format(
meta.verbose_name,
str(self.object)
),
buttons=[messages.button(
reverse(
'{0}:edit'.format(self.url_namespace),
args=(self.object.id,)
),
_(u'Edit')
)]
)
return redirect(self.get_success_url())
开发者ID:awayme,项目名称:wagtailplus,代码行数:32,代码来源:crud.py
示例6: add
def add(request):
ImageForm = get_image_form()
ImageModel = get_image_model()
if request.POST:
image = ImageModel(uploaded_by_user=request.user)
form = ImageForm(request.POST, request.FILES, instance=image)
if form.is_valid():
form.save()
# Reindex the image to make sure all tags are indexed
for backend in get_search_backends():
backend.add(image)
messages.success(request, _("Image '{0}' added.").format(image.title))
return redirect('wagtailimages_index')
else:
messages.error(request, _("The image could not be created due to errors."))
else:
form = ImageForm()
return render(request, "wagtailimages/images/add.html", {
'form': form,
'max_filesize': MAX_UPLOAD_SIZE,
})
开发者ID:gilsondev,项目名称:wagtail,代码行数:25,代码来源:images.py
示例7: form_valid
def form_valid(self, form):
"""
Processes successful form submittal.
:param form: the form instance.
:rtype: django.http.HttpResponse.
"""
# Set the object from form data.
self.object = form.save()
# Reindex the instance to make sure all tags are indexed.
for backend in get_search_backends():
backend.add(self.object)
# Add success message.
messages.success(
self.request,
_(u"{0} '{1}' saved.").format(
unicode(self.model._meta.verbose_name),
unicode(self.object)
)
)
# Redirect to success URL.
return redirect(self.success_url)
开发者ID:MariusCC,项目名称:wagtailplus,代码行数:25,代码来源:crud.py
示例8: edit
def edit(request, image_id):
Image = get_image_model()
ImageForm = get_image_form(Image)
image = get_object_or_404(Image, id=image_id)
if not image.is_editable_by_user(request.user):
raise PermissionDenied
if request.POST:
original_file = image.file
form = ImageForm(request.POST, request.FILES, instance=image)
if form.is_valid():
if 'file' in form.changed_data:
# if providing a new image file, delete the old one and all renditions.
# NB Doing this via original_file.delete() clears the file field,
# which definitely isn't what we want...
original_file.storage.delete(original_file.name)
image.renditions.all().delete()
# Set new image file size
image.file_size = image.file.size
form.save()
# Reindex the image to make sure all tags are indexed
for backend in get_search_backends():
backend.add(image)
messages.success(request, _("Image '{0}' updated.").format(image.title), buttons=[
messages.button(reverse('wagtailimages:edit', args=(image.id,)), _('Edit again'))
])
return redirect('wagtailimages:index')
else:
messages.error(request, _("The image could not be saved due to errors."))
else:
form = ImageForm(instance=image)
# Check if we should enable the frontend url generator
try:
reverse('wagtailimages_serve', args=('foo', '1', 'bar'))
url_generator_enabled = True
except NoReverseMatch:
url_generator_enabled = False
if image.is_stored_locally():
# Give error if image file doesn't exist
if not os.path.isfile(image.file.path):
messages.error(request, _(
"The source image file could not be found. Please change the source or delete the image."
).format(image.title), buttons=[
messages.button(reverse('wagtailimages:delete', args=(image.id,)), _('Delete'))
])
return render(request, "wagtailimages/images/edit.html", {
'image': image,
'form': form,
'url_generator_enabled': url_generator_enabled,
'filesize': image.get_file_size(),
})
开发者ID:CorneliusIV,项目名称:wagtail,代码行数:60,代码来源:images.py
示例9: edit
def edit(request, doc_id, callback=None):
Document = get_document_model()
DocumentMultiForm = get_document_multi_form(Document)
doc = get_object_or_404(Document, id=doc_id)
if not request.is_ajax():
return HttpResponseBadRequest("Cannot POST to this view without AJAX")
if not permission_policy.user_has_permission_for_instance(request.user, 'change', doc):
raise PermissionDenied
form = DocumentMultiForm(request.POST, request.FILES, instance=doc, prefix='doc-' + doc_id)
if form.is_valid():
form.save()
# Reindex the doc to make sure all tags are indexed
for backend in get_search_backends():
backend.add(doc)
return JsonResponse({
'success': True,
'doc_id': int(doc_id),
})
else:
return JsonResponse({
'success': False,
'doc_id': int(doc_id),
'form': render_to_string('wagtaildocs/multiple/edit_form.html', {
'doc': doc,
'form': form,
}, request=request),
})
开发者ID:AdamBolfik,项目名称:wagtail,代码行数:34,代码来源:multiple.py
示例10: add
def add(request):
Document = get_document_model()
DocumentForm = get_document_form(Document)
if request.POST:
doc = Document(uploaded_by_user=request.user)
form = DocumentForm(request.POST, request.FILES, instance=doc, user=request.user)
if form.is_valid():
form.save()
# Reindex the document to make sure all tags are indexed
for backend in get_search_backends():
backend.add(doc)
messages.success(request, _("Document '{0}' added.").format(doc.title), buttons=[
messages.button(reverse('wagtaildocs:edit', args=(doc.id,)), _('Edit'))
])
return redirect('wagtaildocs:index')
else:
messages.error(request, _("The document could not be saved due to errors."))
else:
form = DocumentForm(user=request.user)
return render(request, "wagtaildocs/documents/add.html", {
'form': form,
})
开发者ID:Jimmy570,项目名称:wagtail,代码行数:26,代码来源:documents.py
示例11: add
def add(request):
ImageModel = get_image_model()
ImageForm = get_image_form(ImageModel)
if request.POST:
image = ImageModel(uploaded_by_user=request.user)
form = ImageForm(request.POST, request.FILES, instance=image)
if form.is_valid():
# Set image file size
image.file_size = image.file.size
form.save()
# Reindex the image to make sure all tags are indexed
for backend in get_search_backends():
backend.add(image)
messages.success(request, _("Image '{0}' added.").format(image.title), buttons=[
messages.button(reverse('wagtailimages:edit', args=(image.id,)), _('Edit'))
])
return redirect('wagtailimages:index')
else:
messages.error(request, _("The image could not be created due to errors."))
else:
form = ImageForm()
return render(request, "wagtailimages/images/add.html", {
'form': form,
})
开发者ID:WalterC87,项目名称:wagtail,代码行数:29,代码来源:images.py
示例12: edit
def edit(request, document_id):
doc = get_object_or_404(Document, id=document_id)
if not doc.is_editable_by_user(request.user):
raise PermissionDenied
if request.POST:
original_file = doc.file
form = DocumentForm(request.POST, request.FILES, instance=doc)
if form.is_valid():
if "file" in form.changed_data:
# if providing a new document file, delete the old one.
# NB Doing this via original_file.delete() clears the file field,
# which definitely isn't what we want...
original_file.storage.delete(original_file.name)
doc = form.save()
# Reindex the document to make sure all tags are indexed
for backend in get_search_backends():
backend.add(doc)
messages.success(request, _("Document '{0}' updated").format(doc.title))
return redirect("wagtaildocs_index")
else:
messages.error(request, _("The document could not be saved due to errors."))
else:
form = DocumentForm(instance=doc)
return render(request, "wagtaildocs/documents/edit.html", {"document": doc, "form": form})
开发者ID:sudocode,项目名称:wagtail,代码行数:29,代码来源:documents.py
示例13: form_valid
def form_valid(self, form):
"""
Processes successful form submittal.
:param form: the form instance.
:rtype: django.http.HttpResponse.
"""
self.object = form.save()
for backend in get_search_backends():
backend.add(self.object)
if self.object.link_type == Link.LINK_TYPE_EMAIL:
javascript = 'wagtaillinks/chooser/email-chosen.js'
elif self.object.link_type == Link.LINK_TYPE_EXTERNAL:
javascript = 'wagtaillinks/chooser/external-chosen.js'
instance_json = json.dumps({
'id': self.object.id,
'linktype': 'link',
'title': unicode(self.object.title),
'url': self.object.url,
})
return render_modal_workflow(
self.request,
None,
javascript,
{'instance_json': instance_json}
)
开发者ID:MariusCC,项目名称:wagtailplus,代码行数:30,代码来源:choosers.py
示例14: edit
def edit(request, image_id, callback=None):
Image = get_image_model()
ImageForm = get_image_edit_form()
image = get_object_or_404(Image, id=image_id)
if not request.is_ajax():
return HttpResponseBadRequest("Cannot POST to this view without AJAX")
if not image.is_editable_by_user(request.user):
raise PermissionDenied
form = ImageForm(request.POST, request.FILES, instance=image, prefix='image-'+image_id)
if form.is_valid():
form.save()
# Reindex the image to make sure all tags are indexed
for backend in get_search_backends():
backend.add(image)
return json_response({
'success': True,
'image_id': int(image_id),
})
else:
return json_response({
'success': False,
'image_id': int(image_id),
'form': render_to_string('wagtailimages/multiple/edit_form.html', {
'image': image,
'form': form,
}, context_instance=RequestContext(request)),
})
开发者ID:Magzhan123,项目名称:TabysKTS,代码行数:34,代码来源:multiple.py
示例15: edit
def edit(request, document_id):
Document = get_document_model()
DocumentForm = get_document_form(Document)
doc = get_object_or_404(Document, id=document_id)
if not permission_policy.user_has_permission_for_instance(request.user, 'change', doc):
return permission_denied(request)
if request.POST:
original_file = doc.file
form = DocumentForm(request.POST, request.FILES, instance=doc, user=request.user)
if form.is_valid():
if 'file' in form.changed_data:
# if providing a new document file, delete the old one.
# NB Doing this via original_file.delete() clears the file field,
# which definitely isn't what we want...
original_file.storage.delete(original_file.name)
doc = form.save()
# Reindex the document to make sure all tags are indexed
for backend in get_search_backends():
backend.add(doc)
messages.success(request, _("Document '{0}' updated").format(doc.title), buttons=[
messages.button(reverse('wagtaildocs:edit', args=(doc.id,)), _('Edit'))
])
return redirect('wagtaildocs:index')
else:
messages.error(request, _("The document could not be saved due to errors."))
else:
form = DocumentForm(instance=doc, user=request.user)
filesize = None
# Get file size when there is a file associated with the Document object
if doc.file:
try:
filesize = doc.file.size
except OSError:
# File doesn't exist
pass
if not filesize:
messages.error(
request,
_("The file could not be found. Please change the source or delete the document"),
buttons=[messages.button(reverse('wagtaildocs:delete', args=(doc.id,)), _('Delete'))]
)
return render(request, "wagtaildocs/documents/edit.html", {
'document': doc,
'filesize': filesize,
'form': form,
'user_can_delete': permission_policy.user_has_permission_for_instance(
request.user, 'delete', doc
),
})
开发者ID:Jimmy570,项目名称:wagtail,代码行数:58,代码来源:documents.py
示例16: post_save_signal_handler
def post_save_signal_handler(instance, **kwargs):
indexed_instance = get_indexed_instance(instance)
if indexed_instance:
cur_language = translation.get_language()
for backend in get_search_backends(with_auto_update=True):
backend_language = getattr(backend, 'language_code', None)
if backend_language is not None:
translation.activate(backend_language)
backend.add(indexed_instance)
translation.activate(cur_language)
开发者ID:razisayyed,项目名称:wagtail,代码行数:11,代码来源:signal_handlers.py
示例17: poster_image_upload
def poster_image_upload(request, embed_id):
Image = get_image_model()
ImageForm = get_image_form()
searchform = SearchForm()
if request.POST:
image = Image(uploaded_by_user=request.user)
form = ImageForm(request.POST, request.FILES, instance=image)
if form.is_valid():
form.save()
# Reindex the image to make sure all tags are indexed
for backend in get_search_backends():
backend.add(image)
if request.GET.get('select_format'):
form = ImageInsertionForm(initial={'alt_text': image.default_alt_text})
return render_modal_workflow(
request, 'wagtailimages/chooser/select_format.html', 'wagtailimages/chooser/select_format.js',
{'image': image, 'form': form}
)
else:
# not specifying a format; return the image details now
embed = Embed.objects.get(id=embed_id)
embed_image = EmbedVideoPosterImage(embed=embed, image=image)
embed_image.save()
image_json = get_image_json(image)
return render_modal_workflow(
request, None, 'wagtailimages/chooser/poster_image_chosen.js',
{'image_json': image_json, 'posterimage_id': embed_image.id}
)
else:
form = ImageForm()
images = Image.objects.order_by('title')
return render_modal_workflow(
request, 'wagtailimages/chooser/chooser.html', 'wagtailimages/chooser/chooser.js', {
'images': images,
'uploadform': form,
'searchform': searchform,
'max_filesize': MAX_UPLOAD_SIZE,
'embed_id': embed_id
}
)
开发者ID:springload,项目名称:wagtailvideoposter,代码行数:47,代码来源:chooser.py
示例18: add
def add(request):
if request.POST:
doc = Document(uploaded_by_user=request.user)
form = DocumentForm(request.POST, request.FILES, instance=doc)
if form.is_valid():
form.save()
# Reindex the document to make sure all tags are indexed
for backend in get_search_backends():
backend.add(doc)
messages.success(request, _("Document '{0}' added.").format(doc.title))
return redirect("wagtaildocs_index")
else:
messages.error(request, _("The document could not be saved due to errors."))
else:
form = DocumentForm()
return render(request, "wagtaildocs/documents/add.html", {"form": form})
开发者ID:sudocode,项目名称:wagtail,代码行数:19,代码来源:documents.py
示例19: chooser_upload
def chooser_upload(request):
Image = get_image_model()
ImageForm = get_image_form(Image)
searchform = SearchForm()
if request.method == "POST":
image = Image(uploaded_by_user=request.user)
form = ImageForm(request.POST, request.FILES, instance=image, user=request.user)
if form.is_valid():
form.save()
# Reindex the image to make sure all tags are indexed
for backend in get_search_backends():
backend.add(image)
if request.GET.get("select_format"):
form = ImageInsertionForm(initial={"alt_text": image.default_alt_text})
return render_modal_workflow(
request,
"wagtailimages/chooser/select_format.html",
"wagtailimages/chooser/select_format.js",
{"image": image, "form": form},
)
else:
# not specifying a format; return the image details now
return render_modal_workflow(
request, None, "wagtailimages/chooser/image_chosen.js", {"image_json": get_image_json(image)}
)
else:
form = ImageForm(user=request.user)
images = Image.objects.order_by("title")
return render_modal_workflow(
request,
"wagtailimages/chooser/chooser.html",
"wagtailimages/chooser/chooser.js",
{"images": images, "uploadform": form, "searchform": searchform},
)
开发者ID:quru,项目名称:wagtail,代码行数:41,代码来源:chooser.py
示例20: form_valid
def form_valid(self, form):
"""
Processes a valid form submittal.
:param form: the form instance.
:rtype: django.http.HttpResponse.
"""
#noinspection PyAttributeOutsideInit
self.object = form.save()
# Index the link.
for backend in get_search_backends():
backend.add(self.object)
#noinspection PyUnresolvedReferences
return render_modal_workflow(
self.request,
None,
'{0}/chosen.js'.format(self.template_dir),
{'obj': self.get_json(self.object)}
)
开发者ID:adonm,项目名称:wagtailplus,代码行数:21,代码来源:chooser.py
注:本文中的wagtail.wagtailsearch.backends.get_search_backends函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论