本文整理汇总了Python中wagtail.wagtailadmin.modal_workflow.render_modal_workflow函数的典型用法代码示例。如果您正苦于以下问题:Python render_modal_workflow函数的具体用法?Python render_modal_workflow怎么用?Python render_modal_workflow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render_modal_workflow函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,
})
)
开发者ID:Eraldo,项目名称:wagtail,代码行数:26,代码来源:chooser.py
示例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
}
)
开发者ID:springload,项目名称:wagtailimagecaption,代码行数:29,代码来源:chooser.py
示例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,
}
)
开发者ID:rudyondolan,项目名称:wagtail,代码行数:31,代码来源:chooser.py
示例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},
)
开发者ID:rthauby,项目名称:wagtail,代码行数:34,代码来源:chooser.py
示例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}
)
开发者ID:jalourenco,项目名称:wagtail,代码行数:35,代码来源:chooser.py
示例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}
)
开发者ID:doru-rocod,项目名称:wagtail,代码行数:27,代码来源:chooser.py
示例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,
})
开发者ID:AppDevy,项目名称:wagtail,代码行数:35,代码来源:chooser.py
示例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,
})
)
开发者ID:chrxr,项目名称:wagtail,代码行数:35,代码来源:chooser.py
示例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}
)
开发者ID:WalterC87,项目名称:wagtail,代码行数:25,代码来源:chooser.py
示例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,
})
)
开发者ID:njamaleddine,项目名称:wagtail,代码行数:29,代码来源:chooser.py
示例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},
)
开发者ID:rthauby,项目名称:wagtail,代码行数:34,代码来源:chooser.py
示例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}
)
开发者ID:dvska,项目名称:wagtail,代码行数:31,代码来源:chooser.py
示例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,
})
开发者ID:Tivix,项目名称:wagtail,代码行数:31,代码来源:chooser.py
示例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}
)
开发者ID:SalahAdDin,项目名称:wagtail-embedvideos,代码行数:35,代码来源:chooser.py
示例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},
)
开发者ID:thrawny,项目名称:wagtail,代码行数:29,代码来源:chooser.py
示例16: 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",
shared_context(request, {"form": form}),
)
开发者ID:kmcodes,项目名称:wagtail,代码行数:31,代码来源:chooser.py
示例17: choose
def choose(request, content_type_app_name, content_type_model_name):
content_type = get_content_type_from_url_params(content_type_app_name, content_type_model_name)
model = content_type.model_class()
snippet_type_name = get_snippet_type_name(content_type)[0]
items = model.objects.all()
p = request.GET.get("p", 1)
paginator = Paginator(items, 25)
try:
paginated_items = paginator.page(p)
except PageNotAnInteger:
paginated_items = paginator.page(1)
except EmptyPage:
paginated_items = paginator.page(paginator.num_pages)
return render_modal_workflow(
request,
'wagtailsnippets/chooser/choose.html', 'wagtailsnippets/chooser/choose.js',
{
'content_type': content_type,
'snippet_type_name': snippet_type_name,
'items': paginated_items,
}
)
开发者ID:rudyondolan,项目名称:wagtail,代码行数:26,代码来源:chooser.py
示例18: document_chosen
def document_chosen(request, document_id):
document = get_object_or_404(get_document_model(), id=document_id)
return render_modal_workflow(
request, None, 'wagtaildocs/chooser/document_chosen.js',
{'document_json': get_document_json(document)}
)
开发者ID:doru-rocod,项目名称:wagtail,代码行数:7,代码来源:chooser.py
示例19: chooser
def chooser(request):
Document = get_document_model()
if permission_policy.user_has_permission(request.user, "add"):
DocumentForm = get_document_form(Document)
uploadform = DocumentForm()
else:
uploadform = None
documents = []
q = None
is_searching = False
if "q" in request.GET or "p" in request.GET or "collection_id" in request.GET:
documents = Document.objects.all()
collection_id = request.GET.get("collection_id")
if collection_id:
documents = documents.filter(collection=collection_id)
searchform = SearchForm(request.GET)
if searchform.is_valid():
q = searchform.cleaned_data["q"]
documents = documents.search(q)
is_searching = True
else:
documents = documents.order_by("-created_at")
is_searching = False
# Pagination
paginator, documents = paginate(request, documents, per_page=10)
return render(
request,
"wagtaildocs/chooser/results.html",
{"documents": documents, "query_string": q, "is_searching": is_searching},
)
else:
searchform = SearchForm()
collections = Collection.objects.all()
if len(collections) < 2:
collections = None
documents = Document.objects.order_by("-created_at")
paginator, documents = paginate(request, documents, per_page=10)
return render_modal_workflow(
request,
"wagtaildocs/chooser/chooser.html",
"wagtaildocs/chooser/chooser.js",
{
"documents": documents,
"uploadform": uploadform,
"searchform": searchform,
"collections": collections,
"is_searching": False,
},
)
开发者ID:thrawny,项目名称:wagtail,代码行数:60,代码来源:chooser.py
示例20: chooser
def chooser(request, get_results=False):
# Get most popular queries
queries = models.Query.get_most_popular()
# If searching, filter results by query string
query_string = None
if "q" in request.GET:
searchform = SearchForm(request.GET)
if searchform.is_valid():
query_string = searchform.cleaned_data["q"]
queries = queries.filter(query_string__icontains=normalise_query_string(query_string))
else:
searchform = SearchForm()
paginator, queries = paginate(request, queries, per_page=10)
# Render
if get_results:
return render(request, "wagtailsearch/queries/chooser/results.html", {"queries": queries})
else:
return render_modal_workflow(
request,
"wagtailsearch/queries/chooser/chooser.html",
"wagtailsearch/queries/chooser/chooser.js",
{"queries": queries, "searchform": searchform},
)
开发者ID:XLeonardo,项目名称:wagtail,代码行数:26,代码来源:queries.py
注:本文中的wagtail.wagtailadmin.modal_workflow.render_modal_workflow函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论