本文整理汇总了Python中wagtail.wagtailadmin.modal_workflow.render_modal_workflow函数的典型用法代码示例。如果您正苦于以下问题:Python render_modal_workflow函数的具体用法?Python render_modal_workflow怎么用?Python render_modal_workflow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render_modal_workflow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: email_link
def email_link(request):
link_text = request.GET.get('link_text', '')
link_url = request.GET.get('link_url', '')
if request.method == 'POST':
form = EmailLinkChooserForm(request.POST)
if form.is_valid():
return render_modal_workflow(
request,
None, 'wagtailadmin/chooser/external_link_chosen.js',
{
'url': 'mailto:' + form.cleaned_data['email_address'],
'link_text': form.cleaned_data['link_text'].strip() or form.cleaned_data['email_address']
}
)
else:
form = EmailLinkChooserForm(initial={'email_address': link_url, 'link_text': link_text})
return render_modal_workflow(
request,
'wagtailadmin/chooser/email_link.html', 'wagtailadmin/chooser/email_link.js',
shared_context(request, {
'form': form,
})
)
示例2: imagecaption_chosen
def imagecaption_chosen(request, image_id):
if request.POST:
form = CaptionForm(request.POST)
if form.is_valid():
try:
if request.POST.get('caption'):
image = Image.objects.get(id=image_id)
if image.imagecaption.count() > 0:
imagecaption = image.imagecaption.all()[0]
imagecaption.caption = request.POST.get('caption')
imagecaption.save()
else:
image.imagecaption.add(ImageCaption(image=image, caption=request.POST.get('caption')))
return render_modal_workflow(request, None, "wagtailimagecaption/chooser/caption_chosen.js", {
'response': json.dumps({'status': True}),
})
except ObjectDoesNotExist:
return None
else:
form = CaptionForm()
return render_modal_workflow(
request,
"wagtailimagecaption/chooser/caption.html",
"wagtailimagecaption/chooser/caption.js",
{
'image_id': image_id,
'form': form
}
)
示例3: email_link
def email_link(request):
prompt_for_link_text = bool(request.GET.get('prompt_for_link_text'))
if prompt_for_link_text:
form_class = EmailLinkChooserWithLinkTextForm
else:
form_class = EmailLinkChooserForm
if request.POST:
form = form_class(request.POST)
if form.is_valid():
return render_modal_workflow(
request,
None, 'wagtailadmin/chooser/external_link_chosen.js',
{
'url': 'mailto:' + form.cleaned_data['email_address'],
'link_text': form.cleaned_data['link_text'] if (prompt_for_link_text and form.cleaned_data['link_text']) else form.cleaned_data['email_address']
}
)
else:
form = form_class()
return render_modal_workflow(
request,
'wagtailadmin/chooser/email_link.html', 'wagtailadmin/chooser/email_link.js',
{
'querystring': get_querystring(request),
'allow_external_link': request.GET.get('allow_external_link'),
'form': form,
}
)
示例4: chooser_select_format
def chooser_select_format(request, image_id):
image = get_object_or_404(get_image_model(), id=image_id)
if request.POST:
form = ImageInsertionForm(request.POST, initial={"alt_text": image.default_alt_text})
if form.is_valid():
format = get_image_format(form.cleaned_data["format"])
preview_image = image.get_rendition(format.filter_spec)
image_json = json.dumps(
{
"id": image.id,
"title": image.title,
"format": format.name,
"alt": form.cleaned_data["alt_text"],
"class": format.classnames,
"preview": {"url": preview_image.url, "width": preview_image.width, "height": preview_image.height},
"html": format.image_to_editor_html(image, form.cleaned_data["alt_text"]),
}
)
return render_modal_workflow(
request, None, "wagtailimages/chooser/image_chosen.js", {"image_json": image_json}
)
else:
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},
)
示例5: chooser_select_format
def chooser_select_format(request, image_id):
image = get_object_or_404(get_image_model(), id=image_id)
if request.POST:
form = ImageInsertionForm(request.POST, initial={'alt_text': image.default_alt_text})
if form.is_valid():
format = get_image_format(form.cleaned_data['format'])
preview_image = image.get_rendition(format.filter_spec)
image_json = json.dumps({
'id': image.id,
'title': image.title,
'format': format.name,
'alt': form.cleaned_data['alt_text'],
'class': format.classnames,
'preview': {
'url': preview_image.url,
'width': preview_image.width,
'height': preview_image.height,
},
'html': format.image_to_editor_html(image, form.cleaned_data['alt_text']),
})
return render_modal_workflow(
request, None, 'wagtailimages/chooser/image_chosen.js',
{'image_json': image_json}
)
else:
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}
)
示例6: chooser_upload
def chooser_upload(request):
Document = get_document_model()
DocumentForm = get_document_form(Document)
if request.method == 'POST':
document = Document(uploaded_by_user=request.user)
form = DocumentForm(request.POST, request.FILES, instance=document, user=request.user)
if form.is_valid():
form.save()
# Reindex the document to make sure all tags are indexed
search_index.insert_or_update_object(document)
return render_modal_workflow(
request, None, 'wagtaildocs/chooser/document_chosen.js',
{'document_json': get_document_json(document)}
)
else:
form = DocumentForm(user=request.user)
documents = Document.objects.order_by('title')
return render_modal_workflow(
request, 'wagtaildocs/chooser/chooser.html', 'wagtaildocs/chooser/chooser.js',
{'documents': documents, 'uploadform': form}
)
示例7: chooser_upload
def chooser_upload(request):
if request.POST:
form = EmbedForm(request.POST, request.FILES)
if form.is_valid():
try:
embed_html = embed_to_editor_html(form.cleaned_data['url'])
return render_modal_workflow(
request, None, 'wagtailembeds/chooser/embed_chosen.js',
{'embed_html': embed_html}
)
except Exception as e :
#print e
#import traceback
#traceback.print_exc()
errors = form._errors.setdefault('url', ErrorList())
if type(e) == NotImplementedOembedException:
errors.append("This URL is not supported by an oembed provider. You may try embedding it using Embedly by setting a propery EMBEDLY_KEY in your settings.")
elif type(e) == AccessDeniedEmbedlyException:
errors.append("There seems to be a problem with your embedly API key. Please check your settings.")
elif type(e) == NotFoundEmbedlyException:
errors.append("The URL you are trying to embed cannot be found.")
elif type(e) == EmbedlyException:
errors.append("There seems to be an error with Embedly while trying to embed this URL. Please try again later.")
else:
errors.append(str(e) )
return render_modal_workflow(request, 'wagtailembeds/chooser/chooser.html', 'wagtailembeds/chooser/chooser.js', {
'form': form,
})
else:
form = EmbedForm()
return render_modal_workflow(request, 'wagtailembeds/chooser/chooser.html', 'wagtailembeds/chooser/chooser.js', {
'form': form,
})
示例8: email_link
def email_link(request):
initial_data = {
'link_text': request.GET.get('link_text', ''),
'email_address': request.GET.get('link_url', ''),
}
if request.method == 'POST':
form = EmailLinkChooserForm(request.POST, initial=initial_data)
if form.is_valid():
result = {
'url': 'mailto:' + form.cleaned_data['email_address'],
'title': form.cleaned_data['link_text'].strip() or form.cleaned_data['email_address'],
# If the user has explicitly entered / edited something in the link_text field,
# always use that text. If not, we should favour keeping the existing link/selection
# text, where applicable.
'prefer_this_title_as_link_text': ('link_text' in form.changed_data),
}
return render_modal_workflow(
request,
None, 'wagtailadmin/chooser/external_link_chosen.js',
{
'result_json': json.dumps(result),
}
)
else:
form = EmailLinkChooserForm(initial=initial_data)
return render_modal_workflow(
request,
'wagtailadmin/chooser/email_link.html', 'wagtailadmin/chooser/email_link.js',
shared_context(request, {
'form': form,
})
)
示例9: 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}
)
示例10: external_link
def external_link(request):
prompt_for_link_text = bool(request.GET.get('prompt_for_link_text'))
if prompt_for_link_text:
form_class = ExternalLinkChooserWithLinkTextForm
else:
form_class = ExternalLinkChooserForm
if request.POST:
form = form_class(request.POST)
if form.is_valid():
return render_modal_workflow(
request,
None, 'wagtailadmin/chooser/external_link_chosen.js',
{
'url': form.cleaned_data['url'],
'link_text': form.cleaned_data['link_text'] if prompt_for_link_text else form.cleaned_data['url']
}
)
else:
form = form_class()
return render_modal_workflow(
request,
'wagtailadmin/chooser/external_link.html', 'wagtailadmin/chooser/external_link.js',
shared_context(request, {
'form': form,
})
)
示例11: chooser_upload
def chooser_upload(request):
Image = get_image_model()
ImageForm = get_image_form()
if request.POST:
image = Image(uploaded_by_user=request.user)
form = ImageForm(request.POST, request.FILES, instance=image)
if form.is_valid():
form.save()
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()
images = Image.objects.order_by("title")
return render_modal_workflow(
request,
"wagtailimages/chooser/chooser.html",
"wagtailimages/chooser/chooser.js",
{"images": images, "uploadform": form},
)
示例12: chooser_upload
def chooser_upload(request):
Image = get_image_model()
ImageForm = get_image_form()
if request.POST:
image = Image(uploaded_by_user=request.user)
form = ImageForm(request.POST, request.FILES, instance=image)
if form.is_valid():
form.save()
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()
images = Image.objects.order_by('title')
return render_modal_workflow(
request, 'wagtailimages/chooser/chooser.html', 'wagtailimages/chooser/chooser.js',
{'images': images, 'uploadform': form}
)
示例13: chooser_upload
def chooser_upload(request):
if request.POST:
form = EmbedForm(request.POST, request.FILES)
if form.is_valid():
error = None
try:
embed_html = embed_to_editor_html(form.cleaned_data['url'])
return render_modal_workflow(
request, None, 'wagtailembeds/chooser/embed_chosen.js',
{'embed_html': embed_html}
)
except AccessDeniedEmbedlyException:
error = _("There seems to be a problem with your embedly API key. Please check your settings.")
except EmbedNotFoundException:
error = _("Cannot find an embed for this URL.")
except EmbedlyException:
error = _("There seems to be an error with Embedly while trying to embed this URL. Please try again later.")
if error:
errors = form._errors.setdefault('url', ErrorList())
errors.append(error)
return render_modal_workflow(request, 'wagtailembeds/chooser/chooser.html', 'wagtailembeds/chooser/chooser.js', {
'form': form,
})
else:
form = EmbedForm()
return render_modal_workflow(request, 'wagtailembeds/chooser/chooser.html', 'wagtailembeds/chooser/chooser.js', {
'form': form,
})
示例14: chooser_select_format
def chooser_select_format(request, embed_video_id):
embed_video = get_object_or_404(get_embed_video_model(), id=embed_video_id)
if request.POST:
form = EmbedVideoInsertionForm(request.POST, initial={'alt_text': embed_video.default_alt_text})
if form.is_valid():
# format = get_embed_video_format(form.cleaned_data['format'])
preview_embed_video = detect_backend(embed_video.url).get_thumbnail_url()
embed_video_json = json.dumps({
'id': embed_video.id,
'title': embed_video.title,
'format': format.name,
'alt': form.cleaned_data['alt_text'],
'class': format.classnames,
'edit_link': reverse('wagtail_embed_videos:edit', args=(embed_video.id,)),
'preview': {
'url': preview_embed_video,
},
'html': format.embed_video_to_editor_html(embed_video, form.cleaned_data['alt_text']),
})
return render_modal_workflow(
request, None, 'wagtail_embed_videos/chooser/embed_video_chosen.js',
{'embed_video_json': embed_video_json}
)
else:
form = EmbedVideoInsertionForm(initial={'alt_text': embed_video.default_alt_text})
return render_modal_workflow(
request, 'wagtail_embed_videos/chooser/select_format.html', 'wagtail_embed_videos/chooser/select_format.js',
{'embed_video': embed_video, 'form': form}
)
示例15: 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},
)