From 823aaf4f132a51d65f2a93f11fa484dfe527bad9 Mon Sep 17 00:00:00 2001 From: Andrea Date: Mon, 8 Jan 2024 23:04:11 +0100 Subject: [PATCH] [Various fixes] Fix nosecount requiring an order to be displayed Fix answer uploading bug Code cleanup in propic --- ext.py | 10 +++++++--- propic.py | 4 ---- tpl/nosecount.html | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ext.py b/ext.py index 345c6ee..cdf335f 100644 --- a/ext.py +++ b/ext.py @@ -194,10 +194,14 @@ class Order: print("POSITION ID IS", self.position_id) for i, ans in enumerate(self.answers): + if TYPE_OF_QUESTIONS[ans['question']] == QUESTION_TYPES["multiple_choice_from_list"]: # if multiple choice + identifier = ans['question_identifier'] + if self.ans(identifier) == "": #if empty answer + await self.edit_answer(identifier, None) # Fix for karaoke fields - if ans['question'] == 40: - del self.answers[i]['options'] - del self.answers[i]['option_identifiers'] + #if ans['question'] == 40: + # del self.answers[i]['options'] + # del self.answers[i]['option_identifiers'] res = await client.patch(join(base_url_event, f'orderpositions/{self.position_id}/'), headers=headers, json={'answers': self.answers}) diff --git a/propic.py b/propic.py index c3fe26f..43d8758 100644 --- a/propic.py +++ b/propic.py @@ -67,8 +67,6 @@ async def upload_propic(request, order: Order): with open(f"res/propic/{fn}_{order.code}_original.jpg", "wb") as f: f.write(body[0].body) - f.flush() - f.close() aspect_ratio = width/height if aspect_ratio > 1: @@ -87,8 +85,6 @@ async def upload_propic(request, order: Order): imgBytes = imgBytes.getvalue() with open(f"res/propic/{fn}_{order.code}_{h}.jpg", "wb") as f: f.write(imgBytes) - f.flush() - f.close() await order.edit_answer_fileUpload(f'{fn}_file', f'{fn}_file_{order.code}_{h}.jpg', 'image/jpeg', imgBytes) except Exception: diff --git a/tpl/nosecount.html b/tpl/nosecount.html index d9edb22..ff91a1b 100644 --- a/tpl/nosecount.html +++ b/tpl/nosecount.html @@ -2,7 +2,7 @@ {% block title %}Furizon 2024 Nosecount{% endblock %} {% block main %}
- {% if order.isAdmin() %} + {% if order and order.isAdmin() %} {% endif %}
@@ -16,7 +16,7 @@ {% if o.code == o.room_id and o.room_confirmed %}

{{o.room_name}} - {% if order.isAdmin() %} + {% if order and order.isAdmin() %}
Rename Unconfirm @@ -49,7 +49,7 @@

{{o.room_name}} {% if o.room_person_no - len(o.room_members) > 0 %} - Remaining slots: {{o.room_person_no - len(o.room_members)}} {% endif %} - {% if order.isAdmin() %} + {% if order and order.isAdmin() %}
Rename Delete -- 2.43.5