def get_juror_routes(): """\ The refactored routes for jurors, coming soon. * removed GET('/juror/round/<round_id:int>/tasks', get_tasks) because requests for tasks must be interpreted in the context of an active round. Specifically, ranking rounds must get and submit all tasks at once. * removed POST('/juror/bulk_submit/rating', bulk_submit_rating) and POST('/juror/submit/rating', submit_rating) in favor of the unified submission URL which includes the round_id """ api = [ GET('/juror', get_index), GET('/juror/campaign/<campaign_id:int>', get_campaign), GET('/juror/round/<round_id:int>', get_round), GET('/juror/round/<round_id:int>/tasks', get_tasks_from_round), POST('/juror/round/<round_id:int>/tasks/submit', submit_ratings), POST('/juror/round/<round_id:int>/tasks/skip', skip_rating), GET('/juror/round/<round_id:int>/votes', get_votes_from_round), GET('/juror/round/<round_id:int>/votes-stats', get_votes_stats_from_round), GET('/juror/round/<round_id:int>/ratings', get_ratings_from_round), GET('/juror/round/<round_id:int>/rankings', get_rankings_from_round), POST('/juror/round/<round_id:int>/<entry_id:int>/fave', submit_fave), POST('/juror/round/<round_id:int>/<entry_id:int>/unfave', remove_fave), POST('/juror/round/<round_id:int>/<entry_id:int>/flag', submit_flag), GET('/juror/faves', get_faves) ] ui = [] return api, ui
def get_meta_routes(): api = [ GET('/maintainer/active_users', get_active_users), GET('/logs/audit', get_audit_logs), GET('/logs/api', get_api_log_tail, render_basic), GET('/logs/api_exc', get_api_exc_log_tail, render_basic), GET('/logs/feel', get_frontend_error_log, render_basic), POST('/logs/feel', post_frontend_error_log, render_basic) ] ui = [] return api, ui
def test_debug_server_errors(): app = Application([GET('/', _raiser, render_basic)], debug=True) cl = app.get_local_client() resps = [] resps.append(cl.get('/', headers={'Accept': 'text/plain'})) resps.append(cl.get('/', headers={'Accept': 'text/html'})) json_resp = cl.get('/', headers={'Accept': 'application/json'}) resps.append(json_resp) resps.append(cl.get('/', headers={'Accept': 'application/xml'})) assert all(['RuntimeError' in r.get_data(True) for r in resps]) json_data = json.loads(json_resp.get_data(True)) assert json_data['clastic_version'] == __version__
def create_app(): new_link_mw = PostDataMiddleware({ "target_url": str, "new_alias": str, "expiry_time": int, "max_count": int }) static_app = StaticApplication(STATIC_PATH) routes = [ ("/", home, "home.html"), POST("/submit", add_entry, middlewares=[new_link_mw]), ("/static", static_app), GET("/<alias>", use_entry), ] config_path = os.path.join(CUR_PATH, "erosion.ini") config = ConfigParser() config.read(config_path) host_url = config["erosion"]["host_url"].rstrip("/") + "/" db_path = config["erosion"]["db_path"] if not os.path.isabs(db_path): db_path = os.path.join(os.path.dirname(config_path), db_path) resources = {"host_url": host_url, "db": LinkDB(db_path)} cookie_secret = config["erosion"]["cookie_secret"] cookie_mw = SignedCookieMiddleware(secret_key=cookie_secret) render_factory = AshesRenderFactory(CUR_PATH) return Application( routes, resources=resources, middlewares=[cookie_mw], render_factory=render_factory, )
def get_admin_routes(): """ /role/(object/id/object/id/...)verb is the guiding principle """ api = [GET('/admin', get_index), POST('/admin/add_series', add_series), POST('/admin/series/<series_id:int>/edit', edit_series), POST('/admin/add_organizer', add_organizer), POST('/admin/remove_organizer', remove_organizer), POST('/admin/add_campaign', create_campaign), GET('/admin/users', get_users), GET('/admin/campaigns/', get_campaigns), GET('/admin/campaign/<campaign_id:int>', get_campaign), POST('/admin/campaign/<campaign_id:int>/edit', edit_campaign), POST('/admin/campaign/<campaign_id:int>/cancel', cancel_campaign), POST('/admin/campaign/<campaign_id:int>/add_round', create_round), POST('/admin/campaign/<campaign_id:int>/add_coordinator', add_coordinator), POST('/admin/campaign/<campaign_id:int>/remove_coordinator', remove_coordinator), POST('/admin/campaign/<campaign_id:int>/finalize', finalize_campaign), POST('/admin/campaign/<campaign_id:int>/publish', publish_report), POST('/admin/campaign/<campaign_id:int>/unpublish', unpublish_report), GET('/admin/campaign/<campaign_id:int>/audit', get_campaign_log), POST('/admin/round/<round_id:int>/import', import_entries), POST('/admin/round/<round_id:int>/activate', activate_round), POST('/admin/round/<round_id:int>/pause', pause_round), GET('/admin/round/<round_id:int>', get_round), POST('/admin/round/<round_id:int>/edit', edit_round), POST('/admin/round/<round_id:int>/cancel', cancel_round), GET('/admin/round/<round_id:int>/preview_results', get_round_results_preview), POST('/admin/round/<round_id:int>/advance', advance_round), GET('/admin/round/<round_id:int>/flags', get_flagged_entries), GET('/admin/round/<round_id:int>/disqualified', get_disqualified), POST('/admin/round/<round_id:int>/autodisqualify', autodisqualify), POST('/admin/round/<round_id:int>/<entry_id:int>/disqualify', disqualify_entry), POST('/admin/round/<round_id:int>/<entry_id:int>/requalify', requalify_entry), GET('/admin/round/<round_id:int>/preview_disqualification', preview_disqualification), GET('/admin/round/<round_id:int>/results', get_results), GET('/admin/round/<round_id:int>/results/download', download_results_csv), GET('/admin/round/<round_id:int>/entries', get_round_entries), GET('/admin/round/<round_id:int>/entries/download', download_round_entries_csv), GET('/admin/round/<round_id:int>/reviews', get_round_reviews), GET('/admin/campaign/<campaign_id:int>/report', get_campaign_report_raw)] ui = [GET('/admin/campaign/<campaign_id:int>/report', get_campaign_report, 'report.html')] # TODO: arguably download URLs should go into "ui" as well, # anything that generates a response directly (or doesn't return json) return api, ui