Exemplo n.º 1
0
 def delete(self, name):
     report = ReportModel.find_by_name(name)
     if report is None:
         return {'message': "Report not found!"}, 404
     else:
         report.delete_from_db()
         return {'message': "Report deleted."}
Exemplo n.º 2
0
    def post(self, name):
        if ReportModel.find_by_name(name):
            return {'message': "A report with that name already exists!"}, 400

        data = Report.parser.parse_args()

        report = ReportModel(name, **data)

        try:
            report.save_to_db()
        except:
            return {
                'message': "An error occured while creating the report."
            }, 500

        return report.json()
Exemplo n.º 3
0
    def put(self, name):
        data = Report.parser.parse_args()

        report = ReportModel.find_by_name(name)

        if report is None:
            report = ReportModel(name, **data)
        else:
            report.benchmark = data['benchmark']
            report.content = data['content']
            report.status = data['status']

        try:
            report.save_to_db()
        except:
            return {'message': "An error occured."}, 500

        return report.json()
Exemplo n.º 4
0
 def get(self, name):
     report = ReportModel.find_by_name(name)
     if report:
         return report.json()
     return {'message': "Report not found!"}, 404