<commit_before>import json
import logging

from django import forms
from django.conf import settings

from . import fields, report_delivery
from ..delivery import (
    fields as delivery_fields, forms as delivery_forms,
    models as delivery_models,
)

logger = logging.getLogger(__name__)


class PrepForm(
    delivery_forms.FormViewExtensionMixin,
    forms.models.ModelForm,
):
    contact_name = forms.CharField(
        label="<NAME>",
        required=False,
    )
    contact_email = forms.CharField(
        label="Email Address",
        required=True,
    )
    contact_phone = forms.CharField(
        label="Phone Number",
        required=True,
    )
    contact_notes = forms.ChoiceField(
        choices=[
            ('Morning', 'Morning'),
            ('Afternoon', 'Afternoon'),
            ('Evening', 'Evening'),
            ('No Preference', 'No Preference'),
        ],
        label='What is the best time to reach you?',
        widget=forms.RadioSelect,
        required=False,
    )
    contact_voicemail = forms.BooleanField(
        label='Is it okay if your school leaves a voicemail?',
        required=False,
    )

    class Meta:
        model = delivery_models.Report
        fields = [
            'contact_name',
            'contact_email',
            'contact_phone',
            'contact_notes',
            'contact_voicemail',
        ]


class ReportSubclassBaseForm(
    delivery_forms.FormViewExtensionMixin,
    forms.models.ModelForm,
):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.instance.report = self.view.report


class MatchingBaseForm(
    ReportSubclassBaseForm,
):
    perp_name = forms.CharField(
        label="Perpetrator's Name",
        required=False,
        widget=forms.TextInput(attrs={'placeholder': 'ex. <NAME>'}),
    )

    def save(self, commit=True):
        if self.data.get('identifier'):
            super().save(commit=commit)

            report_content = report_delivery.MatchReportContent.from_form(self)
            self.instance.encrypt_match_report(
                report_text=json.dumps(report_content.__dict__),
                key=self.cleaned_data.get('identifier'),
            )

            return self.instance
        else:
            return None
<commit_msg>wrong function arg<commit_after>import json
import logging

from django import forms
from django.conf import settings

from . import fields, report_delivery
from ..delivery import (
    fields as delivery_fields, forms as delivery_forms,
    models as delivery_models,
)

logger = logging.getLogger(__name__)


class PrepForm(
    delivery_forms.FormViewExtensionMixin,
    forms.models.ModelForm,
):
    contact_name = forms.CharField(
        label="<NAME>",
        required=False,
    )
    contact_email = forms.CharField(
        label="Email Address",
        required=True,
    )
    contact_phone = forms.CharField(
        label="Phone Number",
        required=True,
    )
    contact_notes = forms.ChoiceField(
        choices=[
            ('Morning', 'Morning'),
            ('Afternoon', 'Afternoon'),
            ('Evening', 'Evening'),
            ('No Preference', 'No Preference'),
        ],
        label='What is the best time to reach you?',
        widget=forms.RadioSelect,
        required=False,
    )
    contact_voicemail = forms.BooleanField(
        label='Is it okay if your school leaves a voicemail?',
        required=False,
    )

    class Meta:
        model = delivery_models.Report
        fields = [
            'contact_name',
            'contact_email',
            'contact_phone',
            'contact_notes',
            'contact_voicemail',
        ]


class ReportSubclassBaseForm(
    delivery_forms.FormViewExtensionMixin,
    forms.models.ModelForm,
):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.instance.report = self.view.report


class MatchingBaseForm(
    ReportSubclassBaseForm,
):
    perp_name = forms.CharField(
        label="Perpetrator's Name",
        required=False,
        widget=forms.TextInput(attrs={'placeholder': 'ex. <NAME>'}),
    )

    def save(self, commit=True):
        if self.data.get('identifier'):
            super().save(commit=commit)

            report_content = report_delivery.MatchReportContent.from_form(self)
            self.instance.encrypt_match_report(
                report_text=json.dumps(report_content.__dict__),
                identifier=self.cleaned_data.get('identifier'),
            )

            return self.instance
        else:
            return None

{'fraction_non_alphanumeric': 0.10501296456352636, 'fraction_numerical': 0.0, 'mean_word_length': 2.3230437903804737, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7535331', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1284, 'n_words': 266}