<commit_before># -*- coding: utf-8 -*-
import django_filters
from django.core.exceptions import ValidationError
from django.db import transaction
from django.utils.encoding import force_text
from rest_framework import filters, permissions, response, serializers, status, viewsets
from rest_framework.decorators import detail_route
from reversion import revisions

from democracy.models.comment import BaseComment
from democracy.views.base import AdminsSeeUnpublishedMixin, CreatedBySerializer
from democracy.views.utils import AbstractSerializerMixin

COMMENT_FIELDS = ['id', 'content', 'author_name', 'n_votes', 'created_at', 'is_registered']


class BaseCommentSerializer(AbstractSerializerMixin, CreatedBySerializer, serializers.ModelSerializer):
    is_registered = serializers.SerializerMethodField()

    def to_representation(self, instance):
        r = super().to_representation(instance)
        request = self.context.get('request', None)
        if request:
            if request.GET.get('include', None) == 'plugin_data':
                r['plugin_data'] = instance.plugin_data
        return r<commit_msg>Return comment label, geometry and images in API<commit_after># -*- coding: utf-8 -*-
import django_filters
from django.core.exceptions import ValidationError
from django.db import transaction
from django.utils.encoding import force_text
from rest_framework import filters, permissions, response, serializers, status, viewsets
from rest_framework.decorators import detail_route
from reversion import revisions

from democracy.models.comment import BaseComment
from democracy.views.base import AdminsSeeUnpublishedMixin, CreatedBySerializer
from democracy.views.utils import AbstractSerializerMixin

COMMENT_FIELDS = ['id', 'content', 'author_name', 'n_votes', 'created_at', 'is_registered',
                  'geojson', 'images', 'label']


class BaseCommentSerializer(AbstractSerializerMixin, CreatedBySerializer, serializers.ModelSerializer):
    is_registered = serializers.SerializerMethodField()

    def to_representation(self, instance):
        r = super().to_representation(instance)
        request = self.context.get('request', None)
        if request:
            if request.GET.get('include', None) == 'plugin_data':
                r['plugin_data'] = instance.plugin_data
        return r
{'fraction_non_alphanumeric': 0.0878174773999139, 'fraction_numerical': 0.0008609556607834697, 'mean_word_length': 4.883544303797469, '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': '2820140', 'n_tokens_mistral': 600, 'n_tokens_neox': 578, 'n_words': 165}