From 37519f0b600bfa964070dd4458f439d04499eb79 Mon Sep 17 00:00:00 2001 From: Ed Date: Mon, 8 May 2023 23:42:44 +0200 Subject: [PATCH] Added columns to export function + additional order fixes --- export.py | 10 ++++++---- ext.py | 7 +++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/export.py b/export.py index 8ba4a12..1080d0f 100644 --- a/export.py +++ b/export.py @@ -8,12 +8,12 @@ bp = Blueprint("export", url_prefix="/manage/export") @bp.route("/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 != 'HWUC9': raise exceptions.Forbidden("Birichino :)") + if order.code not in ['HWUC9','9YKGJ']: raise exceptions.Forbidden("Birichino :)") page = 0 orders = {} - ret = 'code;nome;cognome;nick;nazione;tessera;artista;fursuiter;sponsorship;early;late;shirt;roomsize;roommembers;payment;price\n' + ret = 'status;code;nome;cognome;nick;nazione;tessera;artista;fursuiter;sponsorship;early;late;shirt;roomsize;roommembers;payment;price;refunds;staff\n' while 1: page += 1 @@ -24,11 +24,11 @@ async def export_csv(request, order: Order): for r in r.json()['results']: o = Order(r) - if o.status not in ['pending', 'paid']: continue orders[o.code] = o ret += (';'.join(map(lambda x: str(x), [ + o.status, o.code, o.first_name, o.last_name, @@ -44,7 +44,9 @@ async def export_csv(request, order: Order): len(o.room_members), ','.join(o.room_members), o.payment_provider, - o.total-o.fees + o.total-o.fees, + o.refunds, + o.ans('staff_role') or 'attendee', ]))) + "\n" return text(ret) diff --git a/ext.py b/ext.py index 36f4431..23b34a7 100644 --- a/ext.py +++ b/ext.py @@ -25,6 +25,9 @@ class Order: self.sponsorship = None self.has_early = False self.has_late = False + self.first_name = None + self.last_name = None + self.country = None for p in self.data['positions']: if p['item'] in [16, 38]: @@ -54,8 +57,12 @@ class Order: self.total = float(data['total']) self.fees = 0 + self.refunds = 0 for fee in data['fees']: self.fees += float(fee['value']) + + for ref in data['refunds']: + self.refunds += float(ref['amount']) answers = ['payment_provider', 'shirt_size', 'birth_date', 'fursona_name', 'room_confirmed', 'room_id']