Browse Source

Modify marshmallow calls & as per Deimos suggestions in !21

merge-requests/21/head
James Southern 7 years ago
parent
commit
645bef564d
  1. 18
      tildes/tildes/views/api/web/comment.py

18
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

Loading…
Cancel
Save