def admin_users_setlevel(sid: uuid.UUID, level: int): if level not in User.LEVELS: return json_result(-1, "invalid level") user: User = user_api.find_by_uuid(sid) user.level = level user_api.update_by_uuid(sid, user) return json_result(0, "success")
def admin_users_update(sid: uuid.UUID): password = request.form["password"] level = request.form["level"] user: User = user_api.find_by_uuid(sid) if user == None: return json_result(-1, "user not found") user.password = password try: user.level = int(level) except: return json_result(-1, "level is not integer") if user.level not in User.LEVELS: return json_result(-1, "invalid level") user_api.update_by_uuid(sid, user) return json_result(0, "success")
def admin_images(): images = docker_api.image.getImages() result = [] for image in images: rimage = Image() rimage.uid = "system" rimage.uuid = "system" rimage.status = "done" rimage.tag = image["RepoTags"][0] r: Image = docker_api.image.find_by_tag(rimage.tag) if r != None: rimage.uid = r.uid rimage.uuid = r.uuid rimage.status = r.status u: User = user_api.find_by_uuid(rimage.uid) if u != None: rimage.uid = u.username rimage.tag = rimage.tag.replace(":", "-") result += [rimage] return render_template("/admin/image.html", images=result)