示例#1
0
 def delete(self, pk: int) -> Response:
     """Deletes a Dashboard
     ---
     delete:
       description: >-
         Deletes a Dashboard.
       parameters:
       - in: path
         schema:
           type: integer
         name: pk
       responses:
         200:
           description: Dashboard deleted
           content:
             application/json:
               schema:
                 type: object
                 properties:
                   message:
                     type: string
         401:
           $ref: '#/components/responses/401'
         403:
           $ref: '#/components/responses/403'
         404:
           $ref: '#/components/responses/404'
         422:
           $ref: '#/components/responses/422'
         500:
           $ref: '#/components/responses/500'
     """
     try:
         DeleteDashboardCommand(pk).run()
         return self.response(200, message="OK")
     except DashboardNotFoundError:
         return self.response_404()
     except DashboardForbiddenError:
         return self.response_403()
     except DashboardDeleteFailedError as ex:
         logger.error(
             "Error deleting model %s: %s",
             self.__class__.__name__,
             str(ex),
             exc_info=True,
         )
         return self.response_422(message=str(ex))
示例#2
0
 def delete(self, pk: int) -> Response:  # pylint: disable=arguments-differ
     """Deletes a Dashboard
     ---
     delete:
       description: >-
         Deletes a Dashboard
       parameters:
       - in: path
         schema:
           type: integer
         name: pk
       responses:
         200:
           description: Dashboard deleted
           content:
             application/json:
               schema:
                 type: object
                 properties:
                   message:
                     type: string
         401:
           $ref: '#/components/responses/401'
         403:
           $ref: '#/components/responses/403'
         404:
           $ref: '#/components/responses/404'
         422:
           $ref: '#/components/responses/422'
         500:
           $ref: '#/components/responses/500'
     """
     try:
         DeleteDashboardCommand(g.user, pk).run()
         return self.response(200, message="OK")
     except DashboardNotFoundError:
         return self.response_404()
     except DashboardForbiddenError:
         return self.response_403()
     except DashboardDeleteFailedError as e:
         logger.error(
             f"Error deleting model {self.__class__.__name__}: {e}")
         return self.response_422(message=str(e))