stranck-dev #8
6
admin.py
6
admin.py
|
@ -26,7 +26,7 @@ async def clearCache(request, order:Order):
|
|||
@bp.get('/room/unconfirm/<code>')
|
||||
async def unconfirmRoom(request, code, order:Order):
|
||||
credentialsCheck(request, order)
|
||||
dOrder = await getOrderByCode_safe(request, code)
|
||||
dOrder = await getOrderByCode(request, code, throwException=True)
|
||||
|
||||
if(not dOrder.room_confirmed):
|
||||
raise exceptions.BadRequest("Room is not confirmed!")
|
||||
|
@ -41,7 +41,7 @@ async def unconfirmRoom(request, code, order:Order):
|
|||
@bp.get('/room/delete/<code>')
|
||||
async def deleteRoom(request, code, order:Order):
|
||||
credentialsCheck(request, order)
|
||||
dOrder = await getOrderByCode_safe(request, code)
|
||||
dOrder = await getOrderByCode(request, code, throwException=True)
|
||||
|
||||
ppl = getPeopleInRoomByRoomId(request, code)
|
||||
for p in ppl:
|
||||
|
@ -61,7 +61,7 @@ async def deleteRoom(request, code, order:Order):
|
|||
@bp.post('/room/rename/<code>')
|
||||
async def renameRoom(request, code, order:Order):
|
||||
credentialsCheck(request, order)
|
||||
dOrder = await getOrderByCode_safe(request, code)
|
||||
dOrder = await getOrderByCode(request, code, throwException=True)
|
||||
|
||||
name = request.form.get('name')
|
||||
if len(name) > 64 or len(name) < 4:
|
||||
|
|
6
utils.py
6
utils.py
|
@ -125,10 +125,12 @@ def sizeof_fmt(num, suffix="B"):
|
|||
num /= 1000.0
|
||||
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)
|
||||
if not throwException:
|
||||
return res
|
||||
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
|
||||
|
||||
def getPeopleInRoomByRoomId(request, roomId):
|
||||
|
|
Loading…
Reference in New Issue