From 645bef564d77460b342ebe05645b6bde92c8e1c4 Mon Sep 17 00:00:00 2001 From: James Southern Date: Tue, 7 Aug 2018 12:44:14 +0100 Subject: [PATCH] Modify marshmallow calls & as per Deimos suggestions in !21 --- tildes/tildes/views/api/web/comment.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/tildes/tildes/views/api/web/comment.py b/tildes/tildes/views/api/web/comment.py index 390ef43..2f33a89 100644 --- a/tildes/tildes/views/api/web/comment.py +++ b/tildes/tildes/views/api/web/comment.py @@ -1,7 +1,6 @@ """Web API endpoints related to comments.""" -from marshmallow.fields import String -from marshmallow.validate import OneOf +from marshmallow.fields import Boolean from pyramid.request import Request from pyramid.response import Response from sqlalchemy.dialects.postgresql import insert @@ -59,8 +58,6 @@ def _increment_topic_comments_seen( request.db_session.execute(statement) mark_changed(request.db_session) - return - @ic_view_config( route_name='topic_comments', @@ -327,26 +324,21 @@ def untag_comment(request: Request, name: CommentTagOption) -> Response: request_method='PUT', permission='mark_read', ) -@use_kwargs({ - 'clear_all_previous': String( - load_from='mark_all_previous', - validate=OneOf(('true', 'false')), - ), -}) +@use_kwargs({'mark_all_previous': Boolean(missing=False,)}) def put_mark_comments_read( request: Request, - clear_all_previous: str = 'false' + mark_all_previous: bool, ) -> Response: """Mark comment(s) read clearing notifications. comment(s) are removed from unread_notifications and the from topics - 'new' count. If the query param clear_all_previous is 'true' all + 'new' count. If the query param mark_all_previous is Truthy all notifications prior to the target will be cleared. """ comment = request.context response = IC_NOOP - if clear_all_previous == 'true': + if mark_all_previous is True: prev_notifications = ( request.query(CommentNotification).filter( CommentNotification.is_unread == True, #noqa