Esempio n. 1
0
def index(request):
    subreddits = session.query(Subreddit)\
                    .filter(Subreddit.subscribers>100)\
                    .filter(Subreddit.fp_submissions==50)\
                    .filter(Subreddit.all_age_latest<31)\
                    .filter(Subreddit.over18==False)\
                    .order_by(sql_random()).limit(30).all()
    logos = session.query(Subreddit)\
            .filter(Subreddit.logo==True)\
            .filter(Subreddit.all_age_latest<90)\
            .filter(Subreddit.over18==False)\
            .filter(Subreddit.subscribers>100)\
            .order_by(sql_random()).limit(30).all()
    return serve_response('index.html', subreddits=subreddits, logos=logos)
Esempio n. 2
0
def index(request):
    subreddits = (
        session.query(Subreddit)
        .filter(Subreddit.subscribers > 100)
        .filter(Subreddit.fp_submissions == 50)
        .filter(Subreddit.all_age_latest < 31)
        .filter(Subreddit.over18 == False)
        .order_by(sql_random())
        .limit(30)
        .all()
    )
    logos = (
        session.query(Subreddit)
        .filter(Subreddit.logo == True)
        .filter(Subreddit.all_age_latest < 90)
        .filter(Subreddit.over18 == False)
        .filter(Subreddit.subscribers > 100)
        .order_by(sql_random())
        .limit(30)
        .all()
    )
    return serve_response("index.html", subreddits=subreddits, logos=logos)
Esempio n. 3
0
def logos(request, view='random'):
    per_page = 30
    query = session.query(Subreddit).filter(Subreddit.logo == True)
    if view == 'all':
        page = int(request.args.get('page', 1))
        query = query.filter(Subreddit.over18 == False).order_by(
            Subreddit.subscribers.desc())
        pagination = Pagination(query, per_page, page, 'logos')
        return serve_response('logos.html', pagination=pagination, view='all')
    elif view == 'over18':
        page = int(request.args.get('page', 1))
        query = query.filter(Subreddit.over18 == True).order_by(
            Subreddit.subscribers.desc())
        pagination = Pagination(query, per_page, page, 'logos')
        return serve_response('logos.html',
                              pagination=pagination,
                              view='over18')
    else:
        logos = query.filter(Subreddit.over18 == False).filter(
            Subreddit.subscribers > 100).order_by(
                sql_random()).limit(per_page).all()
        return serve_response('logos.html', logos=logos, view='random')
Esempio n. 4
0
def logos(request, view="random"):
    per_page = 30
    query = session.query(Subreddit).filter(Subreddit.logo == True)
    if view == "all":
        page = int(request.args.get("page", 1))
        query = query.filter(Subreddit.over18 == False).order_by(Subreddit.subscribers.desc())
        pagination = Pagination(query, per_page, page, "logos")
        return serve_response("logos.html", pagination=pagination, view="all")
    elif view == "over18":
        page = int(request.args.get("page", 1))
        query = query.filter(Subreddit.over18 == True).order_by(Subreddit.subscribers.desc())
        pagination = Pagination(query, per_page, page, "logos")
        return serve_response("logos.html", pagination=pagination, view="over18")
    else:
        logos = (
            query.filter(Subreddit.over18 == False)
            .filter(Subreddit.subscribers > 100)
            .order_by(sql_random())
            .limit(per_page)
            .all()
        )
        return serve_response("logos.html", logos=logos, view="random")