def choose_snippet(request, id, content_type_app_name, content_type_model_name): """ Choose snippet and display its representation in the Hallo.js richtext field. """ model = get_snippet_model_from_url_params(content_type_app_name, content_type_model_name) if not user_can_edit_snippet_type(request.user, model): raise PermissionDenied try: model.objects.get(id=id) except ObjectDoesNotExist: return render_modal_workflow( request, None, None, {'error': 'Sorry, an error occurred. Contact support or try again later.'} ) embed_html = embed_to_editor_html(id, content_type_app_name, content_type_model_name) return render_modal_workflow( request, None, 'wagtailembedder/editor/snippet_chosen.js', {'embed_html': embed_html} )
def expand_db_attributes(attrs, for_editor): """ Given a dict of attributes from the <embed> tag, return the real HTML representation. """ if for_editor: return embed_to_editor_html(attrs['id'], attrs['app-name'], attrs['content-type-name']) else: return embed_to_frontend_html(attrs['id'], attrs['app-name'], attrs['content-type-name'])
def choose_snippet(request, id, content_type_app_name, content_type_model_name): content_type = get_content_type_from_url_params(content_type_app_name, content_type_model_name) if not user_can_edit_snippet_type(request.user, content_type): raise PermissionDenied model = content_type.model_class() try: model.objects.get(id=id) except ObjectDoesNotExist: return render_modal_workflow( request, None, None, { 'error': 'Sorry, an error occurred. Contact support or try again later.' }) embed_html = embed_to_editor_html(id, content_type_app_name, content_type_model_name) return render_modal_workflow(request, None, 'wagtailembedder/editor/snippet_chosen.js', {'embed_html': embed_html})
def choose_snippet(request, id, content_type_app_name, content_type_model_name): content_type = get_content_type_from_url_params(content_type_app_name, content_type_model_name) if not user_can_edit_snippet_type(request.user, content_type): raise PermissionDenied model = content_type.model_class() try: model.objects.get(id=id) except ObjectDoesNotExist: return render_modal_workflow( request, None, None, {'error': 'Sorry, an error occurred. Contact support or try again later.'} ) embed_html = embed_to_editor_html(id, content_type_app_name, content_type_model_name) return render_modal_workflow( request, None, 'wagtailembedder/editor/snippet_chosen.js', {'embed_html': embed_html} )