Exemplo n.º 1
0
def show():
    if not session.get('session_token'):
        next_url = '/dashboard/group'
        return redirect(url_for('accounts_bp.login') + '?next=' + next_url)

    app_id = session.get('app_id', None)
    developer = Developer()
    developer.session_token = session.get('session_token')
    username = developer.username()
    app_list = developer.get_app_list()
    # tracker_list = developer.get_tracker_of_app(app_id)

    if request.method == 'POST':
        req_type = request.json.get('action')
        if req_type == 'group_list':
            return json.dumps({'group_list': get_groups()})
        elif req_type == 'update':
            args = dict(filter(lambda y: y[0] != 'action' and y[0] != 'id' and y[0] != 'name', dict(request.json).items()))
            args['id'] = request.json.get('id')
            args['name'] = request.json.get('name')
            create_group(args)
            flash("Update group info success!", 'msg')
            return redirect(url_for('dashboard_bp.group'))
        elif req_type == 'delete':
            group_id = request.json.get('id')
            delete_group(group_id)
            flash("Delete group info success!", 'msg')
            return redirect(url_for('dashboard_bp.group'))
        elif req_type == 'label_list':
            return json.dumps(get_label_list())
        else:
            return make_response("invalid action type!")
    print "@## group.show "
    return render_template('dashboard/group-setting.html', username=username,
                           app_id=app_id, app_list=app_list)
Exemplo n.º 2
0
def show():
    context_dict = get_app_list()
    app_id = context_dict['app_id']
    username = context_dict['username']
    app_list = context_dict['app_list']

    developer = Developer()
    developer.session_token = session.get('session_token')
    if request.method == 'POST':
        req_type = request.json.get('type')
        group_id = request.json.get('gourpid')

        if req_type == 'user_list':
            return json.dumps({"userNames": get_tracker_of_app(app_id, group_id=group_id)})

        uid = request.json.get('uid')
        h_start = request.json.get('h_start')
        h_end = request.json.get('h_end')
        e_start = request.json.get('e_start')
        e_end = request.json.get('e_end')
        workday = request.json.get('workday')
        ret_dict = get_attr_of_user(uid, h_start=h_start, h_end=h_end,
                                    e_start=e_start, e_end=e_end, workday=workday == 'workday')
        return bson.json_util.dumps(ret_dict)
    return render_template('dashboard/single-user-motion.html',
                           username=username, app_id=app_id, app_list=app_list)
Exemplo n.º 3
0
def get_app_list():
    ret_dict = {}
    app_id = session.get('app_id')
    developer = Developer()
    developer.session_token = session.get('session_token')
    username = developer.username()
    app_list = developer.get_app_list()
    ret_dict['app_id'] = app_id
    ret_dict['username'] = username
    ret_dict['app_list'] = app_list
    return ret_dict
Exemplo n.º 4
0
def history():
    if not session.get('session_token'):
        next_url = '/dashboard/push'
        return redirect(url_for('accounts_bp.login') + '?next=' + next_url)
    if request.method == "POST":
        print request.json
    app_id = session.get('app_id', None)
    developer = Developer()
    developer.session_token = session.get('session_token')
    username = developer.username()
    app_list = developer.get_app_list()
    tracker_list = developer.get_tracker_of_app(app_id)
    return render_template('dashboard/push-notification-history.html', username=username,
                           app_id=app_id, app_list=app_list, tracker_list=tracker_list)
Exemplo n.º 5
0
def show():
    if not session.get('session_token'):
        next_url = '/dashboard/push'
        return redirect(url_for('accounts_bp.login') + '?next=' + next_url)

    app_id = session.get('app_id', None)
    developer = Developer()
    developer.session_token = session.get('session_token')
    username = developer.username()
    user_id = developer.user_id()
    app_list = developer.get_app_list()
    tracker_list = developer.get_tracker_of_app(app_id)
    if request.method == "POST":
        data = request.json
        data['devId'] = user_id
        data['appId'] = app_id
        url = "http://api.trysenz.com/notifyStrategy/createStrategy"
        rep = post_data(url=url, data=data)
        return make_response(json.dumps(rep))
    return render_template("dashboard/push-notification.html", username=username,
                           app_id=app_id, app_list=app_list, tracker_list=tracker_list)