See #890: Added is_local attribute on admin account API representations

environments/review-docs-rate-jr6phc/deployments/2479
Eliot Berriot 2019-08-27 14:00:33 +02:00
rodzic d7705593a9
commit 9488094ff9
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: DD6965E2476E5C27
2 zmienionych plików z 8 dodań i 0 usunięć

Wyświetl plik

@ -1,3 +1,4 @@
from django.conf import settings
from django.db import transaction
from rest_framework import serializers
@ -183,6 +184,8 @@ class ManageDomainActionSerializer(common_serializers.ActionSerializer):
class ManageBaseActorSerializer(serializers.ModelSerializer):
is_local = serializers.SerializerMethodField()
class Meta:
model = federation_models.Actor
fields = [
@ -201,9 +204,13 @@ class ManageBaseActorSerializer(serializers.ModelSerializer):
"outbox_url",
"shared_inbox_url",
"manually_approves_followers",
"is_local",
]
read_only_fields = ["creation_date", "instance_policy"]
def get_is_local(self, o):
return o.domain_id == settings.FEDERATION_HOSTNAME
class ManageActorSerializer(ManageBaseActorSerializer):
uploads_count = serializers.SerializerMethodField()

Wyświetl plik

@ -87,6 +87,7 @@ def test_manage_actor_serializer(factories, now, to_api_date):
"full_username": actor.full_username,
"user": None,
"instance_policy": None,
"is_local": False,
}
s = serializers.ManageActorSerializer(actor)