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
def api_towns_all(): result = { "status": "success", "message": "Retrieved all towns successfully.", "question": Towns.get_all_towns() } return Response(dumps(result), 200, mimetype='application/json')
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
def api_town_via_id(id): town = Towns.get_town_from_id(id) if town.id < 0: result = { "status": "failure", "message": "Failed to retrieve an Invalid town." } return Response(dumps(result), 400, mimetype='application/json') result = { "status": "success", "message": "Town retrieved successfully.", "town": town.serialize() } return Response(dumps(result), 200, mimetype='application/json')
def api_add_town(): request_data = request.get_json() town = Towns.submit_town_from_json(request_data) if town is None or town.id < 0: result = { "status": "failure", "message": "Failed to add an Invalid Town." } return Response(dumps(result), 500, mimetype='application/json') result = { "status": "success", "message": "Town added successfully.", "town": town.serialize() } return Response(dumps(result), 201, mimetype='application/json')
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
def api_towns(): if 'id' in request.args: id = int(request.args['id']) else: result = { "status": "failure", "message": "Failed to retrieve an Invalid Town, no (id) field provided. please specify an (id)." } return Response(dumps(result), 400, mimetype='application/json') town = Towns.get_town_from_id(id) result = { "status": "success", "message": "Town retrieved successfully.", "town": town.serialize() } return Response(dumps(result), 200, mimetype='application/json')
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