コード例 #1
0
def others():
    """ Generate page to view entries submitted by others """
    if login_check():
        return render_template('others.html',
                               title="Other Users",
                               area_list=db.get_areas())
    return redirect(url_for('index'))
コード例 #2
0
def edit_areas():
    """ Generate page to edit areas """
    if login_check():
        return render_template('edit-areas.html',
                               title="Edit Areas",
                               area_list=db.get_areas())
    return redirect(url_for('index'))
コード例 #3
0
def edit_entry(entry_id):
    """ Generate page to edit an existing entry"""
    if login_check():
        return render_template('new-edit.html',
                               title="Edit Entry",
                               entry=db.get_entry(entry_id),
                               area_list=areas_to_dict(db.get_areas()))
    return redirect(url_for('index'))
コード例 #4
0
def new():
    """ Generate page for making of a new entry"""
    if login_check():
        return render_template('new-edit.html',
                               title="New Entry",
                               entry="",
                               area_list=areas_to_dict(db.get_areas()))
    return redirect(url_for('index'))
コード例 #5
0
def areas():
    """ Return dict of areas and id's """
    if login_check():
        areas_raw = db.get_areas()
        area_dict = {}
        for area in areas_raw:
            area_dict[area['name']] = str(area['_id'])
        return area_dict
    return "Not logged in"
コード例 #6
0
def index(page=1):
    """ Main route returning app homepage or else login page """
    if login_check():
        # Get user stats
        stats = db.get_user_stats(session['user_id'])
        # Check for request data and render home page with filter or without accordingly
        if request.args:
            return render_template('logbook-home.html',
                                   title="Logbook Home",
                                   user_stats=stats,
                                   user_entries=db.get_entries_for_user(
                                       session['user_id'], int(page),
                                       request.args),
                                   area_list=areas_to_dict(db.get_areas()),
                                   set_filters=request.args)
        else:
            return render_template('logbook-home.html',
                                   title="Logbook Home",
                                   user_stats=stats,
                                   user_entries=db.get_entries_for_user(
                                       session['user_id'], int(page)),
                                   area_list=areas_to_dict(db.get_areas()))

    return render_template('login.html')