From 294d30a464a97946acfd86c9ee1ac07921ed27b2 Mon Sep 17 00:00:00 2001 From: Ed Date: Sun, 6 Aug 2023 12:47:07 +0200 Subject: [PATCH] Translated ita -> eng and tidied for public release --- api.py | 19 +++------------ carpooling.py | 4 +--- config.example.py | 34 ++++++++++++++++++++++++-- export.py | 8 +++---- karaoke.py | 15 ++++-------- propic.py | 7 ++---- stats.py | 5 +--- tpl/base.html | 5 +--- tpl/checkin_1.html | 2 +- tpl/checkin_2.html | 12 +++++----- tpl/checkin_3.html | 10 ++++---- tpl/karaoke_admin.html | 2 +- tpl/stats.html | 54 ------------------------------------------ tpl/welcome.html | 4 ++-- 14 files changed, 63 insertions(+), 118 deletions(-) delete mode 100644 tpl/stats.html diff --git a/api.py b/api.py index e996d84..22e2163 100644 --- a/api.py +++ b/api.py @@ -1,5 +1,5 @@ from sanic import response -from sanic import Blueprint, exceptions +from sanic import Blueprint from ext import * from config import * import sqlite3 @@ -59,8 +59,8 @@ async def api_leaderboard(request): async def send_feedback(request): try: async with httpx.AsyncClient() as client: - r = await client.post("https://api.telegram.org/bot5648800229:AAGr5EJdyo4obXB7pftIcQGjYLAlQdpu1Iw/sendMessage", - json = {'chat_id': -946677603, 'text': str(request.json)} + r = await client.post(f"https://api.telegram.org/bot{TG_BOT_API}/sendMessage", + json = {'chat_id': TG_CHAT_ID, 'text': str(request.json)} ) except: return response.json({'ok': False, 'error': 'There has been an issue sending your feedback.'}) @@ -85,19 +85,6 @@ async def show_events(request): return r -@bp.route("/achievements.json") -async def show_achievements(request): - - if request.token: - user = await request.app.ctx.om.get_order(code=request.token[:5]) - if not user or user.app_token != request.token[5:]: - return response.json({'ok': False, 'error': 'The token you have provided is not valid.'}, status=401) - - with sqlite3.connect('data/boop.db') as db: - db.row_factory = sqlite3.Row - events = db.execute('SELECT * FROM achievement ORDER BY points DESC') - return response.json([{'won_at': '2023-05-05T21:00Z' if request.token and random.random() < 0.2 else None, **dict(x), 'about': 'This is instructions on how to win the field.'} for x in events]) - @bp.get("/logout") async def logout(request): if not request.token: diff --git a/carpooling.py b/carpooling.py index 03f5a82..3b89501 100644 --- a/carpooling.py +++ b/carpooling.py @@ -1,8 +1,6 @@ -from sanic.response import html, redirect, text +from sanic.response import html from sanic import Blueprint, exceptions -from random import choice from ext import * -from config import headers import json bp = Blueprint("carpooling", url_prefix="/manage/carpooling") diff --git a/config.example.py b/config.example.py index b33b7b4..de039d9 100644 --- a/config.example.py +++ b/config.example.py @@ -1,11 +1,41 @@ -headers = {'Host': 'your-pretix-hostname', 'Authorization': 'Token XXXXXXXXXXXXXXXXXXXXXXXX'} -base_url = "https://your-pretix-hostname/api/v1/organizers/organizer-name/events/your-event/" +ORGANIZER = 'furizon' +EVENT_NAME = 'river-side-2023' +API_TOKEN = 'xxxxxxxxxxxxxxxxxxxxxx' +HOSTNAME = 'your-pretix-hostname' + +headers = {'Host': HOSTNAME, 'Authorization': f'Token {API_TOKEN}'} +base_url = f"https://{HOSTNAME}/api/v1/organizers/{ORGANIZER}/events/{EVENT_NAME}/" PROPIC_DEADLINE = 1683575684 FILL_CACHE = True DEV_MODE = True +ITEM_IDS = { + 'ticket': [90,], + 'membership_card': [91,], + 'sponsorship': [], # first one = normal, second = super + 'early_arrival': [], + 'late_departure': [], + 'room': 98 +} + +# Create a bunch of "room" items which will get added to the order once somebody gets a room. +ROOM_MAP = { + 1: 16, + 2: 17, + 3: 18, + 4: 19, + 5: 20 +} + +# This is used for feedback sending inside of the app. Feedbacks will be sent to the specified chat using the bot api id. +TG_BOT_API = '123456789:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +TG_CHAT_ID = -1234567 + +# These order codes have additional functions. +ADMINS = ['XXXXX', 'YYYYY'] + SMTP_HOST = 'your-smtp-host.com' SMTP_USER = 'username' SMTP_PASSWORD = 'password' diff --git a/export.py b/export.py index d6064f4..ad22b11 100644 --- a/export.py +++ b/export.py @@ -1,14 +1,14 @@ from sanic.response import text from sanic import Blueprint, exceptions from ext import * -from config import headers +from config import headers, ADMINS, ORGANIZER, EVENT_NAME 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 not in ['HWUC9','9YKGJ']: raise exceptions.Forbidden("Birichino :)") + if order.code not in ADMINS: raise exceptions.Forbidden("Birichino :)") page = 0 orders = {} @@ -18,7 +18,7 @@ async def export_csv(request, order: Order): while 1: page += 1 - r = httpx.get(f'https://reg.furizon.net/api/v1/organizers/furizon/events/beyond/orders/?page={page}', headers=headers) + r = httpx.get(f'https://reg.furizon.net/api/v1/organizers/{ORGANIZER}/events/{EVENT_NAME}/orders/?page={page}', headers=headers) if r.status_code == 404: break for r in r.json()['results']: @@ -64,7 +64,7 @@ async def export_hotel_csv(request, order: Order): while 1: page += 1 - r = httpx.get(f'https://reg.furizon.net/api/v1/organizers/furizon/events/beyond/orders/?page={page}', headers=headers) + r = httpx.get(f'https://reg.furizon.net/api/v1/organizers/{ORGANIZER}/events/{EVENT_NAME}/orders/?page={page}', headers=headers) if r.status_code == 404: break for r in r.json()['results']: diff --git a/karaoke.py b/karaoke.py index ecf7627..3b2a15b 100644 --- a/karaoke.py +++ b/karaoke.py @@ -1,15 +1,8 @@ from sanic.response import html, redirect, text from sanic import Blueprint, exceptions, response -from random import choice from ext import * -from config import headers, PROPIC_DEADLINE -from PIL import Image -from os.path import isfile -from os import unlink -from io import BytesIO -from hashlib import sha224 -from time import time from urllib.parse import unquote +from config import ADMINS import json bp = Blueprint("karaoke", url_prefix="/manage/karaoke") @@ -17,7 +10,7 @@ bp = Blueprint("karaoke", url_prefix="/manage/karaoke") @bp.get("/admin") async def show_songs(request, order: Order): - if order.code not in ['9YKGJ', 'CMPQG']: + if order.code not in ADMINS: raise exceptions.Forbidden("Birichino") orders = [x for x in request.app.ctx.om.cache.values() if x.karaoke_songs] @@ -35,7 +28,7 @@ async def show_songs(request, order: Order): @bp.post("/approve") async def approve_songs(request, order: Order): - if order.code not in ['9YKGJ', 'CMPQG']: + if order.code not in ADMINS: raise exceptions.Forbidden("Birichino") for song in request.form: @@ -51,7 +44,7 @@ async def sing_song(request, order: Order, songname): 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 ['9YKGJ', 'CMPQG']: + if order.code not in ADMINS: raise exceptions.Forbidden("Birichino") songname = unquote(songname) diff --git a/propic.py b/propic.py index 2a536a7..04a5472 100644 --- a/propic.py +++ b/propic.py @@ -1,11 +1,8 @@ -from sanic.response import html, redirect, text +from sanic.response import html, redirect from sanic import Blueprint, exceptions -from random import choice from ext import * -from config import headers, PROPIC_DEADLINE +from config import PROPIC_DEADLINE from PIL import Image -from os.path import isfile -from os import unlink from io import BytesIO from hashlib import sha224 from time import time diff --git a/stats.py b/stats.py index ae37d1f..2025490 100644 --- a/stats.py +++ b/stats.py @@ -1,9 +1,6 @@ from sanic.response import html -from sanic import Blueprint, exceptions +from sanic import Blueprint from ext import * -from config import headers -from time import time -import asyncio bp = Blueprint("stats", url_prefix="/manage") diff --git a/tpl/base.html b/tpl/base.html index c4100cd..66da42b 100644 --- a/tpl/base.html +++ b/tpl/base.html @@ -88,9 +88,6 @@ Nose Count {% if order %} Carpooling - {% if not order.room_confirmed %} - Roommate Search - {% endif %} Logout {% endif %}
@@ -109,7 +106,7 @@ }); diff --git a/tpl/checkin_1.html b/tpl/checkin_1.html index 9f5e868..7e08e43 100644 --- a/tpl/checkin_1.html +++ b/tpl/checkin_1.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% block main %}
-

