Пример #1
0
def paticipant_details():
    data = {
        'client_id': request.args.get('client_id'),
        'cycle_id': request.args.get('cycle_id')
    }
    schema = {
        'client_id': {
            'required': True,
            'type': 'string'
        },
        'cycle_id': {
            'required': True,
            'type': 'string'
        }
    }
    res = validator.validate(data, schema)
    if not res:
        response = Response()
        response.success = False
        response.status = 400
        response.errors = "Required data not provided."
        return response.response_json()
    data["assessment_role"] = "participant"
    employee = hp.Employee()
    response = employee.select(data)
    if response.success:
        response.message = "Employe details added "
        response.data = {"participant_details": response.data}
    elif not response.success:
        response.success = False
        response.status = 400
        response.errors = "Participants details not fetched."
    return response.response_json()
Пример #2
0
def all_respondant_details():
    data = {
        'client_id': request.args.get('client_id'),
        'cycle_id': request.args.get('cycle_id')
    }
    if request.args.get('part_id') is not None:
        data['part_id'] = request.args.get('part_id')
    response = Response()
    schema = {
        'client_id': {'required': True, 'type': 'string'},
        'cycle_id': {'required': True, 'type': 'string'}
    }
    validator.allow_unknown = True
    res = validator.validate(data, schema)
    if not res:
        response.success = False
        response.status = 400
        response.errors = "Required data not provided."
        return response.response_json()
    data["assessment_role"]="respondant"
    emp_ids = hp.EmployeeRelationMapping()
    emp_ids_response = emp_ids.select(data)
    if emp_ids_response.success:
        data['emp_ids'] = list()
        for ids in emp_ids_response.data:
            data['emp_ids'].append(ids['pat_emp_id'])
        employee = hp.Employee()
        employee_response = employee.select(data)
        if employee_response.success:
            response.message = "Respondents details fetched."
            response.status = 200
            response.data = {
                                "respondants_details":employee_response.data
            }
        elif not employee_response.success:
            response.success = False
            response.status = 400
            response.errors = "Respondents details not fetched."
    else:
        emp_ids.success = False
        emp_ids.status = 400
        emp_ids.errors = "Respondents details not fetched."

    return response.response_json()
Пример #3
0
def store_feedback():
    data = request.get_json()
    response = Response()
    schema = {
        'client_id': {
            'required': True,
            'type': 'string'
        },
        'cycle_id': {
            'required': True,
            'type': 'integer'
        },
        'map_id': {
            'required': True,
            'type': 'integer'
        },
        'level_id': {
            'required': True,
            'type': 'integer'
        },
        'feedback_text': {
            'required': True,
            'type': 'string'
        }
    }
    res = validator.validate(data, schema)
    if not res:
        response.success = False
        response.status = 400
        response.message = "Required data not found"
    store_feed = hp.StoreFeedback()
    response = store_feed.create(data)
    if response.success:
        response.success = True
        response.status = 200
        response.data = {}
        response.message = "Success"
    elif not response:
        response.success = False
        response.status = 400
        response.message = "Failure"
    return response.response_json()
Пример #4
0
def login():
    data = request.get_json()
    schema = {
        'emp_id': {
            'required': True,
            'type': 'string'
        },
        'client_id': {
            'required': True,
            'type': 'string'
        },
        'password': {
            'required': True,
            'type': 'string'
        },
        'user_role': {
            'required': True,
            'type': 'string'
        }
    }
    res = validator.validate(data, schema)
    if not res:
        response = Response()
        response.success = False
        response.status = 400
        response.errors = "Required data not provided."
    login = hp.LogIn()
    response = login.validate(data)
    if response.success:
        response.data = {
            "client_id": response.data['client_id'],
            "cycle_id": response.data['cycle_id'],
            "user_type": data["user_role"],
            "user_info": {
                "name": response.data['name'],
                "emp_id": response.data['emp_id'],
                "email_id": response.data['email_id']
            }
        }
        response.message = "Login Success!!"
    return response.response_json()
Пример #5
0
def add_cycle_details():
    data = request.get_json()
    response = Response()
    schema = {
        'client_id': {
            'required': True,
            'type': 'string'
        },
        'cycle_name': {
            'required': True,
            'type': 'string'
        },
        'from_date': {
            'required': True,
            'type': 'string'
        },
        'to_date': {
            'required': True,
            'type': 'string'
        }
    }

    res = validator.validate(data, schema)
    if not res:
        response.success = False
        response.status = 400
        response.message = "Required data not found"
    client_cycle = hp.ClientCycleDetails()
    response = client_cycle.create(data)
    if response.success:
        response.status = 200
        response.data = {
            "client_id": response.data['client_id'],
            "cycle_id": response.data['cycle_id']
        }
        response.message = "Success"
    elif not response:
        response.success = False
        response.status = 400
        response.message = "Failure"
    return response.response_json()