Esempio n. 1
0
def admin_only():
    if 'username' not in session:
        return redirect('/login')
    news = NewsModel(news_db.get_connection()).get_all()
    news.sort(key=lambda x: x[3])
    user_model = UsersModel(users_db.get_connection())
    usernames = {}
    for item in news:
        data = user_model.get(item[4])
        if item[4] not in usernames:
            usernames.update(
                {item[4]: [str(data[2] + ' ' + data[3]), data[1]]})
    return render_template('index.html',
                           username=session['username'],
                           news=news,
                           users=usernames)
Esempio n. 2
0
def index():
    if 'username' not in session:
        return redirect('/ban')
    news = NewsModel(news_db.get_connection()).get_all(session['user_id'])
    news.sort(key=lambda x: x[3])
    news.reverse()
    user_model = UsersModel(users_db.get_connection())
    usernames = {}
    for item in news:
        data = user_model.get(item[4])
        if item[4] not in usernames:
            usernames.update(
                {item[4]: [str(data[2] + ' ' + data[3]), data[1]]})

    return render_template('index.html',
                           title='a',
                           username=session['username'],
                           cur_user_id=session['user_id'],
                           news=news,
                           users=usernames)
Esempio n. 3
0
def user_data(user_id):
    if 'username' not in session:
        return redirect('/ban')
    user_model = UsersModel(users_db.get_connection())
    data = user_model.get(user_id)
    news = NewsModel(news_db.get_connection()).get_all(user_id)
    path = data[6]
    if session['user_id'] == user_id:
        my_page = True
    else:
        my_page = False
    name_surname = data[2] + ' ' + data[3]
    return render_template('user_data.html',
                           title=name_surname,
                           my_page=my_page,
                           cur_user_id=session['user_id'],
                           path=path,
                           name=data[2],
                           surname=data[3],
                           status=data[4],
                           news=news)
Esempio n. 4
0
def personal():
    user_model = UsersModel(u_db.get_connection())
    row = list(user_model.get(session['user_id']))
    snippet = {
        'Логин': '',
        'Пароль': '',
        'Номер карты': '',
        'Дата истечения': '',
        'Имя': '',
        'Трехзначный код': '',
        'Баланс': ''
    }
    i = 1
    for el in snippet:
        if i == 4:
            snippet[el] = str(row[i]) + '/' + str(row[i + 1])
            i += 2
        else:
            snippet[el] = str(row[i])
            i += 1
    tuple_s = []
    for el in snippet:
        tuple_s.append((el, snippet[el]))
    return render_template('personal.html', lists=tuple_s)