Skip to content

Commit

Permalink
fix: Rename ObjectTag perms to match model name
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuf-musleh committed Aug 14, 2023
1 parent b9ba062 commit 9f7d5c1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions openedx_tagging/core/tagging/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def can_change_object_tag(user: User, object_tag: ObjectTag = None) -> bool:
rules.add_perm("oel_tagging.view_tag", rules.always_allow)

# ObjectTag
rules.add_perm("oel_tagging.add_object_tag", can_change_object_tag)
rules.add_perm("oel_tagging.change_object_tag", can_change_object_tag)
rules.add_perm("oel_tagging.delete_object_tag", is_taxonomy_admin)
rules.add_perm("oel_tagging.view_object_tag", rules.always_allow)
rules.add_perm("oel_tagging.add_objecttag", can_change_object_tag)
rules.add_perm("oel_tagging.change_objecttag", can_change_object_tag)
rules.add_perm("oel_tagging.delete_objecttag", is_taxonomy_admin)
rules.add_perm("oel_tagging.view_objecttag", rules.always_allow)
40 changes: 20 additions & 20 deletions tests/openedx_tagging/core/tagging/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ def test_view_tag(self):
# ObjectTag

@ddt.data(
"oel_tagging.add_object_tag",
"oel_tagging.change_object_tag",
"oel_tagging.add_objecttag",
"oel_tagging.change_objecttag",
)
def test_add_change_object_tag(self, perm):
"""Taxonomy administrators can create/edit an ObjectTag with an enabled Taxonomy"""
Expand All @@ -174,8 +174,8 @@ def test_add_change_object_tag(self, perm):
assert not self.learner.has_perm(perm, self.object_tag)

@ddt.data(
"oel_tagging.add_object_tag",
"oel_tagging.change_object_tag",
"oel_tagging.add_objecttag",
"oel_tagging.change_objecttag",
)
def test_object_tag_disabled_taxonomy(self, perm):
"""Taxonomy administrators cannot create/edit an ObjectTag with a disabled Taxonomy"""
Expand All @@ -189,23 +189,23 @@ def test_object_tag_disabled_taxonomy(self, perm):
True,
False,
)
def test_delete_object_tag(self, enabled):
def test_delete_objecttag(self, enabled):
"""Taxonomy administrators can delete any ObjectTag, even those associated with a disabled Taxonomy."""
self.taxonomy.enabled = enabled
self.taxonomy.save()
assert self.superuser.has_perm("oel_tagging.delete_object_tag")
assert self.superuser.has_perm("oel_tagging.delete_object_tag", self.object_tag)
assert self.staff.has_perm("oel_tagging.delete_object_tag")
assert self.staff.has_perm("oel_tagging.delete_object_tag", self.object_tag)
assert not self.learner.has_perm("oel_tagging.delete_object_tag")
assert self.superuser.has_perm("oel_tagging.delete_objecttag")
assert self.superuser.has_perm("oel_tagging.delete_objecttag", self.object_tag)
assert self.staff.has_perm("oel_tagging.delete_objecttag")
assert self.staff.has_perm("oel_tagging.delete_objecttag", self.object_tag)
assert not self.learner.has_perm("oel_tagging.delete_objecttag")
assert not self.learner.has_perm(
"oel_tagging.delete_object_tag", self.object_tag
"oel_tagging.delete_objecttag", self.object_tag
)

@ddt.data(
"oel_tagging.add_object_tag",
"oel_tagging.change_object_tag",
"oel_tagging.delete_object_tag",
"oel_tagging.add_objecttag",
"oel_tagging.change_objecttag",
"oel_tagging.delete_objecttag",
)
def test_object_tag_no_taxonomy(self, perm):
"""Taxonomy administrators can modify an ObjectTag with no Taxonomy"""
Expand All @@ -216,9 +216,9 @@ def test_object_tag_no_taxonomy(self, perm):

def test_view_object_tag(self):
"""Anyone can view any ObjectTag"""
assert self.superuser.has_perm("oel_tagging.view_object_tag")
assert self.superuser.has_perm("oel_tagging.view_object_tag", self.object_tag)
assert self.staff.has_perm("oel_tagging.view_object_tag")
assert self.staff.has_perm("oel_tagging.view_object_tag", self.object_tag)
assert self.learner.has_perm("oel_tagging.view_object_tag")
assert self.learner.has_perm("oel_tagging.view_object_tag", self.object_tag)
assert self.superuser.has_perm("oel_tagging.view_objecttag")
assert self.superuser.has_perm("oel_tagging.view_objecttag", self.object_tag)
assert self.staff.has_perm("oel_tagging.view_objecttag")
assert self.staff.has_perm("oel_tagging.view_objecttag", self.object_tag)
assert self.learner.has_perm("oel_tagging.view_objecttag")
assert self.learner.has_perm("oel_tagging.view_objecttag", self.object_tag)

0 comments on commit 9f7d5c1

Please sign in to comment.