示例#1
0
def show_current_session(session_id=None):
    if session_id is None:
        return redirect('/session/viewall')

    db = Database()
    # get all current entries and load up
    session_name = db.get_session_name(session_id)
    entries = []
    for db_entry in db.get_entries_for_session(session_id):
        entry = {
            'entry_id': db_entry['entry_id'],
            'value': db_entry['value'],
            'time_created': db_entry['time_created']
        }

        if not is_logged_in():
            entry['can_update'] = False
        else:
            if db.is_user_id_administrator(
                    flask_session['user_id']
            ) or db_entry['creator_id'] == flask_session['user_id']:
                entry['can_update'] = True
        entries.append(entry)
    return render_template('view_session.html',
                           session_name=session_name,
                           entries=entries)
示例#2
0
def console():
    if not is_logged_in():  # REDIRECT TO LOGIN
        flash('You must be logged in to view this.', 'danger')
        return redirect('/')

    if not is_current_session_set():  # REDIRECT TO VIEW SESSIONS PAGE
        flash('You must have a current session set to view this.', 'danger')
        return redirect('/')

    db = Database()
    actions_ul = []
    actions_ur = []
    actions_ll = []

    for action in db.get_entry_options_by_category_id(1):
        actions_ul.append({
            'value': action['value'],
            'color_class': action['color_class'],
            'category': action['category_name']
        })

    for action in db.get_entry_options_by_category_id(2):
        actions_ur.append({
            'value': action['value'],
            'color_class': action['color_class'],
            'category': action['category_name']
        })

    for action in db.get_entry_options_by_category_id(3):
        actions_ll.append({
            'value': action['value'],
            'color_class': action['color_class'],
            'category': action['category_name']
        })
        actions_ul.append({
            'value': action['value'],
            'color_class': action['color_class'],
            'category': action['category_name']
        })

    session_id = session['current_session_id']
    dates = []

    for db_entry in db.get_entries_for_session(session_id):
        dates += [getDate(db_entry['time_created'])]
    dates = list(sorted(set(dates), key=dates.index))
    data = getData(dates, db.get_internal_entries_for_session(session_id))

    return render_template('console.html',
                           actions_ul=actions_ul,
                           actions_ur=actions_ur,
                           actions_ll=actions_ll,
                           data=data)