def admin_panel(): current_user = get_current_user(request) logged_cookie = request.get_cookie("logged") if bool(logged_cookie): if logged_cookie != config['admin.token']: return redirect(f'{basename}/') else: return redirect(f'{basename}/') return dict(boards=Board.select(), current_user=current_user, board_name=None, mods=Anon.select().where(Anon.mod != ""), basename=basename)
def add_board(): if check_admin(request) == 1: return abort(403, "You are not allowed to do this.") name = request.forms.get("name").strip().lower() if any(char in list(punctuation + ' ') for char in name): return abort(400, "Boards can't have symbols in their name.") if Board.select().where(Board.name == name).exists(): return abort(400, "A board with this name already exists.") data = { "name": name, "nsfw": bool(request.forms.get("nsfw")), "title": request.forms.get("title").strip() } board = Board(**data) board.save() board_directory(name) return redirect(f'{basename}/admin')