2023-01-17 21:24:20 +00:00
|
|
|
from sanic.response import text
|
|
|
|
from sanic import Blueprint, exceptions
|
|
|
|
from ext import *
|
2023-08-06 10:47:07 +00:00
|
|
|
from config import headers, ADMINS, ORGANIZER, EVENT_NAME
|
2023-01-17 21:24:20 +00:00
|
|
|
|
|
|
|
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!")
|
2023-08-06 10:47:07 +00:00
|
|
|
if order.code not in ADMINS: raise exceptions.Forbidden("Birichino :)")
|
2023-01-17 21:24:20 +00:00
|
|
|
|
|
|
|
page = 0
|
|
|
|
orders = {}
|
|
|
|
|
2023-05-08 21:42:44 +00:00
|
|
|
ret = 'status;code;nome;cognome;nick;nazione;tessera;artista;fursuiter;sponsorship;early;late;shirt;roomsize;roommembers;payment;price;refunds;staff\n'
|
2023-01-17 21:24:20 +00:00
|
|
|
|
|
|
|
while 1:
|
|
|
|
page += 1
|
|
|
|
|
2023-08-06 10:47:07 +00:00
|
|
|
r = httpx.get(f'https://reg.furizon.net/api/v1/organizers/{ORGANIZER}/events/{EVENT_NAME}/orders/?page={page}', headers=headers)
|
2023-01-17 21:24:20 +00:00
|
|
|
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),
|
|
|
|
[
|
2023-05-08 21:42:44 +00:00
|
|
|
o.status,
|
2023-01-17 21:24:20 +00:00
|
|
|
o.code,
|
|
|
|
o.first_name,
|
|
|
|
o.last_name,
|
|
|
|
o.name,
|
|
|
|
o.country,
|
|
|
|
o.has_card or '',
|
|
|
|
o.is_artist or '',
|
|
|
|
o.is_fursuiter or '',
|
|
|
|
o.sponsorship or '',
|
|
|
|
o.has_early or '',
|
|
|
|
o.has_late or '',
|
|
|
|
o.shirt_size,
|
|
|
|
len(o.room_members),
|
|
|
|
','.join(o.room_members),
|
|
|
|
o.payment_provider,
|
2023-05-08 21:42:44 +00:00
|
|
|
o.total-o.fees,
|
|
|
|
o.refunds,
|
|
|
|
o.ans('staff_role') or 'attendee',
|
2023-01-17 21:24:20 +00:00
|
|
|
]))) + "\n"
|
|
|
|
|
|
|
|
return text(ret)
|
2023-05-25 22:59:09 +00:00
|
|
|
|
|
|
|
@bp.route("/hotel_export.csv")
|
2023-07-04 21:07:39 +00:00
|
|
|
async def export_hotel_csv(request, order: Order):
|
2023-05-25 22:59:09 +00:00
|
|
|
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
|
|
|
|
|
2023-08-06 10:47:07 +00:00
|
|
|
r = httpx.get(f'https://reg.furizon.net/api/v1/organizers/{ORGANIZER}/events/{EVENT_NAME}/orders/?page={page}', headers=headers)
|
2023-05-25 22:59:09 +00:00
|
|
|
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)
|