from rest_framework import serializers
from rest_framework.validators import UniqueValidator
from cride.circles.models import Circle

class CircleSerializer(serializers.Serializer):
    name = serializers.CharField()
    slug_name = serializers.SlugField()
    rides_taken = serializers.IntegerField()
    rides_offered = serializers.IntegerField()
    members_limit = serializers.IntegerField()
    
class CreateCircleSerializer(serializers.Serializer):
    name = serializers.CharField(max_length=140)
    slug_name = serializers.CharField(max_length=40, validators=[UniqueValidator(queryset=Circle.objects.all())])
    about = serializers.CharField(max_length=255, required=False)

    def create(self, data):
        return Circle.objects.create(**data)



[((193, 216), 'rest_framework.serializers.CharField', 'serializers.CharField', ([], {}), '()\n', (214, 216), False, 'from rest_framework import serializers\n'), ((233, 256), 'rest_framework.serializers.SlugField', 'serializers.SlugField', ([], {}), '()\n', (254, 256), False, 'from rest_framework import serializers\n'), ((275, 301), 'rest_framework.serializers.IntegerField', 'serializers.IntegerField', ([], {}), '()\n', (299, 301), False, 'from rest_framework import serializers\n'), ((322, 348), 'rest_framework.serializers.IntegerField', 'serializers.IntegerField', ([], {}), '()\n', (346, 348), False, 'from rest_framework import serializers\n'), ((369, 395), 'rest_framework.serializers.IntegerField', 'serializers.IntegerField', ([], {}), '()\n', (393, 395), False, 'from rest_framework import serializers\n'), ((466, 503), 'rest_framework.serializers.CharField', 'serializers.CharField', ([], {'max_length': '(140)'}), '(max_length=140)\n', (487, 503), False, 'from rest_framework import serializers\n'), ((630, 683), 'rest_framework.serializers.CharField', 'serializers.CharField', ([], {'max_length': '(255)', 'required': '(False)'}), '(max_length=255, required=False)\n', (651, 683), False, 'from rest_framework import serializers\n'), ((728, 757), 'cride.circles.models.Circle.objects.create', 'Circle.objects.create', ([], {}), '(**data)\n', (749, 757), False, 'from cride.circles.models import Circle\n'), ((594, 614), 'cride.circles.models.Circle.objects.all', 'Circle.objects.all', ([], {}), '()\n', (612, 614), False, 'from cride.circles.models import Circle\n')]