You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.0 KiB
67 lines
2.0 KiB
from unfold.components import BaseComponent, register_component
|
|
from django.template.loader import render_to_string
|
|
|
|
from .user import *
|
|
from .professor import *
|
|
from .student import *
|
|
from .location import *
|
|
|
|
|
|
@register_component
|
|
class AllUserComponent(BaseComponent):
|
|
def get_context_data(self, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context["children"] = render_to_string(
|
|
"admin/helpers/kpi_progress.html",
|
|
{
|
|
"total": User.objects.filter(is_active=True).count(),
|
|
},
|
|
)
|
|
return context
|
|
|
|
@register_component
|
|
class GuestUserComponent(BaseComponent):
|
|
def get_context_data(self, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context["children"] = render_to_string(
|
|
"admin/helpers/kpi_progress.html",
|
|
{
|
|
"total": User.objects.filter(email__isnull=True).count(),
|
|
},
|
|
)
|
|
return context
|
|
|
|
@register_component
|
|
class ProfessorUserComponent(BaseComponent):
|
|
def get_context_data(self, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
professor_count = User.objects.filter(groups__name="Professor Group").count()
|
|
context["children"] = render_to_string(
|
|
"admin/helpers/kpi_progress.html",
|
|
{
|
|
"total": professor_count
|
|
},
|
|
)
|
|
return context
|
|
|
|
|
|
|
|
@register_component
|
|
class StudentUserComponent(BaseComponent):
|
|
def get_context_data(self, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
student_count = User.objects.filter(
|
|
models.Q(groups__name="Student Group") |
|
|
models.Q(user_type=User.UserType.STUDENT)
|
|
).distinct().count()
|
|
|
|
context["children"] = render_to_string(
|
|
"admin/helpers/kpi_progress.html",
|
|
{
|
|
"total": student_count,
|
|
},
|
|
)
|
|
return context
|