<commit_before>from rest_framework import serializers

from bluebottle.accounts.serializers import UserPreviewSerializer
from bluebottle.bluebottle_drf2.serializers import (EuroField, ImageSerializer,
                                            OEmbedField)
from bluebottle.bluebottle_utils.serializers import MetaField

from apps.fund.models import Donation
from .models import FundRaiser


class FundRaiserSerializer(serializers.ModelSerializer):
    """ Serializer to view/create fundraisers """

    owner = UserPreviewSerializer(read_only=True)
    project = serializers.SlugRelatedField(source='project', slug_field='slug')
    image = ImageSerializer()
    amount = EuroField()
    amount_donated = EuroField(source='amount_donated', read_only=True)
    video_html = OEmbedField(source='video_url', maxwidth='560', maxheight='315')

    meta_data = MetaField(
            # title = 'get_meta_title',
            # fb_title = 'get_fb_title',
            # description = 'projectplan__pitch',
            # keywords = 'projectplan__tags',
            # image_source = 'projectplan__image',
            # tweet = 'get_tweet',
            )

    class Meta:
        model = FundRaiser
        fields = ('id', 'owner', 'project', 'title', 'description', 'image',
                  'video_html', 'video_url', 'amount', 'deadline',
                  'amount_donated', 'meta_data')


class FundRaiserPreviewSerializer(serializers.ModelSerializer):
    class Meta:
        model = FundRaiser
        fields = ('title', 'id')


class DonationFundRaiserSerializer(serializers.ModelSerializer):
    fundraiser = FundRaiserPreviewSerializer(read_only=True)

    class Meta:
        model = Donation
        fields = ('fundraiser',)<commit_msg>Meta data for fundraiser<commit_after>from rest_framework import serializers

from bluebottle.accounts.serializers import UserPreviewSerializer
from bluebottle.bluebottle_drf2.serializers import (EuroField, ImageSerializer,
                                            OEmbedField)
from bluebottle.bluebottle_utils.serializers import MetaField

from apps.fund.models import Donation
from .models import FundRaiser


class FundRaiserSerializer(serializers.ModelSerializer):
    """ Serializer to view/create fundraisers """

    owner = UserPreviewSerializer(read_only=True)
    project = serializers.SlugRelatedField(source='project', slug_field='slug')
    image = ImageSerializer()
    amount = EuroField()
    amount_donated = EuroField(source='amount_donated', read_only=True)
    video_html = OEmbedField(source='video_url', maxwidth='560', maxheight='315')

    meta_data = MetaField(
            # title = 'get_meta_title', # TODO: specific title format
            # fb_title = 'get_fb_title',
            # description = 'projectplan__pitch',
            # keywords = 'projectplan__tags',
            image_source = 'image',
            # tweet = 'get_tweet',
            )

    class Meta:
        model = FundRaiser
        fields = ('id', 'owner', 'project', 'title', 'description', 'image',
                  'video_html', 'video_url', 'amount', 'deadline',
                  'amount_donated', 'meta_data')


class FundRaiserPreviewSerializer(serializers.ModelSerializer):
    class Meta:
        model = FundRaiser
        fields = ('title', 'id')


class DonationFundRaiserSerializer(serializers.ModelSerializer):
    fundraiser = FundRaiserPreviewSerializer(read_only=True)

    class Meta:
        model = Donation
        fields = ('fundraiser',)
{'fraction_non_alphanumeric': 0.09914285714285714, 'fraction_numerical': 0.004, 'mean_word_length': 3.2079326923076925, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7195758', 'n_tokens_mistral': 990, 'n_tokens_neox': 941, 'n_words': 202}