<commit_before>from django.contrib import admin
from cog.models import *
from django.shortcuts import get_object_or_404

class ProjectAdmin(admin.ModelAdmin):
    pass

admin.site.register(Project, ProjectAdmin)

admin.site.register(Doc)

class NewsAdmin(admin.ModelAdmin):

    fields = ('title', 'text')
    readonly_fields = ('author', 'project', 'other_projects')
    date_hierarchy = 'update_date'

    def save_model(self, request, obj, form, change):

        if (change==False):
            project_short_name = request.GET['project']
            project = get_object_or_404(Project, short_name__iexact=project_short_name)
            obj.author = request.user
            obj.project = project
            # must obtain a primary key first
            obj.save()
            for other_project_short_name in request.GET.getlist('other_projects'):
                other_project = get_object_or_404(Project, short_name__iexact=other_project_short_name)
                obj.other_projects.add(other_project)
                obj.save()
        else:
            obj.save()

admin.site.register(News, NewsAdmin)

class PostAdmin(admin.ModelAdmin):
    pass
admin.site.register(Post, PostAdmin)

admin.site.register(Topic, admin.ModelAdmin)

admin.site.register(SearchFacet, admin.ModelAdmin)
admin.site.register(SearchProfile, admin.ModelAdmin)

admin.site.register(Folder, admin.ModelAdmin)

admin.site.register(Bookmark, admin.ModelAdmin)

admin.site.register(Lock, admin.ModelAdmin)

admin.site.register(ProjectTag, admin.ModelAdmin)

admin.site.register(UserProfile, admin.ModelAdmin)

admin.site.register(PeerSite, admin.ModelAdmin)

admin.site.register(DataCart, admin.ModelAdmin)

admin.site.register(Permission, admin.ModelAdmin)

admin.site.register(ManagementBodyPurpose, admin.ModelAdmin)

admin.site.register(Forum, admin.ModelAdmin)

admin.site.register(ForumTopic, admin.ModelAdmin)

admin.site.register(ForumThread, admin.ModelAdmin)<commit_msg>Enabdling admin search on UserProfile objects.<commit_after>from django.contrib import admin
from cog.models import *
from django.shortcuts import get_object_or_404

class ProjectAdmin(admin.ModelAdmin):
    pass

admin.site.register(Project, ProjectAdmin)

admin.site.register(Doc)

class NewsAdmin(admin.ModelAdmin):

    fields = ('title', 'text')
    readonly_fields = ('author', 'project', 'other_projects')
    date_hierarchy = 'update_date'

    def save_model(self, request, obj, form, change):

        if (change==False):
            project_short_name = request.GET['project']
            project = get_object_or_404(Project, short_name__iexact=project_short_name)
            obj.author = request.user
            obj.project = project
            # must obtain a primary key first
            obj.save()
            for other_project_short_name in request.GET.getlist('other_projects'):
                other_project = get_object_or_404(Project, short_name__iexact=other_project_short_name)
                obj.other_projects.add(other_project)
                obj.save()
        else:
            obj.save()

admin.site.register(News, NewsAdmin)

class PostAdmin(admin.ModelAdmin):
    pass
admin.site.register(Post, PostAdmin)

admin.site.register(Topic, admin.ModelAdmin)

admin.site.register(SearchFacet, admin.ModelAdmin)
admin.site.register(SearchProfile, admin.ModelAdmin)

admin.site.register(Folder, admin.ModelAdmin)

admin.site.register(Bookmark, admin.ModelAdmin)

admin.site.register(Lock, admin.ModelAdmin)

admin.site.register(ProjectTag, admin.ModelAdmin)

class UserProfileAdmin(admin.ModelAdmin):
    search_fields = ['user__username', 'user__first_name', 'user__last_name', 'user__email']
admin.site.register(UserProfile, UserProfileAdmin)

admin.site.register(PeerSite, admin.ModelAdmin)

admin.site.register(DataCart, admin.ModelAdmin)

admin.site.register(Permission, admin.ModelAdmin)

admin.site.register(ManagementBodyPurpose, admin.ModelAdmin)

admin.site.register(Forum, admin.ModelAdmin)

admin.site.register(ForumTopic, admin.ModelAdmin)

admin.site.register(ForumThread, admin.ModelAdmin)
{'fraction_non_alphanumeric': 0.10454323400097704, 'fraction_numerical': 0.004396678065461651, 'mean_word_length': 4.176991150442478, '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': '1141029', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1217, 'n_words': 211}