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, 'rest_framework.serializers.CharField', 'serializers.CharField', False, 'from rest_framework import serializers\n'), (7, 'rest_framework.serializers.SlugField', 'serializers.SlugField', False, 'from rest_framework import serializers\n'), (8, 'rest_framework.serializers.IntegerField', 'serializers.IntegerField', False, 'from rest_framework import serializers\n'), (9, 'rest_framework.serializers.IntegerField', 'serializers.IntegerField', False, 'from rest_framework import serializers\n'), (10, 'rest_framework.serializers.IntegerField', 'serializers.IntegerField', False, 'from rest_framework import serializers\n'), (13, 'rest_framework.serializers.CharField', 'serializers.CharField', False, 'from rest_framework import serializers\n'), (15, 'rest_framework.serializers.CharField', 'serializers.CharField', False, 'from rest_framework import serializers\n'), (18, 'cride.circles.models.Circle.objects.create', 'Circle.objects.create', False, 'from cride.circles.models import Circle\n'), (14, 'cride.circles.models.Circle.objects.all', 'Circle.objects.all', False, 'from cride.circles.models import Circle\n')]