mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-07-07 18:26:30 +00:00
38 lines
974 B
Python
38 lines
974 B
Python
from rest_framework import serializers
|
|
from .models import Payment, Topup
|
|
from devices.serializers import DeviceSerializer
|
|
from api.serializers import CustomReadOnlyUserSerializer
|
|
|
|
|
|
class PaymentSerializer(serializers.ModelSerializer):
|
|
devices = DeviceSerializer(many=True, read_only=True)
|
|
|
|
class Meta: # type: ignore
|
|
model = Payment
|
|
fields = "__all__"
|
|
|
|
|
|
class UpdatePaymentSerializer(serializers.ModelSerializer):
|
|
class Meta: # type: ignore
|
|
model = Payment
|
|
fields = [
|
|
"number_of_months",
|
|
]
|
|
|
|
|
|
class TopupSerializer(serializers.ModelSerializer):
|
|
user = CustomReadOnlyUserSerializer(read_only=True)
|
|
|
|
class Meta: # type: ignore
|
|
model = Topup
|
|
fields = [
|
|
"id",
|
|
"amount",
|
|
"user",
|
|
"paid",
|
|
"mib_reference",
|
|
"created_at",
|
|
"updated_at",
|
|
]
|
|
read_only_fields = ["id", "created_at", "updated_at"]
|