<commit_before>from django.contrib import admin

from .models import UserProfile, Calendar, Event


class ProfileAdmin(admin.ModelAdmin):
    list_display = ('user_name',)
    search_fields = ['user__username']

    def user_name(self, obj):
        return obj.user.username
    user_name.short_description = 'username'

admin.site.register(UserProfile, ProfileAdmin)
admin.site.register(Calendar, admin.ModelAdmin)
admin.site.register(Event, admin.ModelAdmin)<commit_msg>Improvements to user profile admin<commit_after>from django.contrib import admin

from devmo.urlresolvers import reverse

from taggit_extras.managers import NamespacedTaggableManager
from taggit.forms import TagWidget, TagField

from .models import UserProfile, Calendar, Event


class ProfileAdmin(admin.ModelAdmin):
    
    list_display = ('user_name', 'related_user', 'fullname', 'title',
                    'organization', 'location','content_flagging_email',
                    'tags', )

    list_editable = ('content_flagging_email', 'tags', )
    
    search_fields = ('user__username', 'homepage', 'title', 'fullname',
                     'organization', 'location', 'bio', 'misc', 
                     'user__email', 'tags__name', )

    list_filter = ()

    formfield_overrides = {
        NamespacedTaggableManager: {
            "widget": TagWidget(attrs={"size": 45})
        }
    }

    def related_user(self, obj):
        """HTML link to related user account"""
        link = reverse('admin:auth_user_change', args=(obj.user.id,))
        # TODO: Needs l10n? Maybe not a priority for an admin page.
        return ('<a href="%(link)s"><strong>User %(id)s</strong></a>' % dict(
            link=link, id=obj.user.id, username=obj.user.username))

    related_user.allow_tags = True
    related_user.short_description = 'User account'

    def user_name(self, obj):
        return obj.user.username

    user_name.short_description = 'User name'


admin.site.register(UserProfile, ProfileAdmin)
admin.site.register(Calendar, admin.ModelAdmin)
admin.site.register(Event, admin.ModelAdmin)
{'fraction_non_alphanumeric': 0.11911623439000961, 'fraction_numerical': 0.0019212295869356388, 'mean_word_length': 3.5381263616557734, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, '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': '5730343', 'n_tokens_mistral': 626, 'n_tokens_neox': 597, 'n_words': 135}