Ejemplo n.º 1
0
 class Meta:
     model = Profile
     exclude = (
         'mates',
         'email_code',
         'phone_code',
     )
     validators = [ValidateInterestsCount()]
Ejemplo n.º 2
0
 class Meta:
     model = Profile
     validators = [ValidateInterestsCount()]
     fields = (
         'id',
         'picture',
         'living_city',
         'full_name',
     )
Ejemplo n.º 3
0
 class Meta:
     model = Profile
     validators = [ValidateInterestsCount()]
     fields = (
         'id',
         'photo_url',
         'age',
         'living_city',
         'interests',
         'referece',
         'status',
     )
Ejemplo n.º 4
0
class ProfileSerializer(serializers.ModelSerializer):
    languages = LanguageSerializer(
        many=True,
        read_only=True,
    )
    interests = serializers.PrimaryKeyRelatedField(
        many=True,
        queryset=Interest.objects.all(),
        validators=[ValidateInterestsCount()])
    references = serializers.PrimaryKeyRelatedField(
        source='references_to', many=True, queryset=Reference.objects.all())
    reference_rate = serializers.CharField(source='get_average_rate',
                                           read_only=True)
    photo_url = serializers.CharField(source='get_photo_url', read_only=True)
    photos = serializers.ListField(source='get_photos', read_only=True)
    photo = Base64ImageField(
        max_length=None,
        use_url=True,
    )
    device_registration_ids = serializers.ListField(
        source='get_device_registration_ids',
        read_only=True,
    )

    class Meta:
        model = Profile
        exclude = (
            'mates',
            'email_code',
            'phone_code',
        )
        validators = [ValidateInterestsCount()]

    def update(self, instance, validated_data):
        try:
            instance.interests = validated_data.pop('interests')
        except KeyError:
            pass

        for attr, value in validated_data.items():
            setattr(instance, attr, value)

        instance.save()
        return instance
Ejemplo n.º 5
0
 class Meta:
     model = Poll
     fields = ('id', 'text', 'interests')
     validators = [ValidateInterestsCount()]
Ejemplo n.º 6
0
 class Meta:
     model = Poll
     fields = ('id', 'text', 'author', 'interests', 'latitude', 'longitude',
               'address')
     validators = [ValidateInterestsCount()]