<commit_before>"""Forms for users."""

import logging

from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit, Layout, Fieldset, ButtonHolder, HTML
from django_select2.forms import Select2Widget
from taggit.forms import TagField
from taggit_labels.widgets import LabelWidget

from django import forms
from django.urls.base import reverse

from .models import Profile
from .utils import create_userjobs_for

logger = logging.getLogger(__name__)


class ProfileForm(forms.ModelForm):
    """Form for setting user's profile info."""

    tags = TagField(required=True, widget=LabelWidget, help_text="Only jobs with these tags will be shown to you.")

    class Meta:
        """ProfileForm config info."""

        model = Profile
        exclude = ('user',)
        widgets = {
            'custom_timezone': Select2Widget,
        }

    def __init__(self, *args, **kwargs):
        """Add Crispy Forms helpers."""
        super(ProfileForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.add_input(Submit('submit', 'Save'))


class CustomSignupForm(forms.ModelForm):
    """Customize django-allauth SignupForm to include tags."""

    tags = TagField(required=True, widget=LabelWidget)

    class Meta:
        """CustomSignupForm config info."""

        model = Profile
        fields = ('tags',)

    def __init__(self, *args, **kwargs):
        """Create a pretty crispy form."""
        self.helper = FormHelper()
        self.helper.form_action = reverse('account_signup')
        self.helper.form_id = 'signup_form'
        self.helper.form_class = 'signup'
        self.helper.layout = Layout(
            Fieldset(
                'Account Details',
                'username',
                'email',
                '<PASSWORD>',
                '<PASSWORD>'
            ),
            Fieldset(
                'My Profile',
                HTML("""
                    <p><small>Only jobs with these tags will be shown to you.  This can be changed later.</small></p>
                """),
                'tags'
            ),
            ButtonHolder(
                Submit('submit', 'Sign Up &raquo;')
            )
        )
        super(CustomSignupForm, self).__init__(*args, **kwargs)

    def signup(self, request, user):<commit_msg>don't force the form_action<commit_after>"""Forms for users."""

import logging

from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit, Layout, Fieldset, ButtonHolder, HTML
from django_select2.forms import Select2Widget
from taggit.forms import TagField
from taggit_labels.widgets import LabelWidget

from django import forms
from django.urls.base import reverse

from .models import Profile
from .utils import create_userjobs_for

logger = logging.getLogger(__name__)


class ProfileForm(forms.ModelForm):
    """Form for setting user's profile info."""

    tags = TagField(required=True, widget=LabelWidget, help_text="Only jobs with these tags will be shown to you.")

    class Meta:
        """ProfileForm config info."""

        model = Profile
        exclude = ('user',)
        widgets = {
            'custom_timezone': Select2Widget,
        }

    def __init__(self, *args, **kwargs):
        """Add Crispy Forms helpers."""
        super(ProfileForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.add_input(Submit('submit', 'Save'))


class CustomSignupForm(forms.ModelForm):
    """Customize django-allauth SignupForm to include tags."""

    tags = TagField(required=True, widget=LabelWidget)

    class Meta:
        """CustomSignupForm config info."""

        model = Profile
        fields = ('tags',)

    def __init__(self, *args, **kwargs):
        """Create a pretty crispy form."""
        logger.debug("Args: %s; kwargs: %s", args, kwargs)
        self.helper = FormHelper()
        # self.helper.form_action = reverse('account_signup')
        self.helper.form_id = 'signup_form'
        self.helper.form_class = 'signup'
        self.helper.layout = Layout(
            Fieldset(
                'Account Details',
                'username',
                'email',
                '<PASSWORD>',
                '<PASSWORD>'
            ),
            Fieldset(
                'My Profile',
                HTML("""
                    <p><small>Only jobs with these tags will be shown to you.  This can be changed later.</small></p>
                """),
                'tags'
            ),
            ButtonHolder(
                Submit('submit', 'Sign Up &raquo;')
            )
        )
        super(CustomSignupForm, self).__init__(*args, **kwargs)

    def signup(self, request, user):
{'fraction_non_alphanumeric': 0.11395890701122643, 'fraction_numerical': 0.0012709171785638637, 'mean_word_length': 2.274618585298197, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4601177', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1249, 'n_words': 354}