def post_test_lead(cls): appeal = AppealModel('Test Title', 'title.url') appeal.save_to_db() lead = LeadModel('*****@*****.**', '1111222233', 'Test', 'Tester', appeal.id) lead.save_to_db() return lead
def create_lead_and_operator(): appeal = AppealModel('title', 'url') appeal.save_to_db() lead = LeadModel('email', 'phone', 'name', 'surname', appeal.id) lead.save_to_db() operator = OperatorModel('testuser', 'name', 'surname', 'email') operator.save_to_db() return lead, operator
def create_call(): appeal = AppealModel('title', 'url') appeal.save_to_db() lead = LeadModel('email', 'phone', 'name', 'surname', appeal.id) lead.save_to_db() operator = OperatorModel('testuser', 'name', 'surname', 'email') operator.save_to_db() call = CallModel('04-12-2020', '03::04::05', 5.4, lead.id, operator.id) call.save_to_db()
def create_donation(): appeal = AppealModel('title', 'url') appeal.save_to_db() lead = LeadModel('email', 'phone', 'name', 'surname', appeal.id) lead.save_to_db() operator = OperatorModel('testuser', 'name', 'surname', 'email') operator.save_to_db() donation = DonationModel('Annual', 30.00, lead.id, operator.id) donation.save_to_db() return donation
def get(self, id): appeal = AppealModel.find_by_id(id) if appeal: return appeal.json() return {'message': 'There is no appeal with this id'}, 404
def delete(self, id): appeal = AppealModel.find_by_id(id) if appeal: try: appeal.delete_from_db() return {'message': 'Appeal deleted'} except Exception: return {'message': 'Error deleting the appeal'}, 500 return {'message': 'There is no appeal with this id'}, 404
def put(self, id): appeal = AppealModel.find_by_id(id) if appeal: data = self.parser.parse_args() for attribute, value in data.items(): if value: setattr(appeal, attribute, value) try: appeal.save_to_db() return appeal.json() except Exception: return {'message': 'An error occured updating' 'an appeal.'}, 500 return {'message': 'There is no appeal with this id'}, 404
def post(self): data = self.parser.parse_args() if AppealModel.find_by_url(data['url']): return {'message': 'There is already an appeal with this url'}, 400 appeal = AppealModel(**data) try: appeal.save_to_db() except Exception: return {'message': 'An error occured inserting an appeal'}, 500 return appeal.json()
def post_test_appeal(self): appeal = AppealModel('test', 'http://test.com') appeal.save_to_db() return appeal
def post_test_appeal(self, url): appeal = AppealModel('test', url) appeal.save_to_db() return appeal
def create_appeal(self): appeal = AppealModel('Test title', 'test.url') appeal.save_to_db() return appeal