<commit_before>from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
from django import forms
from django_select2.forms import Select2MultipleWidget

from grandchallenge.blogs.forms import PostForm, PostUpdateForm
from grandchallenge.core.forms import SaveFormInitMixin
from grandchallenge.jqfileupload.widgets import uploader
from grandchallenge.jqfileupload.widgets.uploader import UploadedAjaxFileList
from grandchallenge.products.models import ProjectAirFiles


class ImportForm(SaveFormInitMixin, forms.Form):
    products_file = forms.FileField()
    companies_file = forms.FileField()
    images_zip = UploadedAjaxFileList(
        widget=uploader.AjaxUploadWidget(multifile=False, auto_commit=False),
    )

    def __init__(self, *args, user, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.add_input(Submit("save", "Submit"))
        self.fields["images_zip"].widget.user = user


class ProjectAirFilesForm(SaveFormInitMixin, forms.ModelForm):
    class Meta:
        model = ProjectAirFiles
        fields = ["title", "study_file", "archive"]


class ProductsPostUpdateForm(PostUpdateForm):
    class Meta(PostUpdateForm.Meta):
        fields = (*PostUpdateForm.Meta.fields, "companies")
        widgets = {
            **PostForm.Meta.widgets,
            "companies": Select2MultipleWidget,
        }<commit_msg>inheret markdown widget (#1999)<commit_after>from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
from django import forms
from django_select2.forms import Select2MultipleWidget

from grandchallenge.blogs.forms import PostUpdateForm
from grandchallenge.core.forms import SaveFormInitMixin
from grandchallenge.jqfileupload.widgets import uploader
from grandchallenge.jqfileupload.widgets.uploader import UploadedAjaxFileList
from grandchallenge.products.models import ProjectAirFiles


class ImportForm(SaveFormInitMixin, forms.Form):
    products_file = forms.FileField()
    companies_file = forms.FileField()
    images_zip = UploadedAjaxFileList(
        widget=uploader.AjaxUploadWidget(multifile=False, auto_commit=False),
    )

    def __init__(self, *args, user, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.add_input(Submit("save", "Submit"))
        self.fields["images_zip"].widget.user = user


class ProjectAirFilesForm(SaveFormInitMixin, forms.ModelForm):
    class Meta:
        model = ProjectAirFiles
        fields = ["title", "study_file", "archive"]


class ProductsPostUpdateForm(PostUpdateForm):
    class Meta(PostUpdateForm.Meta):
        fields = (*PostUpdateForm.Meta.fields, "companies")
        widgets = {
            **PostUpdateForm.Meta.widgets,
            "companies": Select2MultipleWidget,
        }
{'fraction_non_alphanumeric': 0.09154929577464789, 'fraction_numerical': 0.0035211267605633804, 'mean_word_length': 4.330206378986867, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5882777', 'n_tokens_mistral': 832, 'n_tokens_neox': 780, 'n_words': 168}