Beispiel #1
0
 def serialize(self):
     json_requisition = {
         "id": self.id,
         "title": self.title,
         "subject": Subjects.get_subject_from_id(self.subject).subject,
         "district": Districts.get_district_from_id(self.district).district,
         "state": States.get_state_from_id(self.state).state,
         "town": Towns.get_town_from_id(self.town).town,
         "institution": self.institution,
         "minexperience": self.minexperience,
         "maxexperience": self.maxexperience,
         "requisitiondetails": self.requisitiondetails,
         "responsibilities": self.responsibilities,
         "benefits": self.benefits,
         "eduexpdetails": self.eduexpdetails,
         "salary": self.salary,
         "vacancy": self.vacancy,
         "gender": self.gender,
         "jobtype": self.jobtype,
         "submitter": self.submitter,
         "registeredon": self.registeredon.strftime("%d/%m/%Y"),
         "closedon": self.closedon.strftime("%d/%m/%Y"),
         "isapplied": False
     }
     return json_requisition
Beispiel #2
0
def api_districts_all():
    result = {
        "status": "success",
        "message": "Retrieved all districts successfully.",
        "object": Districts.get_all_districts()
    }
    return Response(dumps(result), 200, mimetype='application/json')
Beispiel #3
0
 def serialize_without_roles(self):
     json_user = {
         "id":
         self.id,
         "userid":
         self.userid,
         "firstname":
         self.firstname,
         "middlename":
         self.middlename,
         "lastname":
         self.lastname,
         "fullname":
         self.fullname(),
         "fathername":
         self.fathername,
         "gender":
         self.gender,
         "nationality":
         self.nationality,
         "dob":
         self.dob.strftime("%d/%m/%Y"),
         "address":
         self.address,
         "pan":
         self.pan,
         "designation":
         self.designation,
         "ctc":
         self.ctc,
         "ectc":
         self.ectc,
         "teachingsubject":
         Subjects.get_subject_from_id(self.teachingsubject).subject,
         "district":
         Districts.get_district_from_id(self.district).district,
         "stateLocation":
         States.get_state_from_id(self.state).state,
         "town":
         Towns.get_town_from_id(self.town).town,
         "qualification":
         Qualifications.get_qualification_from_id(
             self.qualification).qualification,
         "totalexperience":
         self.totalexperience,
         "circulum":
         self.circulum,
         "teachingmedium":
         self.teachingmedium,
         "currentorganization":
         self.currentorganization,
         "segment":
         self.segment,
         "department":
         self.department
     }
     return json_user
Beispiel #4
0
def api_district_via_id(district_id):
    district = Districts.get_district_from_id(district_id)
    if district.id < 0:
        result = {
            "status": "failure",
            "message": "Failed to retrieve an Invalid district."
        }
        return Response(dumps(result), 400, mimetype='application/json')
    result = {
        "status": "success",
        "message": "District retrieved successfully.",
        "district": district.serialize()
    }
    return Response(dumps(result), 200, mimetype='application/json')
Beispiel #5
0
def api_add_district():
    request_data = request.get_json()
    district = Districts.submit_district_from_json(request_data)
    if district is None or district.id < 0:
        result = {
            "status": "failure",
            "message": "Failed to add an Invalid District."
        }
        return Response(dumps(result), 500, mimetype='application/json')
    result = {
        "status": "success",
        "message": "District added successfully.",
        "district": district.serialize()
    }
    return Response(dumps(result), 201, mimetype='application/json')
Beispiel #6
0
 def serialize_dict(classname, requisition_dict):
     json_requisition = {
         "id":
         requisition_dict['id'],
         "title":
         requisition_dict['title'],
         "subject":
         Subjects.get_subject_from_id(requisition_dict['subject']).subject,
         "district":
         Districts.get_district_from_id(
             requisition_dict['district']).district,
         "state":
         States.get_state_from_id(requisition_dict['state']).state,
         "town":
         Towns.get_town_from_id(requisition_dict['town']).town,
         "institution":
         requisition_dict['institution'],
         "minexperience":
         requisition_dict['minexperience'],
         "maxexperience":
         requisition_dict['maxexperience'],
         "requisitiondetails":
         requisition_dict['requisitiondetails'],
         "responsibilities":
         requisition_dict['responsibilities'],
         "benefits":
         requisition_dict['benefits'],
         "eduexpdetails":
         requisition_dict['eduexpdetails'],
         "salary":
         requisition_dict['salary'],
         "vacancy":
         requisition_dict['vacancy'],
         "gender":
         requisition_dict['gender'],
         "jobtype":
         requisition_dict['jobtype'],
         "submitter":
         requisition_dict['submitter'],
         "registeredon":
         requisition_dict['registeredon'].strftime("%d/%m/%Y"),
         "closedon":
         requisition_dict['closedon'].strftime("%d/%m/%Y")
     }
     return json_requisition
Beispiel #7
0
def api_districts():
    if 'id' in request.args:
        id = int(request.args['id'])
    else:
        result = {
            "status":
            "failure",
            "message":
            "Failed to retrieve an Invalid District, no (id) field provided. please specify an (id)."
        }
        return Response(dumps(result), 400, mimetype='application/json')

    district = Districts.get_district_from_id(id)
    result = {
        "status": "success",
        "message": "District retrieved successfully.",
        "district": district.serialize()
    }
    return Response(dumps(result), 200, mimetype='application/json')
Beispiel #8
0
 def serialize_view_userprofile(cls, userprofile_dict):
     json_user = {
         "id":
         userprofile_dict["id"],
         "userid":
         userprofile_dict["userid"],
         "firstname":
         userprofile_dict["firstname"],
         "middlename":
         userprofile_dict["middlename"],
         "lastname":
         userprofile_dict["lastname"],
         "fullname":
         userprofile_dict["firstname"] + ' ' +
         userprofile_dict["middlename"] + ' ' +
         userprofile_dict["lastname"],
         "fathername":
         userprofile_dict["fathername"],
         "gender":
         userprofile_dict["gender"],
         "nationality":
         userprofile_dict["nationality"],
         "dob":
         userprofile_dict["dob"].strftime("%d/%m/%Y"),
         "address":
         userprofile_dict["address"],
         "pan":
         userprofile_dict["pan"],
         "designation":
         userprofile_dict["designation"],
         "ctc":
         userprofile_dict["ctc"],
         "ectc":
         userprofile_dict["ectc"],
         "teachingsubject":
         Subjects.get_subject_from_id(
             userprofile_dict["teachingsubject"]).subject,
         "district":
         Districts.get_district_from_id(
             userprofile_dict["district"]).district,
         "stateLocation":
         States.get_state_from_id(userprofile_dict["state"]).state,
         "town":
         Towns.get_town_from_id(userprofile_dict["town"]).town,
         "qualification":
         Qualifications.get_qualification_from_id(
             userprofile_dict["qualification"]).qualification,
         "totalexperience":
         userprofile_dict["totalexperience"],
         "circulum":
         userprofile_dict["circulum"],
         "teachingmedium":
         userprofile_dict["teachingmedium"],
         "currentorganization":
         userprofile_dict["currentorganization"],
         "segment":
         userprofile_dict["segment"],
         "department":
         userprofile_dict["department"],
         "email":
         userprofile_dict["email"],
         "mobile":
         userprofile_dict["mobile"]
     }
     return json_user