<commit_before># -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from django.utils.translation import ugettext_lazy as _
from django.contrib import admin
from django.contrib.admin import SimpleListFilter
import logging

from ..forms.team import TeamAdminForm
from ..models import Role

LOG = logging.getLogger(__name__)

class RoleListFilter(SimpleListFilter):
    title = _('roles')

    parameter_name = 'role'

    def lookups(self, request, model_admin):
        qs = Role.objects.all()
        return [(-1, _("without role"))] + [(i.id, i.name) for i in qs]

    def queryset(self, request, queryset):
        if self.value():
            if self.value() == '-1':
                return queryset.exclude(role_id__in=[role.id for role in Role.objects.all()])
            else:
                return queryset.filter(role_id=self.value())

class TeamAdmin(admin.ModelAdmin):

    list_display = ["name", "role"]
    filter_horizontal = ['users']
    list_filter = (RoleListFilter, )
    search_fields = ('name',)
    #form = TeamAdminForm
<commit_msg>display email in admin<commit_after># -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from django.utils.translation import ugettext_lazy as _
from django.contrib import admin
from django.contrib.admin import SimpleListFilter
import logging

from ..forms.team import TeamAdminForm
from ..models import Role

LOG = logging.getLogger(__name__)

class RoleListFilter(SimpleListFilter):
    title = _('roles')

    parameter_name = 'role'

    def lookups(self, request, model_admin):
        qs = Role.objects.all()
        return [(-1, _("without role"))] + [(i.id, i.name) for i in qs]

    def queryset(self, request, queryset):
        if self.value():
            if self.value() == '-1':
                return queryset.exclude(role_id__in=[role.id for role in Role.objects.all()])
            else:
                return queryset.filter(role_id=self.value())

class TeamAdmin(admin.ModelAdmin):

    list_display = ["name", "role", "email"]
    filter_horizontal = ['users']
    list_filter = (RoleListFilter, )
    search_fields = ('name',)
    #form = TeamAdminForm

{'fraction_non_alphanumeric': 0.12202925045703839, 'fraction_numerical': 0.002742230347349177, 'mean_word_length': 3.234042553191489, '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': '745164', 'n_tokens_mistral': 663, 'n_tokens_neox': 642, 'n_words': 176}