forked from rDrama/rDrama
Refactor admig logic, fix banners path. (#250)
Made the logic of the recent admig upload thread fixes (arguably) more Pythonic, or at least less verbose. Also, the banners path was replaced with a duplicate of the sidebars path during the copypasta. This has been remedied.master
parent
1553435f2b
commit
6656edeefc
|
@ -228,18 +228,16 @@ def api_comment(v):
|
||||||
if image == "": return {"error":"Image upload failed"}
|
if image == "": return {"error":"Image upload failed"}
|
||||||
if v.admin_level > 2 and level == 1:
|
if v.admin_level > 2 and level == 1:
|
||||||
if parent_post.id == 37696:
|
if parent_post.id == 37696:
|
||||||
li = os.listdir('files/assets/images/rDrama/sidebar')
|
li = sorted(os.listdir('files/assets/images/rDrama/sidebar'),
|
||||||
li = [int(x.split('.webp')[0]) for x in li]
|
key=lambda e: int(e.split('.webp')[0]))[-1]
|
||||||
li = sorted(li)
|
num = int(li.split('.webp')[0]) + 1
|
||||||
num = li[-1] + 1
|
|
||||||
filename = f'files/assets/images/rDrama/sidebar/{num}.webp'
|
filename = f'files/assets/images/rDrama/sidebar/{num}.webp'
|
||||||
copyfile(oldname, filename)
|
copyfile(oldname, filename)
|
||||||
process_image(v.patron, filename, 400)
|
process_image(v.patron, filename, 400)
|
||||||
elif parent_post.id == 37697:
|
elif parent_post.id == 37697:
|
||||||
li = os.listdir('files/assets/images/rDrama/sidebar')
|
li = sorted(os.listdir('files/assets/images/rDrama/banners'),
|
||||||
li = [int(x.split('.webp')[0]) for x in li]
|
key=lambda e: int(e.split('.webp')[0]))[-1]
|
||||||
li = sorted(li)
|
num = int(li.split('.webp')[0]) + 1
|
||||||
num = li[-1] + 1
|
|
||||||
filename = f'files/assets/images/rDrama/banners/{num}.webp'
|
filename = f'files/assets/images/rDrama/banners/{num}.webp'
|
||||||
copyfile(oldname, filename)
|
copyfile(oldname, filename)
|
||||||
process_image(v.patron, filename)
|
process_image(v.patron, filename)
|
||||||
|
|
Loading…
Reference in New Issue