MCPcopy Index your code
hub / github.com/Flagsmith/flagsmith / UserListSerializer

Class UserListSerializer

api/users/serializers.py:66–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64
65
66class UserListSerializer(serializers.ModelSerializer): # type: ignore[type-arg]
67 role = serializers.SerializerMethodField(read_only=True)
68 join_date = serializers.SerializerMethodField(read_only=True)
69
70 default_fields = ("id", "email", "first_name", "last_name", "last_login", "uuid")
71 organisation_users_fields = (
72 "role",
73 "date_joined",
74 )
75
76 class Meta:
77 model = FFAdminUser
78
79 def get_field_names(self, declared_fields, info): # type: ignore[no-untyped-def]
80 fields = self.default_fields
81 if self.context.get("organisation"):
82 fields += self.organisation_users_fields # type: ignore[assignment]
83 return fields
84
85 def get_role(self, instance): # type: ignore[no-untyped-def]
86 return instance.get_organisation_role(self.context.get("organisation"))
87
88 def get_join_date(self, instance): # type: ignore[no-untyped-def]
89 return instance.get_organisation_join_date(self.context.get("organisation"))
90
91
92class UserIdsSerializer(serializers.Serializer): # type: ignore[type-arg]

Calls

no outgoing calls

Tested by

no test coverage detected