55from flask import Blueprint
66from flask import current_app
77from flask import jsonify
8+ from flask import request
89from PyMatcha import redis
910from PyMatcha .errors import NotFoundError
1011from PyMatcha .models .report import Report
1112from PyMatcha .models .view import View
1213from PyMatcha .success import Success
1314from PyMatcha .success import SuccessDeleted
1415from PyMatcha .utils .decorators import debug_token_required
16+ from PyMatcha .utils .decorators import validate_params
1517
1618debug_bp = Blueprint ("debug" , __name__ )
1719
@@ -94,7 +96,7 @@ def delete_reports():
9496 return "" , 204
9597
9698
97- @debug_bp .route ("/debug/reports" )
99+ @debug_bp .route ("/debug/reports" , methods = [ "GET" ] )
98100@debug_token_required
99101def debug_get_all_reports ():
100102 report_list = []
@@ -103,10 +105,26 @@ def debug_get_all_reports():
103105 return jsonify (report_list )
104106
105107
106- @debug_bp .route ("/debug/reports/<uid>" )
108+ @debug_bp .route ("/debug/reports/<uid>" , methods = [ "GET" ] )
107109@debug_token_required
108110def debug_get_user_reports (uid ):
109111 u = get_user (uid )
110112 reports_received = [r .to_dict () for r in u .get_reports_received ()]
111113 reports_sent = [r .to_dict () for r in u .get_reports_sent ()]
112114 return jsonify ({"reports_received" : reports_received , "reports_sent" : reports_sent }), 200
115+
116+
117+ DEBUG_CREATE_FAKE_REPORT = {"reporter_id" : int , "reported_id" : int , "reason" : str , "details" : str }
118+
119+
120+ @debug_bp .route ("/debug/reports" , methods = ["POST" ])
121+ @debug_token_required
122+ @validate_params (DEBUG_CREATE_FAKE_REPORT )
123+ def debug_create_report ():
124+ data = request .get_json ()
125+ reporter_id = data ["reporter_id" ]
126+ reported_id = data ["reported_id" ]
127+ reason = data ["reason" ]
128+ details = data ["details" ]
129+ Report .create (reported_id = reported_id , reporter_id = reporter_id , reason = reason , details = details )
130+ return "" , 204
0 commit comments