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: 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:
bodyBytesBuff = BytesIO(body[0].body) img = Image.open(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]:
@ -91,28 +88,19 @@ async def upload_propic(request, order: Order):
width, height = img.size width, height = img.size
img.thumbnail((512,512)) img.thumbnail((512,512))
imgBytesBuff = BytesIO() imgBytes = BytesIO()
img.save(imgBytesBuff, format='jpeg') img.save(imgBytes, format='jpeg')
imgBytes = imgBytesBuff.getvalue() imgBytes = imgBytes.getvalue()
with open(f"res/propic/{fn}_{order.code}.jpg", "wb") as f: with open(f"res/propic/{fn}_{order.code}_{h}.jpg", "wb") as f:
f.write(imgBytes) 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: 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}.jpg") await order.edit_answer(fn, f"{fn}_{order.code}_{h}.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,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;} .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,10 +42,16 @@
</em></p> </em></p>
{% endif %} {% endif %}
<div class="grid grid_2x2"> <div class="grid">
<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 ''}} /> {% if order.ans('propic') %}
<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 type="submit" name="submit" value="Delete main image" {{'disabled' if time() > PROPIC_DEADLINE 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 ''}} /> {% 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> </div>
</form> </form>
</details> </details>

View File

@ -75,15 +75,19 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
<p class="grid grid_2x2"> <p class="grid">
{% if order.room_owner %} {% if order.room_owner %}
{% if not order.room_confirmed %} {% 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> {% if len(room_members) == 1 %}
<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 href="/manage/room/delete" role="button">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 %}
{# <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 %} {% endif %}
{% else %} {% else %}
{% if order.room_id and not order.room_confirmed %} {% if order.room_id and not order.room_confirmed %}