Esempio n. 1
0
def login():
    """Homepage with login"""
    # Get all of the authenticated user's friends
    tag_names = [str(tag.tag_name) for tag in Tag.get_all_tags()]
    session['tag_names'] = tag_names
    top_6_tags = Tag.get_most_popular_tags(6)
    return render_template("login.html", top_6_tags=top_6_tags)
Esempio n. 2
0
def init_app():
    # get some global objects
    # create tag dictionary for app-wide use
    if not app.config['post_tags']:
        for tag in Tag.get_all_tags():
            app.config['post_tags'][tag.name] = tag.id

    if not app.config['categories']:
        app.config['categories'] = Category.fetch_all_categories()
Esempio n. 3
0
def post_by_tag(tag_name):
    """the function that shows the relevant post list based on the tags the user select"""
    page = request.args.get('page', 1, type=int)
    posts_all = Post.get_posts_by_tag(tag_name)
    tag_names = [str(tag.tag_name) for tag in Tag.get_all_tags()]

    if posts_all:
        post_ids = [post.post_id for post in posts_all]
        session["post_ids"] = post_ids
        pagination = Post.get_posts_by_tag_pagination(tag=tag_name, page=page)
        posts = pagination.items
        return render_template('post_list_by_tag.html', posts=posts, tag_names=tag_names, tag_name=tag_name,
                               pagination=pagination)
    else:
        flash('your search returns no relevant posts')
        return redirect(url_for('show_all_posts'))
Esempio n. 4
0
def post_question():
    """This is the render the page that users can edit their questions/posts """
    tag_names = [str(tag.tag_name) for tag in Tag.get_all_tags()]
    return render_template("post_question.html", tag_names=tag_names)
Esempio n. 5
0
def tag_list():
    """Show form to create a new tag"""
    tags = Tag.get_all_tags()
    return render_template("./tag_list.html", tags=tags)
Esempio n. 6
0
def edit_post_form(id):
    post = Post.get_single_post(id)
    tags = Tag.get_all_tags()
    return render_template("./edit_post.html", post=post, tags=tags)
Esempio n. 7
0
def create_post(id):
    """Show form to create a new post"""
    user = User.get_single_user(id)
    tags = Tag.get_all_tags()
    return render_template("./create_post.html", user=user, tags=tags)