<commit_before>from .models import MapItData

from django import forms

class PostcodeForm(forms.Form):
    postcode = forms.CharField(
        label='Enter your postcode',
        max_length=20
    )

class ConstituencyForm(forms.Form):
    constituency = forms.ChoiceField(
        label='Select a constituency',
        choices=[('', '')] + sorted(
            [
                (mapit_id, constituency['name'])
                for mapit_id, constituency
                in MapItData.constituencies_2010.items()
            ],
            key=lambda t: t[1]
        )
    )


class BaseCandidacyForm(forms.Form):
    person_id = forms.CharField(
        label='Person ID',
        max_length=256,
    )
    mapit_area_id = forms.CharField(
        label='MapIt Area ID',
        max_length=256,
    )

class CandidacyCreateForm(BaseCandidacyForm):
    source = forms.CharField(
        label="Source of information that they're standing",
        max_length=512,
    )

class CandidacyDeleteForm(BaseCandidacyForm):
    source = forms.CharField(
        label="Information source for this change",
        max_length=512,
    )

class BasePersonForm(forms.Form):
    name = forms.CharField(
        label="Full name",
        max_length=256,
    )
    party = forms.CharField(
        label="Party in 2015",
        max_length=256,
    )
    email = forms.CharField(
        label="Email",
        max_length=256,
        required=False,
    )
    date_of_birth = forms.DateField(
        label="Date of birth",
        required=False,
    )
    wikipedia_url = forms.CharField(
        label="Wikipedia URL",
        max_length=256,
        required=False,
    )
    homepage_url = forms.CharField(
        label="Homepage URL",
        max_length=256,
        required=False,
    )
    twitter_username = forms.CharField(
        label="Twitter username",
        max_length=256,
        required=False,
    )


class NewPersonForm(BasePersonForm):
    constituency = forms.CharField(
        label="Constituency in 2015",
        max_length=256,
        widget=forms.HiddenInput(),
    )
    source = forms.CharField(
        label="Source of information",
        max_length=512,
    )

class UpdatePersonForm(BasePersonForm):
    standing = forms.BooleanField(
        label='Standing in 2015',
        required=False,
    )
    constituency = forms.ChoiceField(
        label='Constituency in 2015',
        required=False,
        choices=[('', '')] + sorted(
            [
                (mapit_id, constituency['name'])
                for mapit_id, constituency
                in MapItData.constituencies_2010.items()
            ],
            key=lambda t: t[1]
        )
    )
    source = forms.CharField(
        label="Source of information for this change",
        max_length=512,
    )
<commit_msg>Make the 'information source' fields more helpful<commit_after>from .models import MapItData

from django import forms

class PostcodeForm(forms.Form):
    postcode = forms.CharField(
        label='Enter your postcode',
        max_length=20
    )

class ConstituencyForm(forms.Form):
    constituency = forms.ChoiceField(
        label='Select a constituency',
        choices=[('', '')] + sorted(
            [
                (mapit_id, constituency['name'])
                for mapit_id, constituency
                in MapItData.constituencies_2010.items()
            ],
            key=lambda t: t[1]
        )
    )


class BaseCandidacyForm(forms.Form):
    person_id = forms.CharField(
        label='Person ID',
        max_length=256,
    )
    mapit_area_id = forms.CharField(
        label='MapIt Area ID',
        max_length=256,
    )

class CandidacyCreateForm(BaseCandidacyForm):
    source = forms.CharField(
        label="Source of information that they're standing",
        max_length=512,
    )

class CandidacyDeleteForm(BaseCandidacyForm):
    source = forms.CharField(
        label="Information source for this change",
        max_length=512,
    )

class BasePersonForm(forms.Form):
    name = forms.CharField(
        label="Full name",
        max_length=256,
    )
    party = forms.CharField(
        label="Party in 2015",
        max_length=256,
    )
    email = forms.CharField(
        label="Email",
        max_length=256,
        required=False,
    )
    date_of_birth = forms.DateField(
        label="Date of birth",
        required=False,
    )
    wikipedia_url = forms.CharField(
        label="Wikipedia URL",
        max_length=256,
        required=False,
    )
    homepage_url = forms.CharField(
        label="Homepage URL",
        max_length=256,
        required=False,
    )
    twitter_username = forms.CharField(
        label="Twitter username",
        max_length=256,
        required=False,
    )


class NewPersonForm(BasePersonForm):
    constituency = forms.CharField(
        label="Constituency in 2015",
        max_length=256,
        widget=forms.HiddenInput(),
    )
    source = forms.CharField(
        label="Source of information",
        max_length=512,
        error_messages={
            'required': 'You must indicate how you know about this candidate'
        },
        widget=forms.TextInput(
            attrs={
                'required': 'required',
                'placeholder': 'How you know about this candidate'
            }
        )
    )

class UpdatePersonForm(BasePersonForm):
    standing = forms.BooleanField(
        label='Standing in 2015',
        required=False,
    )
    constituency = forms.ChoiceField(
        label='Constituency in 2015',
        required=False,
        choices=[('', '')] + sorted(
            [
                (mapit_id, constituency['name'])
                for mapit_id, constituency
                in MapItData.constituencies_2010.items()
            ],
            key=lambda t: t[1]
        )
    )
    source = forms.CharField(
        label="Source of information for this change",
        max_length=512,
        error_messages={
            'required': 'You must indicate how you know about this candidate'
        },
        widget=forms.TextInput(
            attrs={
                'required': 'required',
                'placeholder': 'How you know about this candidate'
            }
        )
    )

{'fraction_non_alphanumeric': 0.10041440867070449, 'fraction_numerical': 0.021357985336308574, 'mean_word_length': 2.0182780182780182, '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': '6468307', 'n_tokens_mistral': 1903, 'n_tokens_neox': 1778, 'n_words': 372}