serializers.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. from rest_framework import serializers
  2. from apps.projects.serializers.base_serializers import ProjectReferenceSerializer
  3. from .models import Release
  4. class ReleaseSerializer(serializers.ModelSerializer):
  5. dateCreated = serializers.DateTimeField(source="created", read_only=True)
  6. dateReleased = serializers.DateTimeField(source="released", required=False)
  7. shortVersion = serializers.CharField(source="version", read_only=True)
  8. deployCount = serializers.IntegerField(source="deploy_count", read_only=True)
  9. projects = ProjectReferenceSerializer(many=True, read_only=True)
  10. class Meta:
  11. model = Release
  12. fields = (
  13. "url",
  14. "data",
  15. "deployCount",
  16. "dateCreated",
  17. "dateReleased",
  18. "version",
  19. "shortVersion",
  20. "projects",
  21. )
  22. lookup_field = "version"
  23. class AssembleSerializer(serializers.Serializer):
  24. checksum = serializers.RegexField("^[a-fA-F0-9]+$", max_length=40, min_length=40)
  25. chunks = serializers.ListField(
  26. child=serializers.RegexField("^[a-fA-F0-9]+$", max_length=40, min_length=40)
  27. )