<commit_before>from django.contrib import admin

from bejmy.categories.models import Category


@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
    list_display = (
        'name',
        'user',
        'transaction_type',
    )
    list_filter = (
        'user',
        'transaction_type',
    )
    search_fields = (
        'name',
    )
    raw_id_fields = ('parent',)

    def get_queryset(self, request, *args, **kwargs):
        queryset = super().get_queryset(request, *args, **kwargs)
        if not self.request.user.is_superuser():
            queryset = queryset.filter(user=request.user)
        return queryset<commit_msg>Access to all accounts only for superusers<commit_after>from django.contrib import admin

from bejmy.categories.models import Category

from mptt.admin import MPTTModelAdmin


@admin.register(Category)
class CategoryAdmin(MPTTModelAdmin):
    list_display = (
        'name',
        'user',
        'transaction_type',
    )
    list_filter = (
        'user',
        'transaction_type',
    )
    search_fields = (
        'name',
    )
    raw_id_fields = ('parent',)

    def get_queryset(self, request, *args, **kwargs):
        queryset = super().get_queryset(request, *args, **kwargs)
        if not self.request.user.is_superuser():
            queryset = queryset.filter(user=request.user)
        return queryset
{'fraction_non_alphanumeric': 0.1144927536231884, 'fraction_numerical': 0.0, 'mean_word_length': 2.7123655913978495, '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': '3917231', 'n_tokens_mistral': 416, 'n_tokens_neox': 414, 'n_words': 85}