Skip to content

Serializers

hypha.apply.api.v1.projects.serializers

InvoiceDeliverableListSerializer

Bases: ModelSerializer

invoice_id class-attribute instance-attribute

invoice_id = SerializerMethodField()

project_id class-attribute instance-attribute

project_id = IntegerField(source='deliverable.project.id')

Meta

model class-attribute instance-attribute
fields class-attribute instance-attribute
fields = ('id', 'deliverable', 'quantity', 'invoice_id', 'project_id')
depth class-attribute instance-attribute
depth = 1

get_invoice_id

get_invoice_id(obj)
Source code in hypha/apply/api/v1/projects/serializers.py
def get_invoice_id(self, obj):
    return self.context["invoice"].id

DeliverableSerializer

Bases: Serializer

id class-attribute instance-attribute

id = IntegerField()

quantity class-attribute instance-attribute

quantity = IntegerField(min_value=1, default=1)

validate_id

validate_id(value)
Source code in hypha/apply/api/v1/projects/serializers.py
def validate_id(self, value):
    try:
        Deliverable.objects.get(id=value)
    except Deliverable.DoesNotExist as e:
        raise exceptions.ValidationError({"detail": _("Not found")}) from e
    return value