base_serializers.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from rest_framework import serializers
  2. from ..models import Organization
  3. class OrganizationReferenceSerializer(serializers.ModelSerializer):
  4. dateCreated = serializers.DateTimeField(source="created", read_only=True)
  5. status = serializers.SerializerMethodField()
  6. avatar = serializers.SerializerMethodField()
  7. isEarlyAdopter = serializers.SerializerMethodField()
  8. require2FA = serializers.SerializerMethodField()
  9. isAcceptingEvents = (
  10. serializers.SerializerMethodField()
  11. ) # GlitchTip field, not in Sentry OSS
  12. class Meta:
  13. model = Organization
  14. fields = (
  15. "id",
  16. "name",
  17. "slug",
  18. "dateCreated",
  19. "status",
  20. "avatar",
  21. "isEarlyAdopter",
  22. "require2FA",
  23. "isAcceptingEvents",
  24. )
  25. read_only_fields = ("id", "slug")
  26. def get_status(self, obj):
  27. return {"id": "active", "name": "active"}
  28. def get_avatar(self, obj):
  29. return {"avatarType": "", "avatarUuid": None}
  30. def get_isEarlyAdopter(self, obj):
  31. return False
  32. def get_require2FA(self, obj):
  33. return False
  34. def get_isAcceptingEvents(self, obj):
  35. return obj.is_accepting_events