Fixes: (1) Removed all `# type: ignore` annotations across the codebase; (2) Fixed usage of Django Model methods by eliminating unnecessary `# type: ignore` directives; (3) Adjusted usage of functions like `get()` to align with method expectations, removing incorrect comments; Extra: (1) Deleted `pyrightconfig.json` as part of migration to a stricter type-checked environment; (2) Minor code cleanup, including formatting changes and refactoring import statements in adherence to PEP8 recommendations.
36 lines
1.1 KiB
Python
36 lines
1.1 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):
|
|
amount = FloatField(required=True)
|
|
|
|
|
|
class TransactionSerializer(ModelSerializer):
|
|
class Meta:
|
|
model = Transaction
|
|
fields = "__all__"
|
|
|
|
|
|
class TransactionProcessSerializer(ModelSerializer):
|
|
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):
|
|
min_amount = FloatField(read_only=True)
|
|
max_amount = FloatField(read_only=True)
|