def disc(id: int): headers = { "main": "Forum", "brand": SvgMaster.getFullLogo(), "menu": JsonMaster.htmlifyFile("./templates/json-templates/menu.json", {"activated": ["forum"]}), "user": UserMaster.get_userBar() } discussion = session.query(Discussion).filter(Discussion.id == id).first() return flask.render_template( "general-templates/discussion.html", title="oxygen forum", headers=headers, tags=discussion.tagsfilter(getListTags()), answers=map( lambda x: { "date": x.getBeautifulDate(), 'author': x.get_author_field(), 'text': MarkMaster.markdown_to_html(data=x.text) }, discussion.answers), discussion=discussion.to_dict_beauty(), markdown=MarkMaster.markdown_file_to_html(discussion.get_mrk_file()))
def new(): if not UserMaster.is_auntethicated(): return flask.redirect("/login") elif flask.request.method == 'GET': headers = { "main": "New Discussion", "brand": SvgMaster.getFullLogo(), "menu": JsonMaster.htmlifyFile("./templates/json-templates/menu.json", {"activated": ["forum"]}), "user": UserMaster.get_userBar() } return flask.render_template("general-templates/new-discussion.html", title=headers['main'], headers=headers) elif flask.request.method == 'POST': data = flask.request.json disc = Discussion() disc.author_id = UserMaster.get_user().id disc.header = data['header'] session = Session.create_session() session.add(disc) disc = session.query(Discussion).filter( Discussion.header == data['header'], Discussion.author_id == UserMaster.get_user().id).all()[-1] disc.init_file() disc.set_file(data) session.query(Discussion).filter(Discussion.id == disc.id).update( disc.to_dict()) session.commit() return "end"
def login(): if flogin.current_user.is_authenticated: return flask.redirect('/') elif flask.request.method == 'GET': headers = { "main": "Test Page", "brand": SvgMaster.getFullLogo(), "menu": JsonMaster.htmlifyFile( "./templates/json-templates/menu.json", { "activated": [] } ) } return flask.render_template( "general-templates/login.html", title="login to oxygen", headers=headers ) elif flask.request.method == 'POST': data = flask.request.form user = session.query(User).filter( (User.login==data['login']) | ((User.email==data['login']))).first() print(user, "entered") if user is None or not user.check_password(data['password']): flask.flash(f"Invalid username or password: login: {data['login']}") return flask.redirect('/login') login_user(user, remember=True) # if not flogin.is_safe_url(next): return flask.abort(400) return flask.redirect("/")
def main(): headers = { "main": "Main Page", "brand": SvgMaster.getFullLogo(), "menu": JsonMaster.htmlifyFile("./templates/json-templates/menu.json", {"activated": []}), "user": UserMaster.get_userBar() } return flask.render_template("general-templates/basic.html", title="oxygen", headers=headers)
def register(): if flogin.current_user.is_authenticated: return flask.redirect('/') elif flask.request.method == 'GET': headers = { "main": "Test Page", "brand": SvgMaster.getFullLogo(), "menu": JsonMaster.htmlifyFile( "./templates/json-templates/menu.json", { "activated": [] } ) } return flask.render_template( "general-templates/register.html", title="login to oxygen", headers=headers ) elif flask.request.method == 'POST': data = flask.request.form flask.flash("POST :: ", data) user = User() user.login = data['login'] user.email = data['email'] lst =[ "./static/images/avatars/av/avatar_00.png", "./static/images/avatars/av/avatar_01.png", "./static/images/avatars/av/avatar_02.png" ] from random import choice user.avatar = choice(lst) if(data['password'] == data['password-rep']): user.set_password(data['password']) else: del user return "SHIT" session = Session.create_session() session.add(user) session.commit() return flask.redirect("/login")
def main(): headers = { "main": "Forum", "brand": SvgMaster.getFullLogo(), "menu": JsonMaster.htmlifyFile("./templates/json-templates/menu.json", {"activated": ["tags"]}), "user": UserMaster.get_userBar() } all_tags = session.query(Tag).all() print(all_tags) return flask.render_template("general-templates/tags.html", title="oxygen", headers=headers, tags=all_tags)
def main(): headers = { "main": "Forum", "brand": SvgMaster.getFullLogo(), "menu": JsonMaster.htmlifyFile("./templates/json-templates/menu.json", {"activated": ["forum"]}), "user": UserMaster.get_userBar() } forum = list(session.query(Discussion).all())[::-1] forum = list(map(lambda x: x.to_dict_beauty(), forum)) return flask.render_template("general-templates/forum.html", title="oxygen forum", headers=headers, tags=getListTags(), forum=forum)
def register(): if not UserMaster.is_auntethicated(): return flask.redirect('/') elif flask.request.method == 'GET': headers = { "main": "Test Page", "brand": SvgMaster.getFullLogo(), "menu": JsonMaster.htmlifyFile( "./templates/json-templates/menu.json", { "activated": [] } ), "user": UserMaster.get_userBar() } return flask.render_template( "general-templates/user.html", title="login to oxygen", headers=headers, user=UserMaster.get_user(), adress=flask.request.host )