示例#1
0
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)
示例#2
0
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)
示例#3
0
 def _makeOne(self, *args, **kwargs):
     from fanboi2.tasks import add_topic
     return add_topic.delay(*args, **kwargs)
示例#4
0
 def _makeOne(self, *args, **kwargs):
     from fanboi2.tasks import add_topic
     return add_topic.delay(*args, **kwargs)