<commit_before>from django import forms
from models import Module, Area

class DatatableForm(forms.Form):
    sorting = forms.CharField(required = False)
    filter_lob = forms.CharField(required = False)
    filter_year= forms.IntegerField(required = False, max_value=2020, min_value=2010)
    filter_quarter= forms.IntegerField(required = False, max_value=4, min_value=1)
    num_line = forms.IntegerField()

    def clean_sorting(self):
        data = self.cleaned_data['sorting']
        valid_list = ['year', 'quarter','penetration','-year','-quarter','-penetration']
        if not data:
           return '-penetration'
        elif data not in valid_list:
           raise forms.ValidationError("Bad sort field!")
        return data   
  
    def clean_filter_lob(self):
        data = self.cleaned_data['filter_lob']
        valid_list = ['Video', 'HSD','CDV','XHS','',None]
        if data not in valid_list:
           raise forms.ValidationError("Bad LOB filter field!")
        return data


class ChartFilterForm(forms.Form):
    filter_module = forms.ModelMultipleChoiceField(
        label = "Please Select Module(s)",
        queryset=Module.objects.all(),
        required=False,
        widget=forms.SelectMultiple(attrs={"class": "form-control"}))
    filter_area = forms.ModelMultipleChoiceField(
        label = "Please Select Area(s)",
        queryset=Area.objects.all(),
        required=False,
        widget=forms.SelectMultiple(attrs={"class": "form-control"}))<commit_msg>chart filter form<commit_after>from django import forms
from models import Module, Area

class DatatableForm(forms.Form):
    sorting = forms.CharField(required = False)
    filter_lob = forms.CharField(required = False)
    filter_year= forms.IntegerField(required = False, max_value=2020, min_value=2010)
    filter_quarter= forms.IntegerField(required = False, max_value=4, min_value=1)
    num_line = forms.IntegerField()

    def clean_sorting(self):
        data = self.cleaned_data['sorting']
        valid_list = ['year', 'quarter','penetration','-year','-quarter','-penetration']
        if not data:
           return '-penetration'
        elif data not in valid_list:
           raise forms.ValidationError("Bad sort field!")
        return data   
  
    def clean_filter_lob(self):
        data = self.cleaned_data['filter_lob']
        valid_list = ['Video', 'HSD','CDV','XHS','',None]
        if data not in valid_list:
           raise forms.ValidationError("Bad LOB filter field!")
        return data


class ChartFilterForm(forms.Form):
    filter_module = forms.ModelMultipleChoiceField(
        label = "Please Select Module(s)",
        queryset=Module.objects.all(),
        required=False,
        widget=forms.SelectMultiple(attrs={"class": "form-control"}))
    filter_area = forms.ModelMultipleChoiceField(
        label = "Please Select Area(s)",
        queryset=Area.objects.all(),
        required=False,
        widget=forms.CheckboxSelectMultiple(attrs={"class": "form-control"}))
{'fraction_non_alphanumeric': 0.1213527851458886, 'fraction_numerical': 0.006631299734748011, 'mean_word_length': 3.3285509325681493, 'pattern_counts': {'":': 4, '<': 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': '7455886', 'n_tokens_mistral': 891, 'n_tokens_neox': 868, 'n_words': 187}