Compare commits

..

No commits in common. "456361c5850356b8d01e146aa2665909418343b0" and "9dfacc3b5bec8927d2d46415a55acf39a53c78b5" have entirely different histories.

4 changed files with 27 additions and 34 deletions

View File

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

View File

@ -51,11 +51,6 @@
.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 {
background-image: repeating-linear-gradient(90deg, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff);
text-align: center;

View File

@ -42,10 +42,16 @@
</em></p>
{% endif %}
<div class="grid grid_2x2">
<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 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 ''}} />
<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 ''}} />
<div class="grid">
{% if order.ans('propic') %}
<input type="submit" name="submit" value="Delete main image" {{'disabled' if time() > PROPIC_DEADLINE else ''}} />
{% endif %}
{% 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>
</form>
</details>

View File

@ -75,15 +75,19 @@
{% endif %}
{% endif %}
<p class="grid grid_2x2">
<p class="grid">
{% if order.room_owner %}
{% if not order.room_confirmed %}
{# <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 style="grid-area: 1 / 1 / 2 / 2;" 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>
{% 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 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 role="button" href="javascript:document.getElementById('modal-roomrename').setAttribute('open', 'true');">Rename room</a>
{% endif %}
{% else %}
{% if order.room_id and not order.room_confirmed %}