64 lines
1.7 KiB
Python
64 lines
1.7 KiB
Python
|
from rest_framework import serializers
|
||
|
|
||
|
from contest.models import Contest, Band, Frequency, QSO, EntryCategory, User, ShadowCall, Reference
|
||
|
|
||
|
|
||
|
class ContestSerializer(serializers.ModelSerializer):
|
||
|
class Meta:
|
||
|
model = Contest
|
||
|
# FIXME: add callQrg
|
||
|
fields = ('id', 'shortName', 'deadline', 'qsoStartTime', 'qsoEndTime', 'callQrg')
|
||
|
|
||
|
|
||
|
class BandSerializer(serializers.ModelSerializer):
|
||
|
# contest = ContestSerializer()
|
||
|
|
||
|
class Meta:
|
||
|
model = Band
|
||
|
fields = ('id', 'name', 'contest')
|
||
|
|
||
|
|
||
|
class FrequencySerializer(serializers.ModelSerializer):
|
||
|
# band = BandSerializer()
|
||
|
|
||
|
class Meta:
|
||
|
model = Frequency
|
||
|
fields = ('id', 'channel', 'qrg', 'band', 'note')
|
||
|
|
||
|
|
||
|
class EntryCategorySerializer(serializers.ModelSerializer):
|
||
|
class Meta:
|
||
|
model = EntryCategory
|
||
|
fields = ('id', 'name', 'description')
|
||
|
|
||
|
|
||
|
class ReferenceSerializer(serializers.ModelSerializer):
|
||
|
class Meta:
|
||
|
model = Reference
|
||
|
fields = ('id', 'name', 'description')
|
||
|
|
||
|
|
||
|
class UserSerializer(serializers.ModelSerializer):
|
||
|
ref = ReferenceSerializer()
|
||
|
cat = EntryCategorySerializer()
|
||
|
|
||
|
class Meta:
|
||
|
model = User
|
||
|
fields = ('id', 'ref', 'cat', 'location', 'opName', 'regTime', 'dncall', 'qrv2m', 'qrv70cm', 'extra2m70cm')
|
||
|
|
||
|
|
||
|
class QSOSerializer(serializers.ModelSerializer):
|
||
|
# owner = UserSerializer()
|
||
|
|
||
|
class Meta:
|
||
|
model = QSO
|
||
|
fields = ('id', 'owner', 'time', 'call', 'callRef', 'remarks')
|
||
|
|
||
|
|
||
|
class ShadowCallSerializer(serializers.ModelSerializer):
|
||
|
ref = ReferenceSerializer()
|
||
|
|
||
|
class Meta:
|
||
|
model = ShadowCall
|
||
|
fields = ('id', 'username', 'ref', 'location', 'opName', 'regTime')
|