Ejemplo n.º 1
0
def task_post(environ, start_response):
    request = environ['werkzeug.request']
    board = environ['waka.board']

    if request.method != 'POST':
        raise WakaError("POST only accepted")

    cookie = get_cookie_from_request(request, 'wakaadmin')

    wakapost = WakaPost.from_request(request)

    if wakapost.admin_post:
        return StaffAction(cookie, 'admin_post', wakapost=wakapost,
            board=board).execute()


    # not admin, so let's check for hcaptcha

    style_cookie = get_cookie_from_request(request,
        board.options.get('STYLE_COOKIE', 'wakastyle'))
    hcaptcha = request.values.get('hcaptcha', '').lower()
    is_nokosage = wakapost.email.lower() in ['noko', 'sage']

    import config
    if (config.HCAPTCHA and
        hcaptcha != config.HCAPTCHA_ANSWER and
        not (config.HCAPTCHA_COOKIE_BYPASS and style_cookie != '') and
        not (config.HCAPTCHA_NOKOSAGE_BYPASS and is_nokosage)):

        return Template('hcaptcha_failed',
            question=config.HCAPTCHA_QUESTION,
            answer=config.HCAPTCHA_ANSWER,
        )

    return board.post_stuff(wakapost)
Ejemplo n.º 2
0
def task_post(environ, start_response):
    request = environ['werkzeug.request']
    board = environ['waka.board']

    if request.method != 'POST':
        raise WakaError("POST only accepted")

    admin = get_cookie_from_request(request, 'wakaadmin')

    wakapost = WakaPost.from_request(request)

    if wakapost.admin_post:
        return StaffAction(admin, 'admin_post', wakapost=wakapost,
                           board=board).execute()

    # not admin, so let's check for hcaptcha

    style_cookie = get_cookie_from_request(
        request, board.options.get('STYLE_COOKIE', 'wakastyle'))
    hcaptcha = request.values.get('hcaptcha', '').lower()
    is_nokosage = wakapost.email.lower() in ['noko', 'sage']

    import config
    if (config.HCAPTCHA and hcaptcha != config.HCAPTCHA_ANSWER
            and not (config.HCAPTCHA_COOKIE_BYPASS and style_cookie != '')
            and not (config.HCAPTCHA_NOKOSAGE_BYPASS and is_nokosage)):

        return Template(
            'hcaptcha_failed',
            question=config.HCAPTCHA_QUESTION,
            answer=config.HCAPTCHA_ANSWER,
        )

    return board.post_stuff(wakapost)
Ejemplo n.º 3
0
def task_move(environ, start_response):
    request = environ['werkzeug.request']
    
    kwargs = {}
    kwargs['parent'] = request.values.get('num', '')
    try:
        kwargs['admin'] = get_cookie_from_request(request, 'wakaadmin')
    except KeyError:
        kwargs['admin'] = ''
    kwargs['src_brd_obj'] = environ['waka.board']
    kwargs['dest_brd_obj'] = Board(request.values.get('destboard', ''))
    kwargs['action'] = 'thread_move'

    return StaffAction(**kwargs).execute()
Ejemplo n.º 4
0
def _toggle_thread_state(environ, start_response, operation):
    request = environ['werkzeug.request']
    board = environ['waka.board']

    kwargs = {}
    kwargs['num'] = request.values.get('thread', 0)
    kwargs['board'] = board
    kwargs['action'] = 'thread_' + operation
    try:
        kwargs['admin'] = get_cookie_from_request(request, 'wakaadmin')
    except KeyError:
        kwargs['admin'] = ''

    return StaffAction(**kwargs).execute()
Ejemplo n.º 5
0
def task_move(environ, start_response):
    request = environ['werkzeug.request']

    kwargs = {}
    kwargs['parent'] = request.values.get('num', '')
    try:
        kwargs['admin'] = get_cookie_from_request(request, 'wakaadmin')
    except KeyError:
        kwargs['admin'] = ''
    kwargs['src_brd_obj'] = environ['waka.board']
    kwargs['dest_brd_obj'] = Board(request.values.get('destboard', ''))
    kwargs['action'] = 'thread_move'

    return StaffAction(**kwargs).execute()
Ejemplo n.º 6
0
def _toggle_thread_state(environ, start_response, operation):
    request = environ['werkzeug.request']
    board = environ['waka.board']

    kwargs = {}
    kwargs['num'] = request.values.get('thread', 0)
    kwargs['board'] = board
    kwargs['action'] = 'thread_' + operation
    try:
        kwargs['admin'] = get_cookie_from_request(request, 'wakaadmin')
    except KeyError:
        kwargs['admin'] = ''

    return StaffAction(**kwargs).execute()
Ejemplo n.º 7
0
def task_editpost(environ, start_response):
    request = environ['werkzeug.request']
    board = environ['waka.board']

    if request.method != 'POST':
        raise WakaError("POST only accepted")

    cookie = get_cookie_from_request(request, 'wakaadmin')

    request_post = WakaPost.from_request(request)

    if request_post.admin_post:
        return StaffAction(cookie, 'admin_edit', request_post=request_post,
            board=board).execute()
    else:
        return board.edit_stuff(request_post)
Ejemplo n.º 8
0
def task_editpost(environ, start_response):
    request = environ['werkzeug.request']
    board = environ['waka.board']

    if request.method != 'POST':
        raise WakaError("POST only accepted")

    admin = get_cookie_from_request(request, 'wakaadmin')

    wakapost = WakaPost.from_request(request)

    if wakapost.admin_post:
        return StaffAction(admin, 'admin_edit', wakapost=wakapost,
                           board=board).execute()
    else:
        return board.edit_stuff(wakapost)
Ejemplo n.º 9
0
def task_logout(environ, start_response):
    request = environ['werkzeug.request']

    cookie = get_cookie_from_request(request, 'wakaadmin')
    return staff_interface.do_logout(cookie)
Ejemplo n.º 10
0
def task_logout(environ, start_response):
    request = environ['werkzeug.request']

    cookie = get_cookie_from_request(request, 'wakaadmin')
    return staff_interface.do_logout(cookie)