Compare commits

...

2 Commits

Author SHA1 Message Date
stranck 76c8df9e03 Merge pull request '[Various fixes]' (#7) from drew-dev into stranck-dev
Reviewed-on: #7
2024-01-08 22:08:59 +00:00
Andrea 823aaf4f13 [Various fixes]
Fix nosecount requiring an order to be displayed

Fix answer uploading bug

Code cleanup in propic
2024-01-08 23:04:11 +01:00
2 changed files with 7 additions and 7 deletions

10
ext.py
View File

@ -194,10 +194,14 @@ class Order:
print("POSITION ID IS", self.position_id) print("POSITION ID IS", self.position_id)
for i, ans in enumerate(self.answers): 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 # Fix for karaoke fields
if ans['question'] == 40: #if ans['question'] == 40:
del self.answers[i]['options'] # del self.answers[i]['options']
del self.answers[i]['option_identifiers'] # 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}) res = await client.patch(join(base_url_event, f'orderpositions/{self.position_id}/'), headers=headers, json={'answers': self.answers})

View File

@ -68,8 +68,6 @@ async def upload_propic(request, order: Order):
with open(f"res/propic/{fn}_{order.code}_original.jpg", "wb") as f: with open(f"res/propic/{fn}_{order.code}_original.jpg", "wb") as f:
f.write(body[0].body) f.write(body[0].body)
f.flush()
f.close()
aspect_ratio = width/height aspect_ratio = width/height
if aspect_ratio > 1: if aspect_ratio > 1:
@ -88,8 +86,6 @@ async def upload_propic(request, order: Order):
imgBytes = imgBytes.getvalue() imgBytes = imgBytes.getvalue()
with open(f"res/propic/{fn}_{order.code}_{h}.jpg", "wb") as f: with open(f"res/propic/{fn}_{order.code}_{h}.jpg", "wb") as f:
f.write(imgBytes) 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) await order.edit_answer_fileUpload(f'{fn}_file', f'{fn}_file_{order.code}_{h}.jpg', 'image/jpeg', imgBytes)
except Exception: except Exception: