def post(self): """ Untag the given document. Request: `POST` `/tags/remove` Request body: {'document_id': @document_id@} """ document_id = self.request.validated['document_id'] document_type = ROUTE_TYPE user_id = self.request.authenticated_userid tag_relation = get_tag_relation(user_id, document_id) if tag_relation: DBSession.delete(tag_relation) DBSession.add(DocumentTagLog( user_id=user_id, document_id=document_id, document_type=document_type, is_creation=False)) else: log.warning( 'tried to delete not existing tag relation ' '({0}, {1})'.format(user_id, document_id)) raise HTTPBadRequest('This document has no such tag.') notify_es_syncer(self.request.registry.queue_config) return {}
def post(self): """ Tag the given document as todo. Creates a tag relation, so that the authenticated user is marking the given document as todo. Request: `POST` `/tags/add` Request body: {'document_id': @document_id@} """ document_id = self.request.validated['document_id'] document_type = ROUTE_TYPE user_id = self.request.authenticated_userid if get_tag_relation(user_id, document_id): raise HTTPBadRequest('This document is already tagged.') DBSession.add(DocumentTag( user_id=user_id, document_id=document_id, document_type=document_type)) DBSession.add(DocumentTagLog( user_id=user_id, document_id=document_id, document_type=document_type, is_creation=True)) notify_es_syncer(self.request.registry.queue_config) return {}
def post(self): """ Follow the given user. Creates a follower relation, so that the authenticated user is following the given user. Request: `POST` `/users/follow` Request body: {'user_id': @user_id@} """ followed_user_id = self.request.validated['user_id'] follower_user_id = self.request.authenticated_userid follower_relation = get_follower_relation(followed_user_id, follower_user_id) if not follower_relation: DBSession.add( FollowedUser(followed_user_id=followed_user_id, follower_user_id=follower_user_id)) return {}
def post(self): """ Follow the given user. Creates a follower relation, so that the authenticated user is following the given user. Request: `POST` `/users/follow` Request body: {'user_id': @user_id@} """ followed_user_id = self.request.validated['user_id'] follower_user_id = self.request.authenticated_userid follower_relation = get_follower_relation( followed_user_id, follower_user_id) if not follower_relation: DBSession.add(FollowedUser( followed_user_id=followed_user_id, follower_user_id=follower_user_id)) return {}