def is_request_data_valid(self, request, **kwargs): instance = SOURCE_TYPE_DB[kwargs['source_type']].get_object(pk=kwargs['source_id']) if isinstance(instance, Exception): return False, 'The source of %s does not exist.' % kwargs['source_id'] kwargs.pop('content') instance = Comment.get_object(user_id=request.user.id, **kwargs) if isinstance(instance, Comment): return False, 'Can not repeat commented.' return True, None
def get_comment_object(self, request, comment_id): return Comment.get_object(pk=comment_id, user_id=request.user.id)
def get_comment_detail(self, request, comment_id): kwargs = {'user_id': request.user.id, 'id': comment_id} return Comment.get_object(**kwargs)