Merge pull request 'stranck-dev' (#8) from stranck-dev into drew-dev

Reviewed-on: #8
This commit is contained in:
drew 2024-01-08 23:09:45 +00:00
commit 8496c89977
6 changed files with 12 additions and 8 deletions

View File

@ -26,7 +26,7 @@ async def clearCache(request, order:Order):
@bp.get('/room/unconfirm/<code>') @bp.get('/room/unconfirm/<code>')
async def unconfirmRoom(request, code, order:Order): async def unconfirmRoom(request, code, order:Order):
credentialsCheck(request, order) credentialsCheck(request, order)
dOrder = await getOrderByCode_safe(request, code) dOrder = await getOrderByCode(request, code, throwException=True)
if(not dOrder.room_confirmed): if(not dOrder.room_confirmed):
raise exceptions.BadRequest("Room is not confirmed!") raise exceptions.BadRequest("Room is not confirmed!")
@ -41,7 +41,7 @@ async def unconfirmRoom(request, code, order:Order):
@bp.get('/room/delete/<code>') @bp.get('/room/delete/<code>')
async def deleteRoom(request, code, order:Order): async def deleteRoom(request, code, order:Order):
credentialsCheck(request, order) credentialsCheck(request, order)
dOrder = await getOrderByCode_safe(request, code) dOrder = await getOrderByCode(request, code, throwException=True)
ppl = getPeopleInRoomByRoomId(request, code) ppl = getPeopleInRoomByRoomId(request, code)
for p in ppl: for p in ppl:
@ -61,7 +61,7 @@ async def deleteRoom(request, code, order:Order):
@bp.post('/room/rename/<code>') @bp.post('/room/rename/<code>')
async def renameRoom(request, code, order:Order): async def renameRoom(request, code, order:Order):
credentialsCheck(request, order) credentialsCheck(request, order)
dOrder = await getOrderByCode_safe(request, code) dOrder = await getOrderByCode(request, code, throwException=True)
name = request.form.get('name') name = request.form.get('name')
if len(name) > 64 or len(name) < 4: if len(name) > 64 or len(name) < 4:

View File

@ -18,7 +18,8 @@ async def resetDefaultPropic(request, order: Order, isFursuiter, sendAnswer=True
data = f.read() data = f.read()
f.close() f.close()
os.remove(f"res/propic/{order.ans(f'propic{s}')}") # converted file os.remove(f"res/propic/{order.ans(f'propic{s}')}") # converted file
os.remove(f"res/propic/{order.ans(f'propic{s}').split(".jpg")[0]}_original.jpg") # original file filenameNoExt = order.ans(f'propic{s}').split(".jpg")[0]
os.remove(f"res/propic/{filenameNoExt}_original.jpg") # original file
await order.edit_answer_fileUpload(f'propic{s}_file', f'propic{s}_file_{order.code}_default.png', 'image/png', data) await order.edit_answer_fileUpload(f'propic{s}_file', f'propic{s}_file_{order.code}_default.png', 'image/png', data)
if(sendAnswer): if(sendAnswer):
await order.send_answers() await order.send_answers()

View File

@ -18,6 +18,7 @@ function confirmAction (intent, sender) {
intentEditPanel.style.display = 'block'; intentEditPanel.style.display = 'block';
intentEdit.setAttribute('required', true) intentEdit.setAttribute('required', true)
intentFormAction.setAttribute('method', 'POST') intentFormAction.setAttribute('method', 'POST')
document.getElementById("intentRename").value = sender.parentElement.parentElement.querySelector("span").innerText;
break break
case 'unconfirm': case 'unconfirm':
break break

View File

@ -54,7 +54,7 @@
<form method="POST" action="/manage/room/rename"> <form method="POST" action="/manage/room/rename">
<label for="name"></label> <label for="name"></label>
<input type="text" name="name" required minlength="4" maxlength="64" /> <input type="text" name="name" required minlength="4" maxlength="64" value="{{order.ans('room_name')}}"/>
<input type="submit" value="Rename room" /> <input type="submit" value="Rename room" />
</form> </form>
</article> </article>

View File

@ -15,7 +15,7 @@
<div class="grid people" style="padding-bottom:1em;"> <div class="grid people" style="padding-bottom:1em;">
{% endif %} {% endif %}
<div style="margin-bottom: 1em;"> <div style="margin-bottom: 1em;">
{% with order=person, imgSrc='/res/propic/' + (person.ans('propic_fursuiter') or 'default.png'), effects = false, flag = true %} {% with order=person, imgSrc='/res/propic/' + (person.ans('propic_fursuiter') or 'default.png'), effects = true, flag = true %}
{% include 'blocks/propic.html' %} {% include 'blocks/propic.html' %}
{% endwith %} {% endwith %}
<h5>{{person.ans('fursona_name')}}</h5> <h5>{{person.ans('fursona_name')}}</h5>

View File

@ -125,10 +125,12 @@ def sizeof_fmt(num, suffix="B"):
num /= 1000.0 num /= 1000.0
return f"{num:.1f}Yi{suffix}" return f"{num:.1f}Yi{suffix}"
async def getOrderByCode_safe(request, code): async def getOrderByCode(request, code, throwException=False):
res = await request.app.ctx.om.get_order(code=code) res = await request.app.ctx.om.get_order(code=code)
if not throwException:
return res
if res is None: if res is None:
raise exceptions.BadRequest(f"[getOrderByCode_safe] Code {code} not found!") raise exceptions.BadRequest(f"[getOrderByCode] Code {code} not found!")
return res return res
def getPeopleInRoomByRoomId(request, roomId): def getPeopleInRoomByRoomId(request, roomId):