server-client-python icon indicating copy to clipboard operation
server-client-python copied to clipboard

Delete default permissions does not take in a list

Open shinchris opened this issue 4 years ago • 3 comments

Regular permission delete method takes in a singular PermissionRule object, or a list of them. It will delete all the permissions included in the list.

Default permissions delete method only accepts a singular PermissionRule object. It will only delete 1 set of rules maximum. See sample, line 75-79.

shinchris avatar Jan 22 '21 22:01 shinchris

Code comments currently in permissions_endpoint show that delete_permissions can take either a single rule or a list. We should update delete_default_permissions to do the same. # Delete is the only endpoint that doesn't take a list of rules # so let's fake it to keep it consistent

jacalata avatar Jun 07 '22 20:06 jacalata

There's quite a few methods to update: image

jacalata avatar Feb 16 '23 22:02 jacalata

Hi there, first time responder, long time user of tsc here and i want to start with you guys are awesome and very much appreciate your work here. I was working through this recently and noticed that to fix it, all that seems to be needed is to apply the same signature and loop logic that is done on the delete permissions method in the permissions endpoint to the default_permissions_endpoint.

first just update the signature, then add the check and outer loop. def delete_default_permission(self, resource: BaseItem, rules: Union[PermissionsRule,List[PermissionsRule]], content_type: Resource) -> None:

# applying fix so that delete default endpoint can handle a list of rules like the delete permissions endpoint does
if isinstance(rules,PermissionsRule):
    rules = [rules]
for rule in rules:
    for capability, mode in rule.capabilities.items():...`

salvuswarez avatar Mar 15 '23 13:03 salvuswarez