Пример #1
0
    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
Пример #2
0
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
Пример #3
0
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()
Пример #4
0
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
Пример #5
0
    def get(self, id):
        lead = LeadModel.find_by_id(id)

        if lead:
            return lead.json()

        return {'message': 'There is no lead with this email'}, 404
Пример #6
0
    def delete(self, id):
        lead = LeadModel.find_by_id(id)

        if lead:
            try:
                lead.delete_from_db()
                return {'message': 'Lead deleted'}
            except Exception:
                return {'message': 'Error deleting a lead'}, 500

        return {'message': 'There is no lead with this email'}, 404
Пример #7
0
    def put(self, id):
        lead = LeadModel.find_by_id(id)

        if lead:
            data = self.parser.parse_args()

            for attribute, value in data.items():
                if value:
                    setattr(lead, attribute, value)

            try:
                lead.save_to_db()
            except Exception:
                return {'message': 'An error occured updating a lead'}, 500

            return lead.json()

        return {'message': 'There is no lead with this id'}, 404
Пример #8
0
    def post(self):
        data = self.parser.parse_args()

        if LeadModel.find_by_email(data['email']):
            return {'message': 'There is already a lead with this email'}

        lead = LeadModel(**data)

        try:
            lead.save_to_db()
        except Exception:
            return {'message': 'An error occured inserting a lead'}, 500

        return lead.json()