コード例 #1
0
 def validate(self) -> None:
     # Validate/populate model exists
     self._models = ChartDAO.find_by_ids(self._model_ids)
     if not self._models or len(self._models) != len(self._model_ids):
         raise ChartNotFoundError()
     # Check ownership
     for model in self._models:
         try:
             check_ownership(model)
         except SupersetSecurityException:
             raise ChartForbiddenError()
コード例 #2
0
ファイル: bulk_delete.py プロジェクト: airbnb/superset-fork
 def validate(self) -> None:
     # Validate/populate model exists
     self._models = ChartDAO.find_by_ids(self._model_ids)
     if not self._models or len(self._models) != len(self._model_ids):
         raise ChartNotFoundError()
     # Check there are no associated ReportSchedules
     reports = ReportScheduleDAO.find_by_chart_ids(self._model_ids)
     if reports:
         report_names = [report.name for report in reports]
         raise ChartBulkDeleteFailedReportsExistError(
             _("There are associated alerts or reports: %s" %
               ",".join(report_names)))
     # Check ownership
     for model in self._models:
         try:
             check_ownership(model)
         except SupersetSecurityException as ex:
             raise ChartForbiddenError() from ex
コード例 #3
0
ファイル: api.py プロジェクト: bballamudi/incubator-superset
 def favorite_status(self, **kwargs: Any) -> Response:
     """Favorite stars for Charts
     ---
     get:
       description: >-
         Check favorited dashboards for current user
       parameters:
       - in: query
         name: q
         content:
           application/json:
             schema:
               $ref: '#/components/schemas/get_fav_star_ids_schema'
       responses:
         200:
           description:
           content:
             application/json:
               schema:
                 $ref: "#/components/schemas/GetFavStarIdsSchema"
         400:
           $ref: '#/components/responses/400'
         401:
           $ref: '#/components/responses/401'
         404:
           $ref: '#/components/responses/404'
         500:
           $ref: '#/components/responses/500'
     """
     requested_ids = kwargs["rison"]
     charts = ChartDAO.find_by_ids(requested_ids)
     if not charts:
         return self.response_404()
     favorited_chart_ids = ChartDAO.favorited_ids(charts, g.user.id)
     res = [{
         "id": request_id,
         "value": request_id in favorited_chart_ids
     } for request_id in requested_ids]
     return self.response(200, result=res)
コード例 #4
0
 def validate(self) -> None:
     self._models = ChartDAO.find_by_ids(self.chart_ids)
     if len(self._models) != len(self.chart_ids):
         raise ChartNotFoundError()