diff --git a/backend/core/tests/test_contributors.py b/backend/core/tests/test_contributors.py index 3379bb24..b98a8dc1 100644 --- a/backend/core/tests/test_contributors.py +++ b/backend/core/tests/test_contributors.py @@ -30,8 +30,8 @@ def setUpTestData(cls) -> None: cls.episode = Episode.objects.create( name="Death Star destroyed", source_id=source.pk ) - cls.user_1 = User.objects.create(username="Yoda") - cls.user_2 = User.objects.create(username="Obi-Wan") + cls.user_1 = User.objects.create(username="Yoda", is_contributor=True) + cls.user_2 = User.objects.create(username="Obi-Wan", is_contributor=True) def test_single_contributor_one_contribution(self): self.client.force_login(self.user_1) diff --git a/backend/user/admin.py b/backend/user/admin.py index 26d25b24..37a60e2d 100644 --- a/backend/user/admin.py +++ b/backend/user/admin.py @@ -4,4 +4,5 @@ @admin.register(models.User) class UserAdmin(auth_admin.UserAdmin): - pass + fieldsets = auth_admin.UserAdmin.fieldsets + fieldsets[2][1]["fields"] = list(fieldsets[2][1]["fields"]) + ["is_contributor"] diff --git a/backend/user/serializers.py b/backend/user/serializers.py index 4886ee4c..c7ec4a98 100644 --- a/backend/user/serializers.py +++ b/backend/user/serializers.py @@ -13,5 +13,6 @@ class Meta(UserDetailsSerializer.Meta): "first_name", "last_name", "is_staff", + "is_contributor", ) - read_only_fields = ["is_staff", "id", "email"] + read_only_fields = ["is_staff", "id", "email", "is_contributor"] diff --git a/backend/user/tests/test_user_views.py b/backend/user/tests/test_user_views.py index babe923b..fba8584b 100644 --- a/backend/user/tests/test_user_views.py +++ b/backend/user/tests/test_user_views.py @@ -11,6 +11,7 @@ def test_user_details(user_client, user_data): "first_name": user_data["first_name"], "last_name": user_data["last_name"], "is_staff": False, + "is_contributor": False, } @@ -28,10 +29,11 @@ def test_user_updates(user_client, user_data): assert response.status_code == 200 assert details()["username"] == "NewName" - # is_staff is readonly, so nothing should happen + # is_staff and is_contributor are readonly, so nothing should happen response = user_client.patch( route, - {"is_staff": True}, + {"is_staff": True, "is_contributor": True}, content_type="application/json", ) assert not details()["is_staff"] + assert not details()["is_contributor"]