class UpdateCommunityCoverSerializer(serializers.Serializer): cover = RestrictedImageFileSizeField(allow_empty_file=False, required=True, max_upload_size=settings.COMMUNITY_COVER_MAX_SIZE) community_name = serializers.CharField(max_length=settings.COMMUNITY_NAME_MAX_LENGTH, allow_blank=False, required=True, validators=[community_name_characters_validator, community_name_exists])
class CreateCommunityPostSerializer(serializers.Serializer): text = serializers.CharField(max_length=settings.POST_MAX_LENGTH, required=False, allow_blank=False) image = RestrictedImageFileSizeField(allow_empty_file=False, required=False, max_upload_size=settings.POST_IMAGE_MAX_SIZE) video = serializers.FileField(allow_empty_file=False, required=False) community_name = serializers.CharField(max_length=settings.COMMUNITY_NAME_MAX_LENGTH, allow_blank=False, required=True, validators=[community_name_characters_validator, community_name_exists])
class CreatePostSerializer(serializers.Serializer): text = serializers.CharField(max_length=settings.POST_MAX_LENGTH, required=False, allow_blank=False) image = RestrictedImageFileSizeField(allow_empty_file=False, required=False, max_upload_size=settings.POST_IMAGE_MAX_SIZE) video = serializers.FileField(allow_empty_file=False, required=False) circle_id = serializers.ListField( required=False, child=serializers.IntegerField(validators=[circle_id_exists]), )
class RegisterSerializer(serializers.Serializer): password = serializers.CharField(min_length=PASSWORD_MIN_LENGTH, max_length=PASSWORD_MAX_LENGTH, validators=[validate_password]) is_of_legal_age = serializers.BooleanField() are_guidelines_accepted = serializers.BooleanField() name = serializers.CharField(max_length=PROFILE_NAME_MAX_LENGTH, allow_blank=False, validators=[name_characters_validator]) avatar = RestrictedImageFileSizeField(allow_empty_file=True, required=False, max_upload_size=settings.PROFILE_AVATAR_MAX_SIZE) email = serializers.EmailField(validators=[email_not_taken_validator]) token = serializers.CharField()
class CreateCommunitySerializer(serializers.Serializer): type = serializers.ChoiceField(allow_blank=False, choices=Community.COMMUNITY_TYPES) name = serializers.CharField( max_length=settings.COMMUNITY_NAME_MAX_LENGTH, allow_blank=False, validators=[community_name_characters_validator]) title = serializers.CharField( max_length=settings.COMMUNITY_TITLE_MAX_LENGTH, allow_blank=False) description = serializers.CharField( max_length=settings.COMMUNITY_DESCRIPTION_MAX_LENGTH, allow_blank=True, required=False) rules = serializers.CharField( max_length=settings.COMMUNITY_RULES_MAX_LENGTH, allow_blank=True, required=False) user_adjective = serializers.CharField( max_length=settings.COMMUNITY_USER_ADJECTIVE_MAX_LENGTH, allow_blank=False, required=False) users_adjective = serializers.CharField( max_length=settings.COMMUNITY_USERS_ADJECTIVE_MAX_LENGTH, allow_blank=False, required=False) avatar = RestrictedImageFileSizeField( required=False, max_upload_size=settings.COMMUNITY_AVATAR_MAX_SIZE) cover = RestrictedImageFileSizeField( required=False, max_upload_size=settings.COMMUNITY_COVER_MAX_SIZE) invites_enabled = serializers.BooleanField(required=False) color = serializers.CharField(max_length=COLOR_ATTR_MAX_LENGTH, required=True, validators=[hex_color_validator]) categories = serializers.ListField( required=True, min_length=settings.COMMUNITY_CATEGORIES_MIN_AMOUNT, max_length=settings.COMMUNITY_CATEGORIES_MAX_AMOUNT, child=serializers.CharField( max_length=settings.HASHTAG_NAME_MAX_LENGTH, validators=[category_name_exists]), )
class UpdateAuthenticatedUserSerializer(serializers.Serializer): username = serializers.CharField(max_length=USERNAME_MAX_LENGTH, allow_blank=False, validators=[username_characters_validator], required=False) avatar = RestrictedImageFileSizeField(allow_empty_file=False, required=False, allow_null=True, max_upload_size=settings.PROFILE_AVATAR_MAX_SIZE) cover = RestrictedImageFileSizeField(allow_empty_file=False, required=False, allow_null=True, max_upload_size=settings.PROFILE_COVER_MAX_SIZE) password = serializers.CharField(min_length=PASSWORD_MIN_LENGTH, max_length=PASSWORD_MAX_LENGTH, validators=[validate_password], required=False, allow_blank=False) name = serializers.CharField(max_length=PROFILE_NAME_MAX_LENGTH, required=False, allow_blank=False, validators=[name_characters_validator]) followers_count_visible = serializers.NullBooleanField(required=False, default=None) bio = serializers.CharField(max_length=settings.PROFILE_BIO_MAX_LENGTH, required=False, allow_blank=True) url = FriendlyUrlField(required=False, allow_blank=True) location = serializers.CharField(max_length=settings.PROFILE_LOCATION_MAX_LENGTH, required=False, allow_blank=True)
class CreatePostSerializer(serializers.Serializer): text = serializers.CharField(max_length=settings.POST_MAX_LENGTH, required=False, allow_blank=False, validators=post_text_validators) # Prefer adding images with post/uuid/images image = RestrictedImageFileSizeField(allow_empty_file=False, required=False, max_upload_size=settings.POST_MEDIA_MAX_SIZE) # Prefer adding videos with post/uuid/videos video = RestrictedFileSizeField(allow_empty_file=False, required=False, max_upload_size=settings.POST_MEDIA_MAX_SIZE) circle_id = serializers.ListField( required=False, child=serializers.IntegerField(validators=[circle_id_exists]), ) is_draft = serializers.BooleanField( default=False)