コード例 #1
0
def decodeRequestOld(request_json):
    '''
    Maps the request Json to Request class
    :param request_json: json sent by the user with the request
    :return: request class with the info in the json
    '''
    dict = json.loads(request_json)
    request = Request(1, 1, 1, 1)

    for key in dict:
        if key == 'request_id':
            request.request_id = dict[key]
        if key == 'resource_id':
            request.resource_id = dict[key]
        if key == 'template_id':
            request.template_id = dict[key]
        if key == 'user_id':
            request.aged_id = dict[key]
        if key == 'category':
            request.category = dict[key]
        if key == 'from_date':
            request.from_date = dict[key]
        if key == 'to_date':
            request.to_date = dict[key]
        if key == 'subjects':
            request.subjects = dict[key]
    return request
コード例 #2
0
def decodeRequest(request_json):
    '''
    Maps the request Json to Request class
    :param request_json: json sent by the user with the request
    :return: request class with the info in the json
    '''
    request = Request(1, request_json['resource_id'], request_json['template_id'], request_json['aged_id'])
    request.from_date = datetime.strptime(request_json['from_date'], '%d %b %Y')
    request.to_date = datetime.strptime(request_json['to_date'], '%d %b %Y')

    return request
コード例 #3
0
def decodeRequestPendulum(request_post):
    '''
    Maps the request Json to Request class
    :param request_post: json sent by the user with the request
    :return: request class with the info in the json
    '''
    request = Request(1, request_post.form['pilot_id'], request_post.form['intervention_session_id'],request_post.form['resource_id'],
                      request_post.form['template_id'], request_post.form['aged_id'], request_post.form['miniplan_local_id'])
    request.from_date = pendulum.parse(request_post.form['from_date'])
    request.to_date = pendulum.parse(request_post.form['to_date'])

    return request