示例#1
0
def make_report():
    lat = escape(request.get_json()['lat'])
    lng = escape(request.get_json()['lng'])
    description = escape(request.get_json()['description'])
    category_id = escape(request.get_json()['category_id'])
    user_id = session[SESSION_ID_KEY]
    category = category_service.get_by_id(category_id)
    user = user_service.get_by_id(user_id)
    if user is not None and category is not None:
        report = report_service.make_report(lat, lng, description, round(time.time()*1000), user, category)
        return dumps(report_service.report_to_dict(report))
    else:
        return redirect(url_for('not_found'))
示例#2
0
def find_report_by_id(report_id):
    report = report_service.get_by_id(report_id)
    if report is None:
        return redirect(url_for('not_found'))
    return dumps(report_service.report_to_dict(report))