chore(api): rename editor role to host
This commit is contained in:
parent
4009e7eeb6
commit
e730959e9f
|
@ -3,6 +3,6 @@ from django.db import models
|
|||
|
||||
class Role(models.TextChoices):
|
||||
GUEST = "G", "Guest"
|
||||
EDITOR = "H", "Editor"
|
||||
HOST = "H", "Host"
|
||||
MANAGER = "P", "Manager"
|
||||
ADMIN = "A", "Admin"
|
||||
|
|
|
@ -7,7 +7,7 @@ from ...models import Role, User
|
|||
class TestUserManager(APITestCase):
|
||||
def test_create_user(self):
|
||||
user = User.objects.create_user(
|
||||
role=Role.EDITOR,
|
||||
role=Role.HOST,
|
||||
username="test",
|
||||
password="test",
|
||||
email="test@example.com",
|
||||
|
|
|
@ -19,7 +19,7 @@ GUEST_PERMISSIONS = [
|
|||
"view_apiroot",
|
||||
]
|
||||
|
||||
EDITOR_PERMISSIONS = GUEST_PERMISSIONS + [
|
||||
HOST_PERMISSIONS = GUEST_PERMISSIONS + [
|
||||
"add_file",
|
||||
"add_podcast",
|
||||
"add_podcastepisode",
|
||||
|
@ -100,6 +100,6 @@ MANAGER_PERMISSIONS = GUEST_PERMISSIONS + [
|
|||
|
||||
GROUPS = {
|
||||
Role.GUEST.value: GUEST_PERMISSIONS,
|
||||
Role.EDITOR.value: EDITOR_PERMISSIONS,
|
||||
Role.HOST.value: HOST_PERMISSIONS,
|
||||
Role.MANAGER.value: MANAGER_PERMISSIONS,
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ REQUEST_PERMISSION_TYPE_MAP = {
|
|||
|
||||
def get_own_obj(request, view):
|
||||
user = request.user
|
||||
if user is None or user.role != Role.EDITOR:
|
||||
if user is None or user.role != Role.HOST:
|
||||
return ""
|
||||
if request.method == "GET":
|
||||
return ""
|
||||
|
|
|
@ -97,12 +97,12 @@ class TestPermissions(APITestCase):
|
|||
msg=f"Invalid for model {model}",
|
||||
)
|
||||
|
||||
def test_editor_get_permissions(self):
|
||||
def test_host_get_permissions(self):
|
||||
for model in self.URLS:
|
||||
response = self.logged_in_test_model(
|
||||
model,
|
||||
Role.EDITOR,
|
||||
"editor",
|
||||
Role.HOST,
|
||||
"host",
|
||||
self.client.get,
|
||||
)
|
||||
self.assertEqual(
|
||||
|
@ -111,10 +111,10 @@ class TestPermissions(APITestCase):
|
|||
msg=f"Invalid for model {model}",
|
||||
)
|
||||
|
||||
def test_editor_post_permissions(self):
|
||||
def test_host_post_permissions(self):
|
||||
user = get_user_model().objects.create_user(
|
||||
role=Role.EDITOR,
|
||||
username="editor2",
|
||||
role=Role.HOST,
|
||||
username="host2",
|
||||
password="test",
|
||||
email="test@example.com",
|
||||
first_name="test",
|
||||
|
@ -123,14 +123,14 @@ class TestPermissions(APITestCase):
|
|||
file = baker.make("storage.File", owner=user)
|
||||
model = f"files/{file.id}"
|
||||
path = self.path.format(model)
|
||||
self.client.login(username="editor2", password="test")
|
||||
self.client.login(username="host2", password="test")
|
||||
response = self.client.patch(path, {"name": "newFilename"})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_editor_post_permissions_failure(self):
|
||||
def test_host_post_permissions_failure(self):
|
||||
get_user_model().objects.create_user(
|
||||
role=Role.EDITOR,
|
||||
username="editor2",
|
||||
role=Role.HOST,
|
||||
username="host2",
|
||||
password="test",
|
||||
email="test@example.com",
|
||||
first_name="test",
|
||||
|
@ -139,6 +139,6 @@ class TestPermissions(APITestCase):
|
|||
file = baker.make("storage.File")
|
||||
model = f"files/{file.id}"
|
||||
path = self.path.format(model)
|
||||
self.client.login(username="editor2", password="test")
|
||||
self.client.login(username="host2", password="test")
|
||||
response = self.client.patch(path, {"name": "newFilename"})
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
|
Loading…
Reference in New Issue