Пример #1
0
def makeChefPage(usr):
    if userSystem.isLoggedIn():
        if userSystem.isAdmin():
            user = User.query.filter(User.id == usr).first()
            user.privileges = User.Privileges.chef
            db_session.add(user)
            db_session.commit()
    return adminPage()
Пример #2
0
def newRecipePage(network_data=None):
    if userSystem.isLoggedIn():
        if network_data is None:
            return render_template('recipes/newRecipe.html')
        else:
            recipe_system.addRecipe(network_data)
            return render_template('index.html')
    else:
        return render_template('/login/login.html')
Пример #3
0
def voteDownPage(recipeId):
    if userSystem.isLoggedIn():
        Vote.query.filter(Vote.fromUser == userSystem.getUserId()).filter(
            Vote.target == recipeId).delete(synchronize_session=False)
        db_session.commit()

        vote = Vote(userSystem.getUserId(), recipeId, Vote.VoteType.down)
        db_session.add(vote)
        db_session.commit()
    return recipePage(recipeId)
Пример #4
0
def registerPage(network_data=None):
    if userSystem.isLoggedIn():
        return render_template('/index.html')
    if network_data is None:
        return render_template('/login/register.html')
    else:
        login = parser.getLogin(network_data)
        password = parser.getPassword(network_data)
        registered = userSystem.tryRegister(login, password)
        if registered:
            return render_template('/index.html')
        else:
            return render_template('/login/register.html', failed=True)
Пример #5
0
def loginPage(network_data=None):
    if userSystem.isLoggedIn():
        return render_template('/index.html')
    if network_data is None:
        return render_template('/login/login.html')
    else:
        login = parser.getLogin(network_data)
        password = parser.getPassword(network_data)
        loggedIn = userSystem.tryLogin(login, password)
        if loggedIn:
            return render_template('/index.html')
        else:
            return render_template('/login/login.html', failed=True)
Пример #6
0
def adminRemoveUserPage(usr):
    if userSystem.isLoggedIn():
        if userSystem.isAdmin():
            userSystem.removeUser(usr)
    return adminPage()
Пример #7
0
def adminPage():
    if userSystem.isLoggedIn():
        if userSystem.isAdmin():
            users = User.query.all()
            return render_template('/login/adminPanel.html', users=users)
    return render_template('/index.html')