<commit_before>from django import forms

from go.conversation.view_definition import (
    ConversationViewDefinitionBase, EditConversationView)


class ScheduleForm(forms.Form):
    recurring = forms.CharField(
        help_text="Currently supports 'daily' or 'day_of_month'.")
    days = forms.CharField(required=False,
        help_text="Required for 'day_of_month', comma-separated numbers.")
    time = forms.CharField(help_text="Time in 'HH:MM:SS' format.")


class MessageForm(forms.Form):
    message = forms.CharField(widget=forms.Textarea)


class BaseMessageFormSet(forms.formsets.BaseFormSet):
    @staticmethod
    def initial_from_config(data):
        return [{'message': message} for message in data]

    def to_config(self):
        return [form.cleaned_data['message'] for form in self
                if form.cleaned_data and not form.cleaned_data['DELETE']]


MessageFormSet = forms.formsets.formset_factory(
    MessageForm, can_delete=True, extra=1, formset=BaseMessageFormSet)


class EditSequentialSendView(EditConversationView):
    edit_forms = (
        ('schedule', ScheduleForm),
        ('messages', MessageFormSet),
    )


class ConversationViewDefinition(ConversationViewDefinitionBase):
    edit_view = EditSequentialSendView
<commit_msg>Specify valid choices for recurring.<commit_after>from django import forms

from go.conversation.view_definition import (
    ConversationViewDefinitionBase, EditConversationView)


class ScheduleForm(forms.Form):

    RECURRING = (
        ('daily', 'Daily'),
        ('day_of_week', 'Day of Week'),
        ('day_of_month', 'Day of Month'),
        ('never', 'Never'),
    )

    recurring = forms.ChoiceField(
        choices=RECURRING,
        help_text="When messages should be sent.")

    days = forms.CharField(
        required=False,
        help_text="Which days of the week or month messages should be sent on."
                  " List of comma-separated numbers. Not required for daily"
                  " sends.")

    time = forms.CharField(
        help_text="Time at which messages should be sent, in 'HH:MM:SS'"
                  " format.")


class MessageForm(forms.Form):
    message = forms.CharField(widget=forms.Textarea)


class BaseMessageFormSet(forms.formsets.BaseFormSet):
    @staticmethod
    def initial_from_config(data):
        return [{'message': message} for message in data]

    def to_config(self):
        return [form.cleaned_data['message'] for form in self
                if form.cleaned_data and not form.cleaned_data['DELETE']]


MessageFormSet = forms.formsets.formset_factory(
    MessageForm, can_delete=True, extra=1, formset=BaseMessageFormSet)


class EditSequentialSendView(EditConversationView):
    edit_forms = (
        ('schedule', ScheduleForm),
        ('messages', MessageFormSet),
    )


class ConversationViewDefinition(ConversationViewDefinitionBase):
    edit_view = EditSequentialSendView

{'fraction_non_alphanumeric': 0.09890859481582538, 'fraction_numerical': 0.0006821282401091405, 'mean_word_length': 3.59717868338558, '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': '812622', 'n_tokens_mistral': 849, 'n_tokens_neox': 819, 'n_words': 194}