<commit_before>from django.contrib import admin

from .models import JoinInvitation, InvitationStat


class InvitationStatAdmin(admin.ModelAdmin):
    raw_id_fields = ["user"]
    readonly_fields = ["invites_sent", "invites_accepted"]
    list_display = [
        "user",
        "invites_sent",
        "invites_accepted",
        "invites_allocated",
        "invites_remaining",
        "can_send"
    ]
    list_filter = ["invites_sent", "invites_accepted"]


admin.site.register(
    JoinInvitation,
    list_display=["from_user", "to_user", "sent", "status", "to_user_email"],
    list_filter=["sent", "status"],
    search_fields=["from_user__username"]
)
admin.site.register(InvitationStat, InvitationStatAdmin)<commit_msg>don't assume AUTH_USER_MODEL USERNAME_FIELD is username<commit_after>from django.contrib import admin
from django.contrib.auth import get_user_model

from .models import JoinInvitation, InvitationStat


User = get_user_model()


class InvitationStatAdmin(admin.ModelAdmin):
    raw_id_fields = ["user"]
    readonly_fields = ["invites_sent", "invites_accepted"]
    list_display = [
        "user",
        "invites_sent",
        "invites_accepted",
        "invites_allocated",
        "invites_remaining",
        "can_send"
    ]
    list_filter = ["invites_sent", "invites_accepted"]


admin.site.register(
    JoinInvitation,
    list_display=["from_user", "to_user", "sent", "status", "to_user_email"],
    list_filter=["sent", "status"],
    search_fields=["from_user__{}".format(User.USERNAME_FIELD)]
)
admin.site.register(InvitationStat, InvitationStatAdmin)
{'fraction_non_alphanumeric': 0.12382739212007504, 'fraction_numerical': 0.0, 'mean_word_length': 4.351170568561873, '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': '3071107', 'n_tokens_mistral': 519, 'n_tokens_neox': 511, 'n_words': 86}