<commit_before>from django.core.urlresolvers import reverse

from rest_framework import serializers

from premises.models import Contention, Premise, Report, get_fallacy_types
from premises.signals import reported_as_fallacy
from api.v1.users.serializers import UserProfileSerializer


class PremisesSerializer(serializers.ModelSerializer):
    user = UserProfileSerializer()
    absolute_url = serializers.SerializerMethodField()
    premise_type = serializers.ReadOnlyField(source='get_premise_type_display')
    supporters = UserProfileSerializer(many=True)

    class Meta:
        model = Premise
        fields = ('id', 'user', 'text', 'sources', 'parent',
                  'absolute_url', 'premise_type',
                  'date_creation', 'supporters',)

    def get_absolute_url(self, obj):
        return reverse("api-premise-detail", args=[obj.argument.id, obj.id])


class ContentionSerializer(serializers.ModelSerializer):
    user = UserProfileSerializer(read_only=True)
    premises = PremisesSerializer(many=True, read_only=True)
    absolute_url = serializers.SerializerMethodField()
    report_count = serializers.ReadOnlyField(source='reports.count')

    class Meta:
        model = Contention
        fields = ('id', 'user', 'title', 'slug', 'description',
                  'owner', 'sources', 'premises', 'date_creation',
                  'absolute_url', 'report_count', 'is_featured')
        read_only_fields = ('id', 'slug', 'absolute_url',
                            'is_featured', 'date_creation')

    def create(self, validated_data):
        instance = Contention(**validated_data)
        instance.user = self.initial['user']
        instance.ip_address = self.initial['ip']
        instance.save()
        return instance

    def get_absolute_url(self, obj):
        return reverse("api-contention-detail", args=[obj.id])
<commit_msg>argument creation default publish for api<commit_after>from django.core.urlresolvers import reverse

from rest_framework import serializers

from premises.models import Contention, Premise, Report, get_fallacy_types
from premises.signals import reported_as_fallacy
from api.v1.users.serializers import UserProfileSerializer


class PremisesSerializer(serializers.ModelSerializer):
    user = UserProfileSerializer()
    absolute_url = serializers.SerializerMethodField()
    premise_type = serializers.ReadOnlyField(source='get_premise_type_display')
    supporters = UserProfileSerializer(many=True)

    class Meta:
        model = Premise
        fields = ('id', 'user', 'text', 'sources', 'parent',
                  'absolute_url', 'premise_type',
                  'date_creation', 'supporters',)

    def get_absolute_url(self, obj):
        return reverse("api-premise-detail", args=[obj.argument.id, obj.id])


class ContentionSerializer(serializers.ModelSerializer):
    user = UserProfileSerializer(read_only=True)
    premises = PremisesSerializer(many=True, read_only=True)
    absolute_url = serializers.SerializerMethodField()
    report_count = serializers.ReadOnlyField(source='reports.count')

    class Meta:
        model = Contention
        fields = ('id', 'user', 'title', 'slug', 'description',
                  'owner', 'sources', 'premises', 'date_creation',
                  'absolute_url', 'report_count', 'is_featured')
        read_only_fields = ('id', 'slug', 'absolute_url',
                            'is_featured', 'date_creation')

    def create(self, validated_data):
        instance = Contention(**validated_data)
        instance.user = self.initial['user']
        instance.ip_address = self.initial['ip']
        instance.is_published = True
        instance.save()
        return instance

    def get_absolute_url(self, obj):
        return reverse("api-contention-detail", args=[obj.id])

{'fraction_non_alphanumeric': 0.11032308904649331, 'fraction_numerical': 0.0005253480430785396, 'mean_word_length': 3.565947242206235, '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': '1063573', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1034, 'n_words': 219}