From f9806eada4649294a2e71adb3dcfdf3f2b888156 Mon Sep 17 00:00:00 2001 From: Deimos Date: Wed, 14 Aug 2019 16:30:28 -0600 Subject: [PATCH] Preview: Use wiki page schema instead of comment Previews for large wiki pages were failing because their maximum length is a lot longer than comments'. Basing it on a specific markdown "location" isn't ideal, but wiki pages will almost certainly always be the longest, so it's probably fine. --- tildes/tildes/views/api/web/markdown_preview.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tildes/tildes/views/api/web/markdown_preview.py b/tildes/tildes/views/api/web/markdown_preview.py index c03c2f1..52b15f5 100644 --- a/tildes/tildes/views/api/web/markdown_preview.py +++ b/tildes/tildes/views/api/web/markdown_preview.py @@ -7,7 +7,7 @@ from pyramid.request import Request from webargs.pyramidparser import use_kwargs from tildes.lib.markdown import convert_markdown_to_safe_html -from tildes.schemas.comment import CommentSchema +from tildes.schemas.group_wiki_page import GroupWikiPageSchema from tildes.views.decorators import ic_view_config @@ -16,7 +16,8 @@ from tildes.views.decorators import ic_view_config request_method="POST", renderer="markdown_preview.jinja2", ) -@use_kwargs(CommentSchema(only=("markdown",))) +# uses GroupWikiPageSchema because it should always have the highest max_length +@use_kwargs(GroupWikiPageSchema(only=("markdown",))) def markdown_preview(request: Request, markdown: str) -> dict: """Render the provided text as Markdown.""" # pylint: disable=unused-argument