<commit_before># -*- coding: utf-8  -*-
"""
This module contains the forms used in the activities app.
"""
from django import forms
from django.forms import ModelForm, ModelChoiceField, ModelMultipleChoiceField
from django.forms.widgets import TextInput

from clubs.models import Club
from activities.models import Activity, Episode, Review, Evaluation


class ActivityForm(ModelForm):
    """A general form, which doesn't include 'Presidency'."""
    queryset = Club.objects.exclude(english_name="Presidency")
    primary_club = ModelChoiceField(queryset=queryset,
                                    label=Activity.primary_club.field.verbose_name,
                                    help_text=Activity.primary_club.field.help_text)
    secondary_clubs = ModelMultipleChoiceField(queryset=queryset,
                                    label=Activity.secondary_clubs.field.verbose_name,
                                    help_text=Activity.secondary_clubs.field.help_text,
                                    required=False)
    episode_count = forms.CharField(widget=forms.HiddenInput())
    
    class Meta:
        model = Activity
        fields = ['primary_club', # TODO: primary club is already known (signed in):
                                  # no need to include as field
                  'name', 'category', 'description', 'public_description',
                  'organizers', 'participants',
                  'secondary_clubs', 'inside_collaborators',
                  'outside_collaborators', 'requirements',]

    def __init__(self, *args, **kwargs):
        """
        Dynamically add date, time and location fields based on how many
        Episodes are added in the original form. The number of episodes is
        included as a hidden field with the name episode_count.
        Based on this StackOverflow thread:
        http://stackoverflow.com/questions/6142025/dynamically-add-field-to-a-form
        """
        # If an instance is passed, then store it in the instance variable.
        # This will be used in populating the episode fields when an instance
        # is passed.
        instance = kwargs.get('instance', None)
                <commit_msg>Primary club should be chosen automatically.  Also, hide all presidency clubs.<commit_after># -*- coding: utf-8  -*-
"""
This module contains the forms used in the activities app.
"""
from django import forms
from django.forms import ModelForm, ModelChoiceField, ModelMultipleChoiceField
from django.forms.widgets import TextInput

from clubs.models import Club
from activities.models import Activity, Episode, Review, Evaluation


class ActivityForm(ModelForm):
    """A general form, which doesn't include 'Presidency'."""
    queryset = Club.objects.exclude(english_name__startswith="Presidency")
    secondary_clubs = ModelMultipleChoiceField(queryset=queryset,
                                    label=Activity.secondary_clubs.field.verbose_name,
                                    help_text=Activity.secondary_clubs.field.help_text,
                                    required=False)
    episode_count = forms.CharField(widget=forms.HiddenInput())
    
    class Meta:
        model = Activity
        fields = [ 'name', 'category', 'description',
                   'public_description', 'organizers', 'participants',
                   'secondary_clubs', 'inside_collaborators',
                   'outside_collaborators', 'requirements',]

    def __init__(self, *args, **kwargs):
        """
        Dynamically add date, time and location fields based on how many
        Episodes are added in the original form. The number of episodes is
        included as a hidden field with the name episode_count.
        Based on this StackOverflow thread:
        http://stackoverflow.com/questions/6142025/dynamically-add-field-to-a-form
        """
        # If an instance is passed, then store it in the instance variable.
        # This will be used in populating the episode fields when an instance
        # is passed.
        instance = kwargs.get('instance', None)
                
{'fraction_non_alphanumeric': 0.08133268005879471, 'fraction_numerical': 0.0039196472317491425, 'mean_word_length': 2.4138795986622075, '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': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1504450', 'n_tokens_mistral': 1024, 'n_tokens_neox': 983, 'n_words': 313}