<commit_before>from django.forms import Form, ModelForm, CharField, IntegerField, HiddenInput, \
        ModelMultipleChoiceField
from search.models import Comment, Question, Information, GoodPractice, \
    Person, Project, Event, Glossary, Community, Item
from search.widgets import TagInput, NonAdminFilteredSelectMultiple
from bootstrap3_datetime.widgets import DateTimePicker


class CommentForm(ModelForm):
    item_type = CharField(widget=HiddenInput())
    item_id = IntegerField(widget=HiddenInput())

    class Meta:
        model = Comment
        fields = ['text', 'tags']

    def __init__(self, *args, **kwargs):
        super(CommentForm, self).__init__(*args, **kwargs)
        self.fields['tags'].widget = TagInput()
        self.fields['tags'].help_text = None


class QuestionForm(ModelForm):
    item_type = CharField(widget=HiddenInput())
    item_id = IntegerField(widget=HiddenInput())

    class Meta:
        model = Question
        fields = ['title', 'text', 'tags']

    def __init__(self, *args, **kwargs):
        super(QuestionForm, self).__init__(*args, **kwargs)
        self.fields['tags'].widget = TagInput()
        self.fields['tags'].help_text = None


class DashboardForm(ModelForm):
    def __init__(self, *args, **kwargs):
        if "communities" in kwargs:
            communities = kwargs["communities"]
            del kwargs["communities"]
        else:
            communities = Community.objects
        super(DashboardForm, self).__init__(*args, **kwargs)
        self.fields['tags'].widget = TagInput()
        self.fields['tags'].help_text = None
        if 'links' in self.fields:
            self.fields['links'] = ModelMultipleChoiceField(Item.objects.all(),
                widget=NonAdminFilteredSelectMultiple("Links", False),
                required=False)
        if 'communities' in self.fields:
            self.fields['communities'] = ModelMultipleChoiceField(communities,
                widget=NonAdminFilteredSelectMultiple("Communities", False))
        if 'date' in self.fields:
            self.fields['date'].widget = \
                DateTimePicker(options={"format": "YYYY-MM-DD HH:mm",
                                        "pickSeconds": False})
        print self.fields

    class Media:
        js = ['/admin/jsi18n/']
        css = {'all': ['admin/css/widgets.css', 'css/m2m_form_widget.css'], }


class EditInformationForm(DashboardForm):
    class Meta:
        model = Information<commit_msg>Dashboard links now ordered on type, although not in alphabetical order #132<commit_after>from django.forms import Form, ModelForm, CharField, IntegerField, HiddenInput, \
        ModelMultipleChoiceField
from search.models import Comment, Question, Information, GoodPractice, \
    Person, Project, Event, Glossary, Community, Item
from search.widgets import TagInput, NonAdminFilteredSelectMultiple
from bootstrap3_datetime.widgets import DateTimePicker


class CommentForm(ModelForm):
    item_type = CharField(widget=HiddenInput())
    item_id = IntegerField(widget=HiddenInput())

    class Meta:
        model = Comment
        fields = ['text', 'tags']

    def __init__(self, *args, **kwargs):
        super(CommentForm, self).__init__(*args, **kwargs)
        self.fields['tags'].widget = TagInput()
        self.fields['tags'].help_text = None


class QuestionForm(ModelForm):
    item_type = CharField(widget=HiddenInput())
    item_id = IntegerField(widget=HiddenInput())

    class Meta:
        model = Question
        fields = ['title', 'text', 'tags']

    def __init__(self, *args, **kwargs):
        super(QuestionForm, self).__init__(*args, **kwargs)
        self.fields['tags'].widget = TagInput()
        self.fields['tags'].help_text = None


class DashboardForm(ModelForm):
    def __init__(self, *args, **kwargs):
        if "communities" in kwargs:
            communities = kwargs["communities"]
            del kwargs["communities"]
        else:
            communities = Community.objects
        super(DashboardForm, self).__init__(*args, **kwargs)
        self.fields['tags'].widget = TagInput()
        self.fields['tags'].help_text = None
        if 'links' in self.fields:
            self.fields['links'] = ModelMultipleChoiceField(
                Item.objects.order_by('type'),
                widget=NonAdminFilteredSelectMultiple("Links", False),
                required=False)
        if 'communities' in self.fields:
            self.fields['communities'] = ModelMultipleChoiceField(
                communities,
                widget=NonAdminFilteredSelectMultiple("Communities", False))
        if 'date' in self.fields:
            self.fields['date'].widget = \
                DateTimePicker(options={"format": "YYYY-MM-DD HH:mm",
                                        "pickSeconds": False})
        print self.fields

    class Media:
        js = ['/admin/jsi18n/']
        css = {'all': ['admin/css/widgets.css', 'css/m2m_form_widget.css'], }


class EditInformationForm(DashboardForm):
    class Meta:
        model = Information
{'fraction_non_alphanumeric': 0.12094861660079051, 'fraction_numerical': 0.002173913043478261, 'mean_word_length': 2.839908952959029, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2830385', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1350, 'n_words': 306}