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)



[((6, 11, 6, 34), 'rest_framework.serializers.CharField', 'serializers.CharField', ({}, {}), '()', False, 'from rest_framework import serializers\n'), ((7, 16, 7, 39), 'rest_framework.serializers.SlugField', 'serializers.SlugField', ({}, {}), '()', False, 'from rest_framework import serializers\n'), ((8, 18, 8, 44), 'rest_framework.serializers.IntegerField', 'serializers.IntegerField', ({}, {}), '()', False, 'from rest_framework import serializers\n'), ((9, 20, 9, 46), 'rest_framework.serializers.IntegerField', 'serializers.IntegerField', ({}, {}), '()', False, 'from rest_framework import serializers\n'), ((10, 20, 10, 46), 'rest_framework.serializers.IntegerField', 'serializers.IntegerField', ({}, {}), '()', False, 'from rest_framework import serializers\n'), ((13, 11, 13, 48), 'rest_framework.serializers.CharField', 'serializers.CharField', (), '', False, 'from rest_framework import serializers\n'), ((15, 12, 15, 65), 'rest_framework.serializers.CharField', 'serializers.CharField', (), '', False, 'from rest_framework import serializers\n'), ((18, 15, 18, 44), 'cride.circles.models.Circle.objects.create', 'Circle.objects.create', ({}, {}), '(**data)', False, 'from cride.circles.models import Circle\n'), ((14, 90, 14, 110), 'cride.circles.models.Circle.objects.all', 'Circle.objects.all', ({}, {}), '()', False, 'from cride.circles.models import Circle\n')]