def board_topics_post(request, board=None, form=None): """Create a new topic. :param request: A :class:`pyramid.request.Request` object. :type request: pyramid.request.Request :rtype: celery.task.Task """ params = _get_params(request) if board is None: board = board_get(request) if form is None: form = TopicForm(params, request=request) if form.validate(): ratelimit = RateLimiter(request, namespace=board.slug) if ratelimit.limited(): timeleft = ratelimit.timeleft() raise RateLimitedError(timeleft) ratelimit.limit(board.settings['post_delay']) return add_topic.delay(request=serialize_request(request), board_id=board.id, title=form.title.data, body=form.body.data) raise ParamsInvalidError(form.errors)
def board_topics_post(request, board=None, form=None): """Create a new topic. :param request: A :class:`pyramid.request.Request` object. :type request: pyramid.request.Request :rtype: celery.task.Task """ params = _get_params(request) if board is None: board = board_get(request) if form is None: form = TopicForm(params, request=request) if form.validate(): ratelimit = RateLimiter(request, namespace=board.slug) if ratelimit.limited(): timeleft = ratelimit.timeleft() raise RateLimitedError(timeleft) ratelimit.limit(board.settings['post_delay']) return add_topic.delay( request=serialize_request(request), board_id=board.id, title=form.title.data, body=form.body.data) raise ParamsInvalidError(form.errors)
def _makeOne(self, *args, **kwargs): from fanboi2.tasks import add_topic return add_topic.delay(*args, **kwargs)