Ejemplo n.º 1
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
Ejemplo n.º 2
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
Ejemplo n.º 3
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