Cerca ordine

+

Search order

- + diff --git a/tpl/checkin_3.html b/tpl/checkin_3.html index 3fee8ec..fd01322 100644 --- a/tpl/checkin_3.html +++ b/tpl/checkin_3.html @@ -1,19 +1,19 @@ {% extends "base.html" %} {% block main %}
-

โœ… Checkin effettuato!

-

Ricorda di apporre il numero sul badge! Numero: {{order.badge_id}}

+

โœ… Checkin done!

+

Remember to stick the REG number to the badge! Number: {{order.badge_id}}

-

Altri membri della stessa stanza ({{room_owner.actual_room}})

+

Other members of the same room ({{room_owner.actual_room}})

{% for o in roommates %} - + {% endfor %}
{{o.code}} {{o.name}}{{'Effettua Checkin' if not o.checked_in else 'โœ…'}}{{'Checkin' if not o.checked_in else 'โœ…'}}
-

Effettua un altro checkin โžก๏ธ

+

Checkin somebody else โžก๏ธ

{% endblock %} diff --git a/tpl/karaoke_admin.html b/tpl/karaoke_admin.html index 41a3eb2..14002f5 100644 --- a/tpl/karaoke_admin.html +++ b/tpl/karaoke_admin.html @@ -4,7 +4,7 @@

Karaoke Admin

-

Canzoni da cantare

+

Songs to sing

{% for s in songs if s.approved is not none and (not s.singed) %} diff --git a/tpl/stats.html b/tpl/stats.html deleted file mode 100644 index 1c79bec..0000000 --- a/tpl/stats.html +++ /dev/null @@ -1,54 +0,0 @@ -{% extends "base.html" %} -{% block title %}Furizon 2023 Stats{% endblock %} -{% block main %} - -
-
- - - - -
-

Countries

-
- -
- -

Sponsors

-
- -
- -
-{% endblock %} diff --git a/tpl/welcome.html b/tpl/welcome.html index b0ff984..68c8f4d 100644 --- a/tpl/welcome.html +++ b/tpl/welcome.html @@ -24,7 +24,7 @@ - + {% if order.has_early or order.has_late %} @@ -53,7 +53,7 @@ {% if order.status == 'paid' and order.room_confirmed %}
- Download ticket PDF + Download ticket PDF {% endif %}
When{{' (convention)' if order.has_early or order.has_late else ''}}?30 May โ†’ 3 June 202313 October โ†’ 15 October 2023