Beispiel #1
0
def admin():
    if current_user.name != 'admin':
        return render_template('index.html', name=current_user.name)
    """
    if request.method == "GET":
        users = list(name2id.keys())
        return render_template('admin_top.html', usernames=users)
    else:
    """
    name = request.form["username"]
    """
    load_user_data(user_information, USER_FILE_PATH, name)
    data = user_information[name]

    load_user_data(drink_chart_data, DRINK_CHART_PATH, name)
    drink_data = drink_chart_data[name]
    """
    if name in user_instances:
        user_instances[name].load_file()
    else:
        user_instances[name] = UserInformation(name, USER_PICKLE_FILE_PATH,
                                               DRINK_FILE_PATH,
                                               DRINK_CHART_PATH)
        user_instances[name].load_file()

    instance = user_instances[name]
    data = instance.get_user_format()
    drink_data = instance.get_chart_format()
    return render_template('admin2.html',
                           data=data,
                           drink_data=drink_data,
                           username=name)
Beispiel #2
0
def get_admin_data():
    name = request.form["username"]
    if name in user_instances:
        user_instances[name].load_file()
    else:
        user_instances[name] = UserInformation(name, USER_PICKLE_FILE_PATH,
                                               DRINK_FILE_PATH,
                                               DRINK_CHART_PATH)
        user_instances[name].load_file()

    instance = user_instances[name]
    data = instance.get_user_format()
    drink_data = instance.get_chart_format()
    response = jsonify({'data': data, 'drink_data': drink_data})
    return make_response(response)
Beispiel #3
0
def top_page():
    if current_user.is_authenticated:

        if current_user.name in user_instances:
            user_instances[current_user.name].load_file()
        else:
            user_instances[current_user.name] = UserInformation(
                current_user.name, USER_PICKLE_FILE_PATH, DRINK_FILE_PATH,
                DRINK_CHART_PATH)
            user_instances[current_user.name].load_file()

        date_list = list(user_instances[current_user.name].input_dict.keys())

        return render_template('index.html',
                               name=current_user.name,
                               date_list=date_list)
    else:
        return redirect(url_for('login', modal="false"))