2016-08-23 16:13:58 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
|
|
|
|
from rest_framework import serializers
|
|
|
|
|
2016-08-24 09:14:21 +00:00
|
|
|
from .models import User, UserGroup
|
2016-08-23 16:13:58 +00:00
|
|
|
|
|
|
|
|
2016-08-24 04:29:19 +00:00
|
|
|
class UserSerializer(serializers.ModelSerializer):
|
2016-08-25 05:28:02 +00:00
|
|
|
groups = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='users:usergroup-detail-api')
|
|
|
|
|
2016-08-23 16:13:58 +00:00
|
|
|
class Meta:
|
|
|
|
model = User
|
2016-08-24 09:14:21 +00:00
|
|
|
exclude = [
|
2016-08-24 11:42:16 +00:00
|
|
|
'password', 'first_name', 'last_name', 'secret_key_otp',
|
|
|
|
'private_key', 'public_key', 'avatar',
|
2016-08-24 09:14:21 +00:00
|
|
|
]
|
2016-08-24 04:29:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UserGroupSerializer(serializers.ModelSerializer):
|
2016-08-25 05:28:02 +00:00
|
|
|
users = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='users:user-detail-api')
|
|
|
|
|
2016-08-24 04:29:19 +00:00
|
|
|
class Meta:
|
|
|
|
model = UserGroup
|
|
|
|
fields = '__all__'
|
|
|
|
|
|
|
|
|