示例#1
0
def target_data():
    target_ids = flask.request.args.getlist('other_targets', None)
    aichi_targets = []

    for target_id in target_ids:
        aichi_target = mongo.db.targets.find_one_or_404({"id": target_id})
        data = {
            'title': sugar.translate(aichi_target['title']),
            'description': sugar.translate(aichi_target['description'])
        }
        aichi_targets.append(data)

    result = {'result': aichi_targets}
    return flask.jsonify(result)
示例#2
0
def eu_actions_data():
    myactions = schema.common.get_bodies_for_actions()
    actions_ids = flask.request.args.getlist('eu_actions', None)

    eu_actions = []

    for action_id in actions_ids:
        data = {
            'title': sugar.translate(myactions[action_id]['title']),
            'description': sugar.translate(myactions[action_id]['body'])
        }
        eu_actions.append(data)

    result = {'result': eu_actions}
    return flask.jsonify(result)
示例#3
0
def goal_data():
    try:
        goal_short_title = flask.request.args.getlist('goal_short_title')[0]
    except IndexError:
        return flask.jsonify({'result': ''})

    aichi_goal = mongo.db.goals.find_one_or_404({"short_title":
                                                 goal_short_title})
    result = {'result': sugar.translate(aichi_goal['description'])}

    return flask.jsonify(result)
示例#4
0
def eu_targets_for_actions():
    targets_ids = flask.request.args.getlist('eu_targets', None)

    all_actions = schema.common.get_full_eu_actions_from_db()
    result = []
    for target_id in targets_ids:
        result.extend([{
                    'name': a['key'],
                    'value': sugar.translate(a['title'])
                  } for a in all_actions if
                  a['key'].startswith('a%s' % int(target_id))])

    import json
    return json.dumps(result)
示例#5
0
def eu_targets_data():
    targets_ids = flask.request.args.getlist('eu_targets', None)

    eu_targets = []

    for target_id in targets_ids:
        db_target = mongo.db.eu_targets.find_one_or_404({'id': int(target_id)})
        data = {
            'description': sugar.translate(db_target['title']),
        }
        eu_targets.append(data)

    result = {'result': eu_targets}
    return flask.jsonify(result)
示例#6
0
def objective_data():
    try:
        id_code = flask.request.args.getlist('id_code')[0]
    except IndexError:
        return flask.jsonify({'result': ''})

    objective_ids = map(int, id_code.split('.'))
    subobj = mongo.db.objectives.find_one_or_404({"id": objective_ids[0]})

    for depth in range(len(objective_ids) - 1):
        subobj = [s for s in subobj['subobjs'] if
                  s['id'] == objective_ids[depth + 1]][0]

    result = {'result': sugar.translate(subobj['title'])}
    return flask.jsonify(result)