(self, attrs: typing.Any)
| 127 | read_only_fields = ("id", "date_created") |
| 128 | |
| 129 | def validate(self, attrs: typing.Any) -> typing.Any: |
| 130 | if Invite.objects.filter( |
| 131 | email=attrs["email"], organisation__id=self.context["organisation"] |
| 132 | ).exists(): |
| 133 | raise serializers.ValidationError( |
| 134 | {"email": "Invite for email %s already exists" % attrs["email"]} |
| 135 | ) |
| 136 | return super(InviteSerializer, self).validate(attrs) |
| 137 | |
| 138 | |
| 139 | class MultiInvitesSerializer(serializers.Serializer): # type: ignore[type-arg] |