Exemple #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
Exemple #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
Exemple #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()
Exemple #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
Exemple #5
0
    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
Exemple #6
0
    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
Exemple #7
0
    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
Exemple #8
0
    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()
Exemple #9
0
 def post_test_appeal(self):
     appeal = AppealModel('test', 'http://test.com')
     appeal.save_to_db()
     return appeal
Exemple #10
0
    def post_test_appeal(self, url):
        appeal = AppealModel('test', url)
        appeal.save_to_db()

        return appeal
Exemple #11
0
    def create_appeal(self):
        appeal = AppealModel('Test title', 'test.url')
        appeal.save_to_db()

        return appeal