<commit_before>from django.views.generic.base import TemplateView

from .dashboard import (IndexDashboard,
    ProblemsDashboard, ContentDashboard,
    CompetitionDashboard, UserDashboard
    )


class DashboardIndexView(TemplateView):
    template_name = "admin_custom/index.html"

    def get_context_data(self, *args, **kwargs):
        context = super(DashboardIndexView, self).get_context_data(*args,
                                                                   **kwargs)
        context['dashboard'] = IndexDashboard()
        return context


class DashboardProblemsView(TemplateView):
    template_name = "admin_custom/index.html"

    def get_context_data(self, *args, **kwargs):
        context = super(DashboardProblemsView, self).get_context_data(*args,
                                                                      **kwargs)
        context['dashboard'] = ProblemsDashboard()
        return context


class DashboardContentView(TemplateView):
    template_name = "admin_custom/index.html"

    def get_context_data(self, *args, **kwargs):
        context = super(DashboardContentView, self).get_context_data(*args,
                                                                      **kwargs)
        context['dashboard'] = ContentDashboard()
        return context


class DashboardCompetitionView(TemplateView):
    template_name = "admin_custom/index.html"

    def get_context_data(self, *args, **kwargs):
        context = super(DashboardCompetitionView, self).get_context_data(*args,
                                                                      **kwargs)
        context['dashboard'] = CompetitionDashboard()
        return context


class DashboardUsersView(TemplateView):
    template_name = "admin_custom/index.html"

    def get_context_data(self, *args, **kwargs):
        context = super(DashboardUsersView, self).get_context_data(*args,
                                                                      **kwargs)
        context['dashboard'] = UserDashboard()
        return context<commit_msg>admin_custom: Protect the custom dashboard views from non-staff members<commit_after>from django.views.generic.base import TemplateView
from django.contrib.admin.views.decorators import staff_member_required

from base.util import class_view_decorator

from .dashboard import (IndexDashboard,
    ProblemsDashboard, ContentDashboard,
    CompetitionDashboard, UserDashboard
    )


@class_view_decorator(staff_member_required)
class DashboardIndexView(TemplateView):
    template_name = "admin_custom/index.html"

    def get_context_data(self, *args, **kwargs):
        context = super(DashboardIndexView, self).get_context_data(*args,
                                                                   **kwargs)
        context['dashboard'] = IndexDashboard()
        return context


@class_view_decorator(staff_member_required)
class DashboardProblemsView(TemplateView):
    template_name = "admin_custom/index.html"

    def get_context_data(self, *args, **kwargs):
        context = super(DashboardProblemsView, self).get_context_data(*args,
                                                                      **kwargs)
        context['dashboard'] = ProblemsDashboard()
        return context


@class_view_decorator(staff_member_required)
class DashboardContentView(TemplateView):
    template_name = "admin_custom/index.html"

    def get_context_data(self, *args, **kwargs):
        context = super(DashboardContentView, self).get_context_data(*args,
                                                                      **kwargs)
        context['dashboard'] = ContentDashboard()
        return context


@class_view_decorator(staff_member_required)
class DashboardCompetitionView(TemplateView):
    template_name = "admin_custom/index.html"

    def get_context_data(self, *args, **kwargs):
        context = super(DashboardCompetitionView, self).get_context_data(*args,
                                                                      **kwargs)
        context['dashboard'] = CompetitionDashboard()
        return context


@class_view_decorator(staff_member_required)
class DashboardUsersView(TemplateView):
    template_name = "admin_custom/index.html"

    def get_context_data(self, *args, **kwargs):
        context = super(DashboardUsersView, self).get_context_data(*args,
                                                                      **kwargs)
        context['dashboard'] = UserDashboard()
        return context
{'fraction_non_alphanumeric': 0.08627974205025572, 'fraction_numerical': 0.0, 'mean_word_length': 2.3293856402664694, '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': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '472508', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1107, 'n_words': 204}