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)
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)
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)
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)