| 64 | |
| 65 | |
| 66 | class 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 | |
| 92 | class UserIdsSerializer(serializers.Serializer): # type: ignore[type-arg] |
no outgoing calls
no test coverage detected