From ac640c4185071a34b6825b69def3a2d6b1278515 Mon Sep 17 00:00:00 2001 From: Andrea Date: Sun, 18 Feb 2024 11:09:11 +0100 Subject: [PATCH 1/2] [fix] re-added navigation script --- tpl/base.html | 1 + 1 file changed, 1 insertion(+) diff --git a/tpl/base.html b/tpl/base.html index e63aa76..816e443 100644 --- a/tpl/base.html +++ b/tpl/base.html @@ -48,6 +48,7 @@ grid-template-rows: repeat(2, 1fr); } + {% include 'blocks/navbar.html' %} -- 2.43.5 From f8e58fd35d00ccb58311808005de3d0dac931762 Mon Sep 17 00:00:00 2001 From: Andrea Date: Mon, 19 Feb 2024 07:55:23 +0100 Subject: [PATCH 2/2] [wip1] nosecount filters --- app.py | 2 +- config.example.py | 1 + ext.py | 2 +- messages.py | 6 ++++++ stats.py | 20 ++++++++++++++++---- tpl/blocks/room.html | 4 ++++ tpl/nosecount.html | 18 ++++++++++++++++++ 7 files changed, 47 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 6bbdd11..018cbf5 100644 --- a/app.py +++ b/app.py @@ -218,7 +218,7 @@ if __name__ == "__main__": print("Healtchecking...", file=sys.stderr) incPretixRead() res = requests.get(join(domain, "healthcheck"), headers=headers) - if(res.status_code == 200): + if(res.status_code == 200 or SKIP_HEALTHCHECK): break except: pass diff --git a/config.example.py b/config.example.py index f72d50a..861ec21 100644 --- a/config.example.py +++ b/config.example.py @@ -5,6 +5,7 @@ API_TOKEN = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ORGANIZER = 'furizon' EVENT_NAME = 'overlord' HOSTNAME = 'reg.furizon.net' +SKIP_HEALTHCHECK = False headers = {'Host': HOSTNAME, 'Authorization': f'Token {API_TOKEN}'} domain = "http://urlllllllllllllllllllll/" diff --git a/ext.py b/ext.py index 4360783..5b1f913 100644 --- a/ext.py +++ b/ext.py @@ -137,7 +137,7 @@ class Order: return self.data[var] def set_room_errors (self, to_set): - for s in to_set: self.room_errors.append (s) + self.room_errors = to_set def ans(self, name): for p in self.data['positions']: diff --git a/messages.py b/messages.py index 2a3fa24..98fc102 100644 --- a/messages.py +++ b/messages.py @@ -12,6 +12,12 @@ ROOM_UNCONFIRM_TEXT = { 'plain': "Hello {0}\nWe had to unconfirm your room '{1}' due to the following issues:\n{2}\nPlease contact your room's owner or contact our support for further informations at https://furizon.net/contact/.\nThank you\n\nTo manage your booking: https://reg.furizon.net/manage/welcome" } +NOSECOUNT = { + 'filters': { + 'capacity': "Here are some furs that share your room type and don't have a confirmed room." + } +} + LOCALES = { 'shuttle_link': { 'en': 'Book now', diff --git a/stats.py b/stats.py index 15ef5cf..e839b14 100644 --- a/stats.py +++ b/stats.py @@ -1,5 +1,6 @@ from sanic.response import html -from sanic import Blueprint +from sanic import Blueprint, Request +from messages import NOSECOUNT from ext import * bp = Blueprint("stats", url_prefix="/manage") @@ -12,13 +13,24 @@ async def sponsor_count(request, order: Order): tpl = request.app.ctx.tpl.get_template('sponsorcount.html') return html(tpl.render(orders=orders, order=order)) +def calc_filter(orders: dict, filter_cmd: str, order: Order) -> tuple[dict, str]: + if not filter_cmd or len(filter_cmd) == 0 or not orders or len(orders.keys()) == 0: return + if filter_cmd.lower() == "capacity": + return {key:value for key,value in orders.items() if (not value.room_confirmed and value.bed_in_room == order.bed_in_room)}, NOSECOUNT['filters'][filter_cmd.lower()] + else: + return None, None + @bp.route("/nosecount") -async def nose_count(request, order: Order): +async def nose_count(request: Request, order: Order): await request.app.ctx.om.update_cache() orders = {key:value for key,value in sorted(request.app.ctx.om.cache.items(), key=lambda x: len(x[1].room_members), reverse=True) if value.status not in ['c', 'e']} - + filtered: dict = None + filter_message: str = None + for query in request.query_args: + if query[0] == "filter" and order: + filtered, filter_message = calc_filter(orders, query[1], order) if filter else None tpl = request.app.ctx.tpl.get_template('nosecount.html') - return html(tpl.render(orders=orders, order=order)) + return html(tpl.render(orders=orders, order=order, filtered=filtered, filter_header=filter_message)) @bp.route("/fursuitcount") async def fursuit_count(request, order: Order): diff --git a/tpl/blocks/room.html b/tpl/blocks/room.html index 1b9ea67..a10fcfd 100644 --- a/tpl/blocks/room.html +++ b/tpl/blocks/room.html @@ -4,6 +4,10 @@

Room's type: {{ROOM_TYPE_NAMES[order.bed_in_room]}}.

Note! Only people with the same room type can be roommates. If you need help, contact the Furizon's Staff.

+ {% if not order.room_confirmed %} +

Check here for any fur who share your room type.

+ {% endif %} + {# Show alert if room owner has wrong people inside #} {# {% if room_members and quota.get_left(len(room_members)) == 0 and (not order.room_confirmed) %} #} diff --git a/tpl/nosecount.html b/tpl/nosecount.html index 07ea08d..20d59dd 100644 --- a/tpl/nosecount.html +++ b/tpl/nosecount.html @@ -20,6 +20,24 @@

Welcome to the nosecount page! Here you can see all of the available rooms at the convention, as well as the occupants currently staying in each room. Use this page to find your friends and plan your meet-ups.

+ {% if filtered and order %} + {% for person in filtered.values() %} + {% if loop.first %} +
+

{{filter_header}}

+
+ {% endif %} +
+ {% with current=order, order=person, imgSrc='/res/propic/' + (person.ans('propic') or 'default.png'), effects = true, flag = true %} + {% include 'blocks/propic.html' %} + {% endwith %} + +
{{person.ans('fursona_name')}}
+
+ {% if loop.last %}
{% endif %} + {% endfor %} + {% endif %} + {% for o in orders.values() if (o.code == o.room_id and o.room_confirmed) %} {% if loop.first %}
-- 2.43.5