<commit_before>from django import forms

class KeywordSearchForm(forms.Form):
    "Simple keyword search form"
    keywords = forms.CharField(required=False,
        help_text="one or more terms; will search anywhere in the finding aid")
    subject = forms.CharField(required=False,
        help_text="Controlled subject headings: subject, genre, geography, etc.")

    def clean(self):
        """Custom form validation.  Keywords and subjects are both optional,
        but at least one of them should contain search terms."""
        cleaned_data = self.cleaned_data<commit_msg>add repository-choice field to search form #139<commit_after>from django import forms

from findingaids.fa.models import repositories

class KeywordSearchForm(forms.Form):
    "Simple keyword search form"
    keywords = forms.CharField(required=False,
        help_text="one or more terms; will search anywhere in the finding aid")
    subject = forms.CharField(required=False,
        help_text="Controlled subject headings: subject, genre, geography, etc.")
    repo_choices = [(r, r) for r in repositories()]
    repo_choices.insert(0, ('', 'All'))     # first option should be all
    repository = forms.ChoiceField(required=False, choices=repo_choices,
            initial='', help_text="Filter by repository",
            # configure select widget to be large enough to display all choices
            widget=forms.Select(attrs={'size': len(repo_choices)}))

    def clean(self):
        """Custom form validation.  Keywords and subjects are both optional,
        but at least one of them should contain search terms."""
        cleaned_data = self.cleaned_data
{'fraction_non_alphanumeric': 0.0890909090909091, 'fraction_numerical': 0.0024242424242424242, 'mean_word_length': 3.6507042253521127, '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': '1322993', 'n_tokens_mistral': 430, 'n_tokens_neox': 422, 'n_words': 153}