<commit_before>from django.contrib import admin
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin

from .registration.models import Team
from .registration.admin import InlineTeamAdmin
from .util import format_lazy


class CTFAdminSite(admin.AdminSite):
    """
    Custom variant of the AdminSite which replaces the default headers and titles.
    """

    site_header = format_lazy(_('{competition_name} administration'),
                              competition_name=settings.COMPETITION_NAME)
    site_title = site_header
    index_title = _('Administration home')


admin_site = CTFAdminSite()    # pylint: disable=invalid-name


@admin.register(User, site=admin_site)
class CTFUserAdmin(UserAdmin):
    """
    Custom variant of UserAdmin which adjusts the displayed, filterable and editable fields and adds an
    InlineModelAdmin for the associated team.
    """

    class TeamListFilter(admin.SimpleListFilter):
        """
        Admin list filter which allows filtering of user lists by whether they are associated with a Team.
        """
        title = _('associated team')
        parameter_name = 'has_team'

        def lookups(self, request, model_admin):
            return (
                ('1', _('Yes')),
                ('0', _('No'))<commit_msg>Web: Add email field to user creation form<commit_after>from django.contrib import admin
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin

from .registration.models import Team
from .registration.admin import InlineTeamAdmin
from .util import format_lazy


class CTFAdminSite(admin.AdminSite):
    """
    Custom variant of the AdminSite which replaces the default headers and titles.
    """

    site_header = format_lazy(_('{competition_name} administration'),
                              competition_name=settings.COMPETITION_NAME)
    site_title = site_header
    index_title = _('Administration home')


admin_site = CTFAdminSite()    # pylint: disable=invalid-name


@admin.register(User, site=admin_site)
class CTFUserAdmin(UserAdmin):
    """
    Custom variant of UserAdmin which adjusts the displayed, filterable and editable fields and adds an
    InlineModelAdmin for the associated team.
    """

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # Add email field to user creation form
        for fieldset in self.add_fieldsets:
            if fieldset[0] is None:
                fieldset[1]['fields'] += ('email',)

    class TeamListFilter(admin.SimpleListFilter):
        """
        Admin list filter which allows filtering of user lists by whether they are associated with a Team.
        """
        title = _('associated team')
        parameter_name = 'has_team'

        def lookups(self, request, model_admin):
            return (
                ('1', _('Yes')),
                ('0', _('No'))
{'fraction_non_alphanumeric': 0.086073500967118, 'fraction_numerical': 0.0019342359767891683, 'mean_word_length': 3.0882740447957837, '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': '7126845', 'n_tokens_mistral': 845, 'n_tokens_neox': 807, 'n_words': 263}