Sith/api/views/serializers.py

67 lines
1.7 KiB
Python
Raw Normal View History

2016-08-04 22:50:48 +00:00
from rest_framework import serializers
2016-08-05 18:01:23 +00:00
from counter.models import Counter
2016-08-07 20:57:38 +00:00
from core.models import User, RealGroup
2016-08-07 22:33:02 +00:00
from launderette.models import Launderette, Machine, Token
from club.models import Club
2016-08-05 18:01:23 +00:00
class CounterRead(serializers.ModelSerializer):
2016-08-05 18:01:23 +00:00
is_open = serializers.BooleanField(read_only=True)
2016-08-06 10:37:36 +00:00
barman_list = serializers.ListField(
2016-08-07 22:33:02 +00:00
child=serializers.IntegerField()
)
2016-08-05 18:01:23 +00:00
class Meta:
model = Counter
2016-08-06 10:37:36 +00:00
fields = ('id', 'name', 'type', 'is_open', 'barman_list')
class UserRead(serializers.ModelSerializer):
class Meta:
model = User
2016-08-07 20:57:38 +00:00
fields = ('id', 'first_name', 'last_name', 'email',
'date_of_birth', 'nick_name', 'is_active', 'date_joined')
class ClubRead(serializers.ModelSerializer):
class Meta:
model = Club
2016-08-07 20:57:38 +00:00
fields = ('id', 'name', 'unix_name', 'address', 'members')
class GroupRead(serializers.ModelSerializer):
class Meta:
2016-08-07 20:57:38 +00:00
model = RealGroup
2016-08-07 22:33:02 +00:00
class LaunderettePlaceRead(serializers.ModelSerializer):
machine_list = serializers.ListField(
child=serializers.IntegerField()
)
token_list = serializers.ListField(
child=serializers.IntegerField()
)
class Meta:
model = Launderette
fields = ('id', 'name', 'counter', 'machine_list',
'token_list', 'get_absolute_url')
class LaunderetteMachineRead(serializers.ModelSerializer):
class Meta:
model = Machine
fields = ('id', 'name', 'is_working', 'launderette')
class LaunderetteTokenRead(serializers.ModelSerializer):
class Meta:
model = Token
fields = ('id', 'name', 'type', 'launderette', 'borrow_date',
'user', 'is_avaliable')