Exemplo n.º 1
0
def demo():

    username = session.get("username")
    session_token = session.get("session_token")
    if not session_token:
        return redirect(url_for("index"))

    user = Developer()
    user.session_token = session_token
    if user.get_all_demo_application():
        all_demo_application_dict = user.all_demo_application_dict  # 一旦上一步执行成功,会给user添加一个成员变量 all_demo_application_dict
    else:
        print "no demo application  exists"
        all_demo_application_dict = {}
    print "all_demo_application_dict is : %s" % (str(all_demo_application_dict))
    if DEMO_APP_NAME in all_demo_application_dict.keys():
        app_name = DEMO_APP_NAME
        app_id = all_demo_application_dict[app_name]
    else:
        "Demo not exists"
        app_name = None
        app_id = None
    session["app_name"] = app_name
    session["app_id"] = app_id
    # del all_demo_application_dict[app_name]
    print "app_name is %s and app_id is %s" % (str(app_name), str(app_id))
    dashboard = Dashboard()
    dashboard.app_id = app_id
    # all_app_event = 1
    if request.method == "POST":
        is_xhr = True
    else:
        is_xhr = False
    dashboard_link = "/demo"

    return render_template(
        "demo.html",
        is_xhr=is_xhr,
        dashboard_link=dashboard_link,
        route_link="dashboard",
        # sort according to ['16down', '16to35', '35to55', '55up']
        # discard unknown data
        username=username,
        app_name=app_name,
        app_id=app_id,
        all_application_dict={},
    )
Exemplo n.º 2
0
def dash(param):
    username = session.get("username")
    session_token = session.get("session_token")

    if not session_token:
        return redirect(url_for("index"))
    # app_name = request.args.get('app_name')
    # app_id = request.args.get('app_id')
    app_name = session.get("app_name")
    app_id = session.get("app_id")
    print "the app_name is %s and the app_id  is: %s" % (str(app_name), str(app_id))

    user = Developer()
    user.session_token = session_token
    print "Param is %s" % (str(param))
    if param == "dashboard":
        if user.get_all_application():
            all_application_dict = user.all_application_dict  # 一旦上一步执行成功,会给user添加一个成员变量 all_application_dict
        else:
            print "no application  exists"
            all_application_dict = {}
        print "all_application_dict is : %s" % (str(all_application_dict))
        if app_name and app_id:
            del all_application_dict[app_name]
        else:
            app_name = all_application_dict.keys()[0]
            app_id = all_application_dict[app_name]
            del all_application_dict[app_name]
    elif param == "demo":

        if user.get_all_demo_application():
            all_demo_application_dict = (
                user.all_demo_application_dict
            )  # 一旦上一步执行成功,会给user添加一个成员变量 all_demo_application_dict
        else:
            print "no demo application  exists"
            all_demo_application_dict = {}
        print "all_demo_application_dict is : %s" % (str(all_demo_application_dict))
        all_application_dict = {}
        if DEMO_APP_NAME in all_demo_application_dict.keys():
            app_name = DEMO_APP_NAME
            app_id = all_demo_application_dict[app_name]
        else:
            "Demo not exists"
            app_name = None
            app_id = None
    else:
        print "Param is %s" % (str(param))
        all_application_dict = {}

    session["app_name"] = app_name
    session["app_id"] = app_id
    # del all_demo_application_dict[app_name]
    print "app_name is %s and app_id is %s" % (str(app_name), str(app_id))
    dashboard = Dashboard()
    dashboard.app_id = app_id
    # all_app_event = 1
    if request.method == "POST":
        is_xhr = True
    else:
        is_xhr = False
    print "last all_application_dict is : %s" % (str(all_application_dict))

    default_user_profile_category = "Age&Gender"
    default_path_analysis_category = "Frequently Location"
    default_event_name = "Event1"
    default_behavior_recognition_measure = "Activity"

    user_profile_type = "age"
    path_analysis_type = "location"
    event_name_type = "Event1"
    behavior_recognition_measure_type = "activity"

    user_profile_category_dict = dashboard.get_user_profile_category_dict()  # ['Occupation','Tastes']
    path_analysis_measure_dict = dashboard.get_path_analysis_measure_dict()  # ['Frequently Track']
    behavior_recognition_event_dict = dashboard.get_behavior_recognition_event_dict()  # ['event2']
    behavior_recognition_measure_dict = dashboard.get_behavior_recognition_measure_dict()  # ['Location','Time']

    del user_profile_category_dict[user_profile_type]
    del path_analysis_measure_dict[path_analysis_type]
    del behavior_recognition_event_dict[event_name_type]
    del behavior_recognition_measure_dict[behavior_recognition_measure_type]

    print "log comes out !!!!!"
    return render_template(
        "shared/dash.html",
        is_xhr=is_xhr,
        # dashboard_link = dashboard_link,
        route_link="dashboard",
        # sort according to ['16down', '16to35', '35to55', '55up']
        # discard unknown data
        username=username,
        app_name=app_name,
        app_id=app_id,
        all_application_dict=all_application_dict,
        default_user_profile_category=default_user_profile_category,
        default_path_analysis_category=default_path_analysis_category,
        default_event_name=default_event_name,
        default_behavior_recognition_measure=default_behavior_recognition_measure,
        user_profile_type=user_profile_type,
        path_analysis_type=path_analysis_type,
        event_name_type=event_name_type,
        behavior_recognition_measure_type=behavior_recognition_measure_type,
        user_profile_category_dict=user_profile_category_dict,
        path_analysis_measure_dict=path_analysis_measure_dict,
        behavior_recognition_event_dict=behavior_recognition_event_dict,
        behavior_recognition_measure_dict=behavior_recognition_measure_dict,
    )