Skip to content

Commit

Permalink
Merge pull request #1021 from hinashi/fixed/acl_update_error
Browse files Browse the repository at this point in the history
Fixed update acl error when another role was already set
  • Loading branch information
userlocalhost authored Dec 14, 2023
2 parents 63e9b63 + 162fb57 commit 0a3fa17
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
6 changes: 0 additions & 6 deletions acl/api_v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,6 @@ def validate(self, attrs: dict[str, Any]):
"value": int(x["value"]),
}
for x in attrs.get("acl_settings", [])
]
+ [
{"role": role, "value": ACLType.Full}
for role in acl.full.roles.exclude(
id__in=[x["member_id"] for x in attrs.get("acl_settings", [])]
)
],
},
):
Expand Down
24 changes: 24 additions & 0 deletions acl/tests/test_api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,30 @@ def test_update_acl_to_nobody_control(self):
)
self.assertEqual(resp.status_code, 403)

role2 = Role.objects.create(name="role2")

acl.is_public = True
acl.save()
acl.full.roles.remove(role)
acl.full.roles.add(role2)

resp = self.client.put(
"/acl/api/v2/acls/%s" % acl.id,
json.dumps(
{
"is_public": False,
"acl_settings": [
{
"member_id": str(role.id),
"value": str(ACLType.Full.id),
}
],
}
),
"application/json;charset=utf-8",
)
self.assertEqual(resp.status_code, 200)

def test_remove_acl_when_administrative_role_is_left(self):
user = self.guest_login()
acl = ACLBase.objects.create(name="test", created_user=user)
Expand Down

0 comments on commit 0a3fa17

Please sign in to comment.