<commit_before>import csv

from django.http import HttpResponse

from molo.core.models import ArticlePage
from molo.profiles.admin import FrontendUsersModelAdmin
from molo.yourwords.admin import (
    YourWordsCompetitionAdmin, YourWordsCompetitionEntryAdmin)
from molo.yourwords.models import (
    YourWordsCompetition, YourWordsCompetitionEntry)
from wagtailmodeladmin.options import ModelAdminGroup
from wagtailmodeladmin.options import ModelAdmin as WagtailModelAdmin

from nurseconnect.admin_views import NurseConnectFrontendUsersAdminView


class ArticlePageModelAdmin(WagtailModelAdmin):
    model = ArticlePage
    menu_label = "Topic of the Day"
    list_display = ("title", "promote_date", "demote_date")

    def get_queryset(self, request):
        # Return only  Topic of the day articles
        queryset = ArticlePage.objects.filter(<commit_msg>Add clinic code to user admin view<commit_after>import csv

from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.admin.sites import NotRegistered
from django.http import HttpResponse

from molo.core.models import ArticlePage
from molo.profiles.admin import FrontendUsersModelAdmin, ProfileUserAdmin
from molo.yourwords.admin import (
    YourWordsCompetitionAdmin, YourWordsCompetitionEntryAdmin)
from molo.yourwords.models import (
    YourWordsCompetition, YourWordsCompetitionEntry)
from wagtailmodeladmin.options import ModelAdminGroup
from wagtailmodeladmin.options import ModelAdmin as WagtailModelAdmin

from nurseconnect.admin_views import NurseConnectFrontendUsersAdminView


try:
    admin.site.unregister(User)
except NotRegistered:
    pass


@admin.register(User)
class NurseConnectProfileUserAdmin(ProfileUserAdmin):
    list_display = ProfileUserAdmin.list_display + (
        "_clinic_code",
    )

    def _clinic_code(self, obj, *args, **kwargs):
        if (
                hasattr(obj, "profile") and
                hasattr(obj.profile, "for_nurseconnect") and
                obj.profile.for_nurseconnect.clinic_code
        ):
            return obj.profile.for_nurseconnect.clinic_code
        return ""


class ArticlePageModelAdmin(WagtailModelAdmin):
    model = ArticlePage
    menu_label = "Topic of the Day"
    list_display = ("title", "promote_date", "demote_date")

    def get_queryset(self, request):
        # Return only  Topic of the day articles
        queryset = ArticlePage.objects.filter(
{'fraction_non_alphanumeric': 0.06401313089864588, 'fraction_numerical': 0.0, 'mean_word_length': 4.429844097995546, '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': '3703553', 'n_tokens_mistral': 708, 'n_tokens_neox': 666, 'n_words': 171}