Fixes: 1) Add missing `LimitsSerializer` import in `drf.views` module; Extra: 1) Update `.gitignore` to exclude `queries`; 2) Refactor schema and views to integrate new limits functionality.
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
from rest_framework.fields import FloatField, JSONField, SerializerMethodField
|
|
from rest_framework.serializers import ModelSerializer, Serializer
|
|
|
|
from engine.payments.models import Transaction
|
|
|
|
|
|
class DepositSerializer(Serializer): # type: ignore [type-arg]
|
|
amount = FloatField(required=True)
|
|
|
|
|
|
class TransactionSerializer(ModelSerializer): # type: ignore [type-arg]
|
|
class Meta:
|
|
model = Transaction
|
|
fields = "__all__"
|
|
|
|
|
|
class TransactionProcessSerializer(ModelSerializer): # type: ignore [type-arg]
|
|
process = JSONField(required=True)
|
|
order_hr_id = SerializerMethodField(read_only=True, required=False)
|
|
order_uuid = SerializerMethodField(read_only=True, required=False)
|
|
|
|
def get_order_hr_id(self, obj: Transaction) -> str | None:
|
|
return obj.order.human_readable_id if obj.order else None
|
|
|
|
def get_order_uuid(self, obj: Transaction) -> str | None:
|
|
return str(obj.order.uuid) if obj.order else None
|
|
|
|
class Meta:
|
|
model = Transaction
|
|
fields = ("process", "order_hr_id", "order_uuid")
|
|
read_only_fields = ("process", "order_hr_id", "order_uuid")
|
|
|
|
|
|
class LimitsSerializer(Serializer): # type: ignore [type-arg]
|
|
min_amount = FloatField(read_only=True)
|
|
max_amount = FloatField(read_only=True)
|