22
33from logging import getLogger
44
5- import sqlalchemy
5+ import sqlalchemy . exc
66from fastapi import APIRouter , BackgroundTasks , Request , UploadFile , status
77from fastapi .responses import HTMLResponse , RedirectResponse
88from pydantic import ValidationError
@@ -944,9 +944,16 @@ class BlogPostMediaForm(Form):
944944 "Upload media file" ,
945945 validators = [
946946 validators .DataRequired (),
947- custom_validators .is_allowed_extension (
948- ["jpg" , "jpeg" , "png" , "gif" , "webp" , "svg" , "mp4" , "webm" ]
949- ),
947+ custom_validators .is_allowed_extension ([
948+ "jpg" ,
949+ "jpeg" ,
950+ "png" ,
951+ "gif" ,
952+ "webp" ,
953+ "svg" ,
954+ "mp4" ,
955+ "webm" ,
956+ ]),
950957 ],
951958 )
952959
@@ -958,20 +965,18 @@ async def edit_bp_get(
958965) -> _TemplateResponse :
959966 """Return page to edit a blog post."""
960967 bp = await blog_handler .get_bp_from_id (db = db , bp_id = bp_id )
961- form = BlogPostForm .load (
962- {
963- "is_new" : False ,
964- "title" : bp .title ,
965- "tags" : ", " .join ([tag .tag for tag in bp .tags ]),
966- "can_comment" : bp .can_comment ,
967- "is_published" : bp .is_published ,
968- "description" : bp .markdown_description ,
969- "content" : bp .markdown_content ,
970- "thumbnail_url" : bp .thumbnail_location or "" ,
971- "series_id" : bp .series_id or "" ,
972- "series_position" : bp .series_position or "" ,
973- }
974- )
968+ form = BlogPostForm .load ({
969+ "is_new" : False ,
970+ "title" : bp .title ,
971+ "tags" : ", " .join ([tag .tag for tag in bp .tags ]),
972+ "can_comment" : bp .can_comment ,
973+ "is_published" : bp .is_published ,
974+ "description" : bp .markdown_description ,
975+ "content" : bp .markdown_content ,
976+ "thumbnail_url" : bp .thumbnail_location or "" ,
977+ "series_id" : bp .series_id or "" ,
978+ "series_position" : bp .series_position or "" ,
979+ })
975980
976981 return templates .TemplateResponse (
977982 request ,
0 commit comments