예제 #1
0
def getStudentProfileForm():
    studentID = ObjectId(request.json['student_id'])
    form_id = ObjectId(request.json['form_id'])

    form_data = FormsDOM.getFormData(ObjectId(form_id))

    blank_form_id = FormsDOM.getBlankFormId(form_id)
    blank_form_data = blankFormsDOM.getFormData(blank_form_id)

    parent_id = FormsDOM.getInfo(form_id, 'parent_id')
    parent_profile = parentsDOM.getParentProfile(parent_id)
    cleaned_parent_profile = {}
    cleaned_parent_profile['first_name'] = parent_profile['first_name']
    cleaned_parent_profile['last_name'] = parent_profile['last_name']
    cleaned_parent_profile['email'] = parent_profile['email']

    form_info = {}
    form_info['name'] = blankFormsDOM.getFormName(blank_form_id)
    form_info['last_updated'] = FormsDOM.getLastUpdated(form_id)
    form_info['completed'] = FormsDOM.isComplete(form_id)

    isAuthorizedBool = isAuthorized(get_token_auth_header(),
                                    ['developer', 'admin'])
    return {
        'form_data': form_data,
        'blank_form_data': blank_form_data,
        'basic_info': studentsDOM.getBasicInfo(studentID),
        'parent_profile': cleaned_parent_profile,
        'form_info': form_info,
        'isAuthorized': isAuthorizedBool,
    }
def testFormGetInfo():
    expected = True
    actual = FormsDOM.getInfo('000', 'required')
    return expected == actual