You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/02/01 15:41:16 UTC

[GitHub] [superset] villebro commented on a change in pull request #12865: feat(dashboard_rbac): dashboards API support for roles create/update + roles validation

villebro commented on a change in pull request #12865:
URL: https://github.com/apache/superset/pull/12865#discussion_r567917898



##########
File path: superset/commands/utils.py
##########
@@ -48,6 +49,22 @@ def populate_owners(user: User, owners_ids: Optional[List[int]] = None) -> List[
     return owners
 
 
+def populate_roles(roles_ids: Optional[List[int]] = None) -> List[Role]:
+    """
+    Helper function for commands, will fetch all roles from roles id's
+    Can raise ValidationError

Review comment:
       I believe this is what should be in the docstring:
   ```suggestion
       :raises RolesNotFoundValidationError: If a role in the input list is not found 
   ```

##########
File path: superset/dashboards/commands/create.py
##########
@@ -51,19 +51,30 @@ def run(self) -> Model:
 
     def validate(self) -> None:
         exceptions: List[ValidationError] = list()
-        owner_ids: Optional[List[int]] = self._properties.get("owners")
+        owners_ids: Optional[List[int]] = self._properties.get("owners")
+        roles_ids: Optional[List[int]] = self._properties.get("roles")

Review comment:
       This comes down to style, but I think having double plural is not needed here.

##########
File path: tests/base_tests.py
##########
@@ -182,6 +182,15 @@ def get_user(username: str) -> ab_models.User:
         )
         return user
 
+    @staticmethod
+    def get_role(name: str) -> ab_models.User:

Review comment:
       If we're returning `one_or_none()`, this should be optional:
   ```suggestion
       def get_role(name: str) -> Optional[ab_models.User]:
   ```

##########
File path: superset/dashboards/commands/update.py
##########
@@ -76,14 +77,27 @@ def validate(self) -> None:
             exceptions.append(DashboardSlugExistsValidationError())
 
         # Validate/Populate owner
-        if owner_ids is None:
-            owner_ids = [owner.id for owner in self._model.owners]
+        if owners_ids is None:
+            owners_ids = [owner.id for owner in self._model.owners]

Review comment:
       Same here




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org