From fb46a65b863a8580ca9de7fdff10aef971fb8631 Mon Sep 17 00:00:00 2001 From: Ed Date: Fri, 26 May 2023 00:59:09 +0200 Subject: [PATCH] Added option to export data for hotel checkins --- export.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/export.py b/export.py index 1080d0f..3070fdb 100644 --- a/export.py +++ b/export.py @@ -50,3 +50,38 @@ async def export_csv(request, order: Order): ]))) + "\n" return text(ret) + +@bp.route("/hotel_export.csv") +async def export_csv(request, order: Order): + if not order: raise exceptions.Forbidden("You have been logged out. Please access the link in your E-Mail to login again!") + if order.code not in ['HWUC9','9YKGJ']: raise exceptions.Forbidden("Birichino :)") + + page = 0 + orders = {} + + ret = 'code;nome;cognome;datanascita;posnascita;indirizzo;mail;status\n' + + while 1: + page += 1 + + r = httpx.get(f'https://reg.furizon.net/api/v1/organizers/furizon/events/beyond/orders/?page={page}', headers=headers) + if r.status_code == 404: break + + for r in r.json()['results']: + + o = Order(r) + orders[o.code] = o + + ret += (';'.join(map(lambda x: str(x), + [ + o.code, + o.first_name, + o.last_name, + o.birth_date, + o.birth_location, + o.address, + o.email, + o.status + ]))) + "\n" + + return text(ret)