def disconnect_payment_type(args, id): """Admin""" supplier = Supplier.query.get(id) payment_type = PaymentType.query.get(args['id']) if not supplier or not payment_type: return make_response( status_code=404, status='failure', message='Could not find supplier or payment_type', ) try: supplier.payment_types.remove(payment_type) db.session.add(supplier) db.session.commit() return make_response( status_code=200, status='success', message='Successfully disconnected payment_type', data=supplier_schema.dump(supplier).data, ) except Exception as e: return make_response( status_code=404, status='failure', message='payment_type is not connected to this supplier')
def get_education_detail(args, id): education = Education.query.get(id) if not education: return make_response(status_code=404, status='failure', message='No education found with that id') return make_response(status_code=200, status='success', data=education_schema.dump(education).data)
def get_tag_detail(args, id): tag = Tag.query.get(id) if not tag: return make_response(status_code=404, status='failure', message='No work experience found with that id') return make_response(status_code=200, status='success', data=tag_schema.dump(tag).data)
def get_role_detail(args, id): role = Role.query.get(id) if not role: return make_response(status_code=404, status='failure', message='No work experience found with that id') return make_response(status_code=200, status='success', data=role_schema.dump(role).data)
def get_activity_detail(args, id): activity = Activity.query.get(id) if not activity: return make_response(status_code=404, status='failure', message='No work experience found with that id') return make_response(status_code=200, status='success', data=activity_schema.dump(activity).data)
def get_customer_detail(args, id): customer = Customer.query.get(id) if not customer: return make_response(status_code=404, status='failure', message='No work experience found with that id') return make_response(status_code=200, status='success', data=customer_schema.dump(customer).data)
def get_user_detail(args, id): user = User.query.get(id) if not user: return make_response(status_code=404, status='failure', message='No user found with that id') return make_response(status_code=200, status='success', message=None, data=user_schema.dump(user).data)
def get_contact_person_detail(args, id): contact_person = ContactPerson.query.get(id) if not contact_person: return make_response(status_code=404, status='failure', message='No contact person found with that id') return make_response(status_code=200, status='success', data=contact_person_schema.dump(contact_person).data)
def get_work_experience_detail(args, id): work_experience = WorkExperience.query.get(id) if not work_experience: return make_response(status_code=404, status='failure', message='No work experience found with that id') return make_response( status_code=200, status='success', data=work_experience_schema.dump(work_experience).data)
def get_project_response_detail(args, id): project_response = ProjectResponse.query.get(id) if not project_response: return make_response(status_code=404, status='failure', message='No project_response found with that id') return make_response( status_code=200, status='success', data=project_response_schema.dump(project_response).data)
def get_payment_type_detail(id): """Private""" payment_type = PaymentType.query.get(id) if not payment_type: return make_response(status_code=404, status='failure', message='No payment_type found with that id') return make_response(status_code=200, status='success', message=None, data=payment_type_schema.dump(payment_type).data)
def get_reclamation_detail(args, id): """Private""" reclamation = Reclamation.query.get(id) if not reclamation: return make_response(status_code=404, status='failure', message='No reclamation found with that id') return make_response(status_code=200, status='success', message=None, data=reclamation_schema.dump(reclamation).data)
def get_supplier_detail(args, id): """Private""" supplier = Supplier.query.get(id) if not supplier: return make_response(status_code=404, status='failure', message='No supplier found with that id') return make_response(status_code=200, status='success', message=None, data=supplier_schema.dump(supplier).data)
def get_group_detail(args, id): group = Group.query.get(id) if not group: return make_response( status_code=404, status='failure', message='No work experience found with that id') return make_response( status_code=200, status='success', data=group_schema.dump(group).data)
def delete_contact_person(id): contact_person = ContactPerson.query.get(id) if not contact_person: return make_response(status_code=404, status='failure', message='No contact_person found with that id') db.session.delete(contact_person) db.session.commit() return make_response(status_code=200, status='success', message='Successfully deleted contact person')
def delete_role(args, id): role = Role.query.get(id) if not role: return make_response(status_code=404, status='failure', message='No role found with that id') db.session.delete(role) db.session.commit() return make_response(status_code=200, status='success', message='Successfully deleted eduation')
def delete_tag(args, id): tag = Tag.query.get(id) if not tag: return make_response(status_code=404, status='failure', message='No tag found with that id') db.session.delete(tag) db.session.commit() return make_response(status_code=200, status='success', message='Successfully deleted eduation')
def delete_education(args, id): education = Education.query.get(id) if not education: return make_response(status_code=404, status='failure', message='No education found with that id') db.session.delete(education) db.session.commit() return make_response(status_code=200, status='success', message='Successfully deleted eduation')
def get_location_detail(args, id): location = Location.query.get(id) if not location: return make_response( status_code=404, status='failure', message='No work experience found with that id') return make_response( status_code=200, status='success', data=location_schema.dump(location).data)
def delete_project_response(args, id): project_response = ProjectResponse.query.get(id) if not project_response: return make_response(status_code=404, status='failure', message='No project_response found with that id') db.session.delete(project_response) db.session.commit() return make_response(status_code=200, status='success', message='Successfully deleted eduation')
def set_user_tags(args, id): user = User.query.get(id) if not set_tags( session=db.session, parent=user, args=args, relation='user_id'): return make_response(status_code=404, status='failure', message='One or more tags could not be found') tags = Tag.query.filter_by(user_id=id).all() return make_response(status_code=200, status='success', data=TagSchema(many=True).dump(tags).data)
def delete_customer(id): customer = Customer.query.get(id) if not customer: return make_response(status_code=404, status='failure', message='No customer found with that id') db.session.delete(customer) db.session.commit() return make_response(status_code=200, status='success', message='Successfully deleted eduation')
def delete_work_experience(args, id): work_experience = WorkExperience.query.get(id) if not work_experience: return make_response(status_code=404, status='failure', message='No work_experience found with that id') db.session.delete(work_experience) db.session.commit() return make_response(status_code=200, status='success', message='Successfully deleted eduation')
def update_contact_person(args, id): customer = Customer.query.get(args['customer_id']) if not customer: return make_response(status_code=400, status='failure', message='No customer found with that id') contact_person = ContactPerson.query.get(id) contact_person.update(**args) db.session.commit() return make_response(status_code=200, status='success', message='Successfully updated work experience', data=contact_person_schema.dump(contact_person).data)
def update_education(args, id): user = User.query.get(args.get('user_id', g.user_id)) if not user: return make_response(status_code=400, status='failure', message='No user found with that id') education = Education.query.get(id) education.update(**args) db.session.commit() return make_response(status_code=200, status='success', message='Successfully updated education', data=education_schema.dump(education).data)
def create_education(args): user = User.query.get(args.get('user_id', g.user_id)) if not user: return make_response(status_code=400, status='failure', message='No user found with that id') education = Education(**args) user.educations.append(education) db.session.commit() return make_response(status_code=201, status='success', message=None, data=education_schema.dump(education).data)
def create_contact_person(args): customer = Customer.query.get(args['customer_id']) if not customer: return make_response(status_code=400, status='failure', message='No customer found with that id') contact_person = ContactPerson(**args) db.session.add(contact_person) db.session.commit() return make_response(status_code=200, status='success', message=None, data=contact_person_schema.dump(contact_person).data)
def set_work_experience_tags(args, id): work_experience = WorkExperience.query.get(id) if not set_tags(session=db.session, parent=work_experience, args=args, relation='work_experience_id'): return make_response(status_code=404, status='failure', message='One or more tags could not be found') tags = Tag.query.filter_by(work_experience_id=id).all() return make_response(status_code=200, status='success', data=TagSchema(many=True).dump(tags).data)
def update_work_experience(args, id): user = User.query.get(args.get('user_id', g.user_id)) if not user: return make_response(status_code=400, status='failure', message='No user found with that id') work_experience = WorkExperience.query.get(id) work_experience.update(**args) db.session.commit() return make_response( status_code=200, status='success', message='Successfully updated work experience', data=work_experience_schema.dump(work_experience).data)
def create_work_experience(args): user = User.query.get(args.get('user_id', g.user_id)) if not user: return make_response(status_code=400, status='failure', message='No user found with that id') work_experience = WorkExperience(**args) user.work_experience.append(work_experience) db.session.commit() return make_response( status_code=200, status='success', message=None, data=work_experience_schema.dump(work_experience).data)