[Various fixes]

Fix nosecount requiring an order to be displayed

Fix answer uploading bug

Code cleanup in propic
This commit is contained in:
Andrea 2024-01-08 23:04:11 +01:00
parent 53232de597
commit 823aaf4f13
3 changed files with 10 additions and 10 deletions

10
ext.py
View File

@ -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})

View File

@ -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:

View File

@ -2,7 +2,7 @@
{% block title %}Furizon 2024 Nosecount{% endblock %}
{% block main %}
<main class="container">
{% if order.isAdmin() %}
{% if order and order.isAdmin() %}
<script src="/res/scripts/roomManager.js"></script>
{% endif %}
<header>
@ -16,7 +16,7 @@
{% if o.code == o.room_id and o.room_confirmed %}
<h4 style="margin-top:1em;">
<span>{{o.room_name}}</span>
{% if order.isAdmin() %}
{% if order and order.isAdmin() %}
<div class="room-actions">
<a onclick="confirmAction('rename', this)" action="/manage/admin/room/rename/{{o.code}}"><img src="/res/icons/pencil.svg" class="icon" /><span>Rename</span></a>
<a onclick="confirmAction('unconfirm', this)" action="/manage/admin/room/unconfirm/{{o.code}}"><img src="/res/icons/door_open.svg" class="icon" /><span>Unconfirm</span></a>
@ -49,7 +49,7 @@
<h3>
<span>{{o.room_name}}</span>
{% if o.room_person_no - len(o.room_members) > 0 %} <span class="nsc-room-counter"> - Remaining slots: {{o.room_person_no - len(o.room_members)}}</span> {% endif %}
{% if order.isAdmin() %}
{% if order and order.isAdmin() %}
<div class="room-actions">
<a onclick="confirmAction('rename', this)" action="/manage/admin/room/rename/{{o.code}}"><img src="/res/icons/pencil.svg" class="icon" /><span>Rename</span></a>
<a class="act-del" onclick="confirmAction('delete', this)" action="/manage/admin/room/delete/{{o.code}}"><img src="/res/icons/delete.svg" class="icon" /><span>Delete</span></a>