<commit_before>from bluebottle.bluebottle_drf2.serializers import ImageSerializer
from rest_framework import serializers

from bluebottle.categories.models import Category, CategoryContent


class CategoryContentSerializer(serializers.ModelSerializer):
    title = serializers.CharField(required=True)
    description = serializers.CharField(required=False)
    image = ImageSerializer(required=False)
    video_url = serializers.URLField(required=False)
    link_text = serializers.CharField(required=False)
    link_url = serializers.URLField(required=False)

    class Meta:
        model = CategoryContent
        fields = ('title', 'description', 'image', 'video_url', 'link_test', 'link_url')


class CategorySerializer(serializers.ModelSerializer):
    id = serializers.CharField(source='slug', read_only=True)
    title = serializers.CharField()
    description = serializers.CharField()
    image = ImageSerializer(required=False)
    image_logo = ImageSerializer(required=False)
    contents = CategoryContentSerializer(many=True, read_only=True)

    class Meta:
        model = Category
        fields = ('id', 'title', 'description', 'image', 'image_logo', 'contents')<commit_msg>fix category content serializer<commit_after>from bluebottle.bluebottle_drf2.serializers import ImageSerializer
from rest_framework import serializers

from bluebottle.categories.models import Category, CategoryContent


class CategoryContentSerializer(serializers.ModelSerializer):
    title = serializers.CharField(required=True)
    description = serializers.CharField(required=False)
    image = ImageSerializer(required=False)
    video_url = serializers.URLField(required=False)
    link_text = serializers.CharField(required=False)
    link_url = serializers.URLField(required=False)

    class Meta:
        model = CategoryContent
        fields = ('title', 'description', 'image', 'video_url', 'link_text', 'link_url')


class CategorySerializer(serializers.ModelSerializer):
    id = serializers.CharField(source='slug', read_only=True)
    title = serializers.CharField()
    description = serializers.CharField()
    image = ImageSerializer(required=False)
    image_logo = ImageSerializer(required=False)
    contents = CategoryContentSerializer(many=True, read_only=True)

    class Meta:
        model = Category
        fields = ('id', 'title', 'description', 'image', 'image_logo', 'contents')
{'fraction_non_alphanumeric': 0.09983361064891846, 'fraction_numerical': 0.0008319467554076539, 'mean_word_length': 5.295811518324608, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '912878', 'n_tokens_mistral': 651, 'n_tokens_neox': 644, 'n_words': 132}