From 64556c938fdfba4563101f519ab933a1060d065e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sondre=20Gr=C3=B8n=C3=A5s?= <44143748+sondregronas@users.noreply.github.com> Date: Wed, 9 Aug 2023 18:04:07 +0200 Subject: [PATCH] =?UTF-8?q?fix=20=F0=9F=A5=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BookingSystem/api.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/BookingSystem/api.py b/BookingSystem/api.py index c3906ad..6d8a38a 100644 --- a/BookingSystem/api.py +++ b/BookingSystem/api.py @@ -184,14 +184,16 @@ def get_user(userid: str) -> flask.Response: @api.route('/users', methods=['POST']) @login_required() -@handle_api_exception def register_student() -> flask.Response: """Add/update a class in the database.""" con = sqlite3.connect(DATABASE) cur = con.cursor() selected_classroom = flask.request.form.get('classroom') - sanitize({'classroom': VALIDATORS.GROUP}, {'classroom': selected_classroom}) + try: + sanitize({'classroom': VALIDATORS.GROUP}, {'classroom': selected_classroom}) + except APIException as e: + return flask.abort(e.status_code, e.message) data = { 'name': flask.session.get('user').name, @@ -307,7 +309,7 @@ def email_report() -> flask.Response: last_sent = datetime.fromtimestamp(float(mail.get_last_sent())).date() if last_sent and (current_date - last_sent).days < int(interval): raise APIException(f'Ikke sendt - mindre enn {interval} dager siden forrige rapport.', 200) - + return mail.send_report()