2015-06-29 04:43:17 +00:00
|
|
|
# coding=utf-8
|
|
|
|
from rest_framework import serializers
|
|
|
|
|
2015-08-07 12:25:58 +00:00
|
|
|
from .models import User
|
|
|
|
|
2015-06-29 04:43:17 +00:00
|
|
|
|
|
|
|
class UserLoginSerializer(serializers.Serializer):
|
|
|
|
username = serializers.CharField(max_length=30)
|
|
|
|
password = serializers.CharField(max_length=30)
|
2015-08-03 08:52:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UsernameCheckSerializer(serializers.Serializer):
|
|
|
|
username = serializers.CharField(max_length=30)
|
|
|
|
|
2015-08-03 10:45:26 +00:00
|
|
|
|
2015-08-05 12:11:25 +00:00
|
|
|
class EmailCheckSerializer(serializers.Serializer):
|
|
|
|
email = serializers.EmailField(max_length=254)
|
|
|
|
|
|
|
|
|
2015-08-03 10:45:26 +00:00
|
|
|
class UserRegisterSerializer(serializers.Serializer):
|
|
|
|
username = serializers.CharField(max_length=30)
|
|
|
|
real_name = serializers.CharField(max_length=30)
|
|
|
|
password = serializers.CharField(max_length=30, min_length=6)
|
2015-08-05 12:11:25 +00:00
|
|
|
email = serializers.EmailField(max_length=254)
|
2015-08-03 10:45:26 +00:00
|
|
|
|
2015-08-03 11:54:55 +00:00
|
|
|
|
|
|
|
class UserChangePasswordSerializer(serializers.Serializer):
|
|
|
|
username = serializers.CharField(max_length=30)
|
|
|
|
old_password = serializers.CharField(max_length=30, min_length=6)
|
|
|
|
new_password = serializers.CharField(max_length=30, min_length=6)
|
|
|
|
|
2015-08-07 12:25:58 +00:00
|
|
|
|
|
|
|
class UserSerializer(serializers.ModelSerializer):
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = User
|
|
|
|
exclude = ["password"]
|
|
|
|
|
|
|
|
|
|
|
|
class EditUserSerializer(serializers.Serializer):
|
|
|
|
id = serializers.IntegerField()
|
|
|
|
username = serializers.CharField(max_length=30)
|
|
|
|
real_name = serializers.CharField(max_length=30)
|
2015-08-08 06:59:42 +00:00
|
|
|
password = serializers.CharField(max_length=30, min_length=6, required=False, default=None)
|
2015-08-07 12:25:58 +00:00
|
|
|
email = serializers.EmailField(max_length=254)
|
|
|
|
admin_type = serializers.IntegerField(default=0)
|