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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to