<commit_before># -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals

# Third Party Stuff
from django import forms

from .models import Category, TemplateFormat


def _get_category_choices():
    return [(category.slug, category.category_name)
            for category in Category.objects.all()]


def _get_template_choices():
    return [(template.slug, template.template_name)
            for template in TemplateFormat.objects.all()]


class CreateCategoryForm(forms.Form):
    """
    used for creating a category
    """

    category_name = forms.CharField(max_length=255,
                                   min_length=4,
                                   required=True,
                                   label="Enter Category Name",
                                   widget=forms.TextInput(attrs=
                                   {'class': "form-control"}))
    description = forms.CharField(label="Description of Category",
                                  widget=forms.Textarea(attrs=
                                  {"class": "form-control"}))


class TemplateFormatForm(forms.Form):
    """
    used for creating a template format
    """
    category = forms.ChoiceField(label="Category",
                                 required=True,
                                 widget=forms.Select(attrs={
                                'class': 'form-control dropdown'}))
    template_name = forms.CharField(max_length=225,
                                   label="Template Name",
                                   min_length=3,
                                   required=True,
                                   widget=forms.TextInput(attrs={
                                   'class': 'form-control'}))

    def __init__(self, *args, **kwargs):
        super(TemplateFormatForm, self).__init__(*args, **kwargs)
        self.fields['category'].choices = _get_category_choices()


class DocumentForm(forms.Form):
    """
    Used to upload new document
    """
    category = forms.ChoiceField(label="Category",
                                 required=True,
                                 widget=forms.Select(attrs={
                                'class': 'form-control dropdown'}))
    template = forms.ChoiceField(label="Template",
                                 required=True,
                                 widget=forms.Select(attrs={
                                'class': 'form-control dropdown'}))
    document_name = forms.CharField(label='Name of document',
                                    required=True,
                                    max_length=255,
                                    widget=forms.TextInput(attrs={
                                        'class': 'form-control'
                                    }))
    document = forms.FileField(label="Upload File",
                               required=True,
                               widget=forms.FileInput(attrs={
                               'class': 'form-control'}))

    def __init__(self, *args, **kwargs):
        super(DocumentForm, self).__init__(*args, **kwargs)
        self.fields['category'].choices = _get_category_choices()
        self.fields['template'].choices = _get_template_choices()<commit_msg>remove form-control class from filefield<commit_after># -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals

# Third Party Stuff
from django import forms

from .models import Category, TemplateFormat


def _get_category_choices():
    return [(category.slug, category.category_name)
            for category in Category.objects.all()]


def _get_template_choices():
    return [(template.slug, template.template_name)
            for template in TemplateFormat.objects.all()]


class CreateCategoryForm(forms.Form):
    """
    used for creating a category
    """

    category_name = forms.CharField(max_length=255,
                                   min_length=4,
                                   required=True,
                                   label="Enter Category Name",
                                   widget=forms.TextInput(attrs=
                                   {'class': "form-control"}))
    description = forms.CharField(label="Description of Category",
                                  widget=forms.Textarea(attrs=
                                  {"class": "form-control"}))


class TemplateFormatForm(forms.Form):
    """
    used for creating a template format
    """
    category = forms.ChoiceField(label="Category",
                                 required=True,
                                 widget=forms.Select(attrs={
                                'class': 'form-control dropdown'}))
    template_name = forms.CharField(max_length=225,
                                   label="Template Name",
                                   min_length=3,
                                   required=True,
                                   widget=forms.TextInput(attrs={
                                   'class': 'form-control'}))

    def __init__(self, *args, **kwargs):
        super(TemplateFormatForm, self).__init__(*args, **kwargs)
        self.fields['category'].choices = _get_category_choices()


class DocumentForm(forms.Form):
    """
    Used to upload new document
    """
    category = forms.ChoiceField(label="Category",
                                 required=True,
                                 widget=forms.Select(attrs={
                                'class': 'form-control dropdown'}))
    template = forms.ChoiceField(label="Template",
                                 required=True,
                                 widget=forms.Select(attrs={
                                'class': 'form-control dropdown'}))
    document_name = forms.CharField(label='Name of document',
                                    required=True,
                                    max_length=255,
                                    widget=forms.TextInput(attrs={
                                        'class': 'form-control'
                                    }))
    document = forms.FileField(label="Upload File",
                               required=True)

    def __init__(self, *args, **kwargs):
        super(DocumentForm, self).__init__(*args, **kwargs)
        self.fields['category'].choices = _get_category_choices()
        self.fields['template'].choices = _get_template_choices()
{'fraction_non_alphanumeric': 0.10032664489034064, 'fraction_numerical': 0.003733084461035931, 'mean_word_length': 1.4109486314210724, 'pattern_counts': {'":': 2, '<': 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': 46, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1838165', 'n_tokens_mistral': 1512, 'n_tokens_neox': 1439, 'n_words': 286}