amitmiran137 commented on a change in pull request #13035:
URL: https://github.com/apache/superset/pull/13035#discussion_r573581033
##########
File path: superset/dashboards/filters.py
##########
@@ -138,3 +140,22 @@ def apply(self, query: Query, value: Any) -> Query:
)
return query
+
+
+class FilterRelatedRoles(BaseFilter):
+ """
+ A filter to allow searching for related roles of a resource.
+
+ Use in the api by adding something like:
+ related_field_filters = {
+ "roles": RelatedFieldFilter("name", FilterRelatedRoles),
+ }
+ """
+
+ name = _("Role")
+ arg_name = "roles"
+
+ def apply(self, query: Query, value: Optional[Any]) -> Query:
+ role_model = security_manager.role_model
+ like_value = "%" + cast(str, value) + "%"
+ return query.filter((role_model.name).ilike(like_value),)
Review comment:
sure
adding tests also
----------------------------------------------------------------
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]