<commit_before>from operator import itemgetter, attrgetter
from django.conf import settings

from django.contrib import admin, messages
from django.conf.urls import patterns, url
from django.contrib.admin.widgets import FilteredSelectMultiple
from django.contrib.flatpages.admin import FlatPageAdmin
from django.core.cache import cache
from django.db.models import TextField, Q
from django.forms import ModelForm, ModelMultipleChoiceField, TextInput
from django.http import HttpResponseRedirect, Http404
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
from django.utils.html import format_html
from django.utils.safestring import mark_safe

from judge.models import Language, Profile, Problem, ProblemGroup, ProblemType, Submission, Comment, \
    MiscConfig, Judge, NavigationBar, Contest, ContestParticipation, ContestProblem, Organization, BlogPost, \
    ContestProfile, SubmissionTestCase, Solution
from judge.widgets import CheckboxSelectMultipleWithSelectAll, AdminPagedownWidget, MathJaxAdminPagedownWidget

try:
    from django_select2.widgets import HeavySelect2Widget, HeavySelect2MultipleWidget, Select2Widget, Select2MultipleWidget
except ImportError:
    HeavySelect2Widget = None
    HeavySelect2MultipleWidget = None
    Select2Widget = None
    Select2MultipleWidget = None

use_select2 = HeavySelect2MultipleWidget is not None and 'django_select2' in settings.INSTALLED_APPS


class ContestProfileInlineForm(ModelForm):
    def __init__(self, *args, **kwargs):
        super(ContestProfileInlineForm, self).__init__(*args, **kwargs)
        self.fields['current'].queryset = self.instance.history.select_related('contest').all()
        self.fields['current'].label_from_instance = lambda obj: obj.contest.name


class ContestProfileInline(admin.StackedInline):
    fields = ('current',)
    model = ContestProfile
    form = ContestProfileInlineForm
    can_delete = False


class ProfileForm(ModelForm):
    class Meta:
        model = Profile
        if use_select2:
            widgets = {
                'timezone': Select2Widget,
                'organization': HeavySelect2MultipleWidget(data_view='organization_select2'),
            }<commit_msg>It's not multiple!<commit_after>from operator import itemgetter, attrgetter
from django.conf import settings

from django.contrib import admin, messages
from django.conf.urls import patterns, url
from django.contrib.admin.widgets import FilteredSelectMultiple
from django.contrib.flatpages.admin import FlatPageAdmin
from django.core.cache import cache
from django.db.models import TextField, Q
from django.forms import ModelForm, ModelMultipleChoiceField, TextInput
from django.http import HttpResponseRedirect, Http404
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
from django.utils.html import format_html
from django.utils.safestring import mark_safe

from judge.models import Language, Profile, Problem, ProblemGroup, ProblemType, Submission, Comment, \
    MiscConfig, Judge, NavigationBar, Contest, ContestParticipation, ContestProblem, Organization, BlogPost, \
    ContestProfile, SubmissionTestCase, Solution
from judge.widgets import CheckboxSelectMultipleWithSelectAll, AdminPagedownWidget, MathJaxAdminPagedownWidget

try:
    from django_select2.widgets import HeavySelect2Widget, HeavySelect2MultipleWidget, Select2Widget, Select2MultipleWidget
except ImportError:
    HeavySelect2Widget = None
    HeavySelect2MultipleWidget = None
    Select2Widget = None
    Select2MultipleWidget = None

use_select2 = HeavySelect2MultipleWidget is not None and 'django_select2' in settings.INSTALLED_APPS


class ContestProfileInlineForm(ModelForm):
    def __init__(self, *args, **kwargs):
        super(ContestProfileInlineForm, self).__init__(*args, **kwargs)
        self.fields['current'].queryset = self.instance.history.select_related('contest').all()
        self.fields['current'].label_from_instance = lambda obj: obj.contest.name


class ContestProfileInline(admin.StackedInline):
    fields = ('current',)
    model = ContestProfile
    form = ContestProfileInlineForm
    can_delete = False


class ProfileForm(ModelForm):
    class Meta:
        model = Profile
        if use_select2:
            widgets = {
                'timezone': Select2Widget,
                'organization': HeavySelect2Widget(data_view='organization_select2'),
            }
{'fraction_non_alphanumeric': 0.0701115410880947, 'fraction_numerical': 0.008650125199180514, 'mean_word_length': 4.978231292517007, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1301161', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1134, 'n_words': 306}