Compare commits

...

2 Commits

Author SHA1 Message Date
Stranck 456361c585 Visual fixes with buttons 2024-01-10 14:04:04 +01:00
Stranck c5fb4fd55d Hash is not used anymore in propics upload 2024-01-10 11:24:24 +01:00
4 changed files with 34 additions and 27 deletions

View File

@ -58,10 +58,13 @@ async def upload_propic(request, order: Order):
if len(body[0].body) > PROPIC_MAX_FILE_SIZE: if len(body[0].body) > PROPIC_MAX_FILE_SIZE:
raise exceptions.BadRequest("File size too large for " + ("Profile picture" if fn == 'propic' else 'Fursuit picture')) raise exceptions.BadRequest("File size too large for " + ("Profile picture" if fn == 'propic' else 'Fursuit picture'))
h = sha224(body[0].body).hexdigest()[:32]
errorDetails = '' errorDetails = ''
bodyBytesBuff = None
imgBytesBuff = None
img = None
try: try:
img = Image.open(BytesIO(body[0].body)) bodyBytesBuff = BytesIO(body[0].body)
img = Image.open(bodyBytesBuff)
width, height = img.size width, height = img.size
# Checking for min / max size # Checking for min / max size
if width < PROPIC_MIN_SIZE[0] or height < PROPIC_MIN_SIZE[1]: if width < PROPIC_MIN_SIZE[0] or height < PROPIC_MIN_SIZE[1]:
@ -88,19 +91,28 @@ async def upload_propic(request, order: Order):
width, height = img.size width, height = img.size
img.thumbnail((512,512)) img.thumbnail((512,512))
imgBytes = BytesIO() imgBytesBuff = BytesIO()
img.save(imgBytes, format='jpeg') img.save(imgBytesBuff, format='jpeg')
imgBytes = imgBytes.getvalue() imgBytes = imgBytesBuff.getvalue()
with open(f"res/propic/{fn}_{order.code}_{h}.jpg", "wb") as f: with open(f"res/propic/{fn}_{order.code}.jpg", "wb") as f:
f.write(imgBytes) f.write(imgBytes)
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}.jpg', 'image/jpeg', imgBytes)
except Exception: except Exception:
import traceback import traceback
if DEV_MODE: print(traceback.format_exc()) if DEV_MODE: print(traceback.format_exc())
raise exceptions.BadRequest(errorDetails if errorDetails else "The image you uploaded is not valid.") raise exceptions.BadRequest(errorDetails if errorDetails else "The image you uploaded is not valid.")
else: else:
await order.edit_answer(fn, f"{fn}_{order.code}_{h}.jpg") await order.edit_answer(fn, f"{fn}_{order.code}.jpg")
if img is not None:
img.close()
if bodyBytesBuff is not None:
bodyBytesBuff.flush()
bodyBytesBuff.close()
if imgBytesBuff is not None:
imgBytesBuff.flush()
imgBytesBuff.close()
await order.send_answers() await order.send_answers()
return redirect("/manage/welcome#badge") return redirect("/manage/welcome#badge")

View File

@ -51,6 +51,11 @@
.tag {background:var(--primary);color:var(--contrast);font-size:0.8em;font-weight:600;padding:0.1em 0.3em;border-radius:3px;} .tag {background:var(--primary);color:var(--contrast);font-size:0.8em;font-weight:600;padding:0.1em 0.3em;border-radius:3px;}
.grid_2x2 {
grid-template-columns: repeat(2, 1fr);
grid-template-rows: repeat(2, 1fr);
}
.rainbow-text { .rainbow-text {
background-image: repeating-linear-gradient(90deg, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff); background-image: repeating-linear-gradient(90deg, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff);
text-align: center; text-align: center;

View File

@ -42,16 +42,10 @@
</em></p> </em></p>
{% endif %} {% endif %}
<div class="grid"> <div class="grid grid_2x2">
{% if order.ans('propic') %} <input style="grid-area: 1 / 1 / 2 / 3;" type="submit" name="submit" value="Upload" {{'disabled' if (order.ans('propic') and order.ans('propic_fursuiter')) else ''}} />
<input type="submit" name="submit" value="Delete main image" {{'disabled' if time() > PROPIC_DEADLINE else ''}} /> <input style="grid-area: 2 / 1 / 3 / 2;" type="submit" name="submit" value="Delete main image" {{'disabled' if (time() > PROPIC_DEADLINE or not order.ans('propic')) else ''}} />
{% endif %} <input style="grid-area: 2 / 2 / 3 / 3;" type="submit" name="submit" value="Delete fursuit image" {{'disabled' if (time() > PROPIC_DEADLINE or not order.ans('propic_fursuiter')) else ''}} />
{% if order.ans('propic_fursuiter') %}
<input type="submit" name="submit" value="Delete fursuit image" {{'disabled' if time() > PROPIC_DEADLINE else ''}} />
{% endif %}
{% if not order.ans('propic') or (order.is_fursuiter and not order.ans('propic_fursuiter')) %}
<input type="submit" name="submit" value="Upload" />
{% endif %}
</div> </div>
</form> </form>
</details> </details>

View File

@ -75,19 +75,15 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
<p class="grid"> <p class="grid grid_2x2">
{% if order.room_owner %} {% if order.room_owner %}
{% if not order.room_confirmed %} {% if not order.room_confirmed %}
{% if len(room_members) == 1 %}
<a href="/manage/room/delete" role="button">Delete room</a>
{% endif %}
{# <a role="button" {% if not room.forbidden and quota.get_left(len(room_members)) > 0 %}href="javascript:document.getElementById('modal-roomconfirm').setAttribute('open', 'true');"{% endif %}>Confirm <strong>{{[None,'single','double','triple','quadruple','quintuple'][len(room_members)]}}</strong> room</a> #} {# <a role="button" {% if not room.forbidden and quota.get_left(len(room_members)) > 0 %}href="javascript:document.getElementById('modal-roomconfirm').setAttribute('open', 'true');"{% endif %}>Confirm <strong>{{[None,'single','double','triple','quadruple','quintuple'][len(room_members)]}}</strong> room</a> #}
<a role="button" {% if not room.forbidden and len(room_members) == order.room_person_no %}href="javascript:document.getElementById('modal-roomconfirm').setAttribute('open', 'true');"{% endif %}>Confirm <strong>{{[None,'single','double','triple','quadruple','quintuple'][order.room_person_no]}}</strong> room</a>
<a style="grid-area: 1 / 1 / 2 / 2;" role="button" href="javascript:document.getElementById('modal-roomrename').setAttribute('open', 'true');">Rename room</a>
<a role="button" href="javascript:document.getElementById('modal-roomrename').setAttribute('open', 'true');">Rename room</a> <a style="grid-area: 1 / 2 / 2 / 3;" href="/manage/room/delete" role="button" {{'disabled' if (len(room_members) > 1) else ''}} >Delete room</a>
<a style="grid-area: 2 / 1 / 3 / 3; display:block;" role="button" {% if not room.forbidden and len(room_members) == order.room_person_no %}href="javascript:document.getElementById('modal-roomconfirm').setAttribute('open', 'true');"{% endif %}>Confirm <strong>{{[None,'single','double','triple','quadruple','quintuple'][order.room_person_no]}}</strong> room</a>
{% endif %} {% endif %}
{% else %} {% else %}
{% if order.room_id and not order.room_confirmed %} {% if order.room_id and not order.room_confirmed %}