예제 #1
0
def stats():
    um = UsersModel(db.get_connection())
    users_list = um.get_all()
    nm = NewsModel(db.get_connection())
    news_list = nm.get_all()
    stats_list = []
    for item in users_list:
        hobosti = list(
            filter(lambda x: x == item[0], map(lambda x: x[3], news_list)))
        stats_list.append([item[1], len(hobosti)])
    return render_template('stats.html', stats_list=stats_list)
예제 #2
0
def show_user(uname):
    if 'username' not in session:
        return redirect('/login')
    nm = NewsModel(db.get_connection())
    nm.init_table()
    um = UsersModel(db.get_connection())
    um.init_table()
    em = um.get_email(session['username'])
    image = um.get_avatar(uname)
    if uname == session['username']:
        owning = 'True'
    else:
        owning = 'False'
    if request.method == "GET":
        print(nm.get_all(uname))
        return render_template('account.html',
                               username=uname,
                               news=nm.get_all(uname),
                               email=em,
                               own=owning,
                               image=image)
예제 #3
0
파일: main.py 프로젝트: sadboyyy/fatnet
def subscriptions():
    subscribes = SubscribeModel(db.get_connection())
    user_subscriptions = subscribes.get_all(session['user_id'])
    user_model = UsersModel(db.get_connection())
    news = NewsModel(db.get_connection())
    for_post = []
    for _, user in user_subscriptions:
        for_post.extend([
            list(i) + [user_model.get(user)[1]]
            for i in reversed(news.get_all(user))
        ])
    return render_template('subscriptions.html', news=for_post)
예제 #4
0
파일: main.py 프로젝트: Kaisa1906/--
def index():
    nm = NewsModel(db.get_connection())
    news = nm.get_all()
    if len(news) >= 3:
        new = [news[-1], news[-2], news[-3]]
    else:
        new = news
    if 'username' not in session:
        return render_template('index.html', text="Авторизироваться", news=new)
    return render_template('index.html',
                           text='Личный кабинет',
                           news=new,
                           username=session['username'])
예제 #5
0
def main():
    if 'username' not in session:
        return redirect('/login')
    nm = NewsModel(db.get_connection())
    nm.init_table()
    um = UsersModel(db.get_connection())
    um.init_table()
    # nm.delete_all()
    if request.method == "POST":
        content = request.form["comment"]
        # content = request.files["uploadingfiles"]
        avatar = um.get_avatar(session['username'])
        print(avatar)
        nm.insert(str(time.asctime(time.localtime(time.time()))), content,
                  session['username'], avatar)
        for i in nm.get_all():
            check_if_avatar_exists(i)
        return redirect("/main")
    else:
        print(nm.get_all())
        return render_template('home.html',
                               title='Добавление новости',
                               username=session['username'],
                               news=nm.get_all())
예제 #6
0
def my_page():
    if 'username' not in session:
        return redirect('/login')
    if request.method == 'GET':
        nm = NewsModel(db.get_connection())
        nm.init_table()
        um = UsersModel(db.get_connection())
        um.init_table()
        em = um.get_email(session['username'])
        uname = session['username']
        image = um.get_avatar(uname)
        return render_template('account.html',
                               username=uname,
                               news=nm.get_all(uname),
                               email=em,
                               own="True",
                               image=image)
예제 #7
0
파일: main.py 프로젝트: Kaisa1906/--
def news_list():
    nm = NewsModel(db.get_connection())
    news = nm.get_all()
    return render_template('news_list.html',
                           username=session['username'],
                           news=news)