From 3d9a001af324633dd5be621f03767c629dfcdd55 Mon Sep 17 00:00:00 2001 From: Shadi Naif Date: Fri, 8 Mar 2024 11:52:22 +0300 Subject: [PATCH] feat: learners-count statistics --- .../dashboard/statistics/__init__.py | 0 .../dashboard/statistics/learners.py | 1 + futurex_openedx_extensions/helpers/apps.py | 9 +++++++++ futurex_openedx_extensions/helpers/tenant.py | 14 ++++++++++++++ setup.py | 2 ++ 5 files changed, 26 insertions(+) create mode 100644 futurex_openedx_extensions/dashboard/statistics/__init__.py create mode 100644 futurex_openedx_extensions/dashboard/statistics/learners.py create mode 100644 futurex_openedx_extensions/helpers/apps.py create mode 100644 futurex_openedx_extensions/helpers/tenant.py diff --git a/futurex_openedx_extensions/dashboard/statistics/__init__.py b/futurex_openedx_extensions/dashboard/statistics/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/futurex_openedx_extensions/dashboard/statistics/learners.py b/futurex_openedx_extensions/dashboard/statistics/learners.py new file mode 100644 index 00000000..b795e484 --- /dev/null +++ b/futurex_openedx_extensions/dashboard/statistics/learners.py @@ -0,0 +1 @@ +"""functions for getting statistics about learners""" diff --git a/futurex_openedx_extensions/helpers/apps.py b/futurex_openedx_extensions/helpers/apps.py new file mode 100644 index 00000000..cea81a09 --- /dev/null +++ b/futurex_openedx_extensions/helpers/apps.py @@ -0,0 +1,9 @@ +"""helpers Django application initialization""" + +from django.apps import AppConfig + + +class HelpersConfig(AppConfig): + """Configuration for the helpers Django application""" + + name = 'helpers' diff --git a/futurex_openedx_extensions/helpers/tenant.py b/futurex_openedx_extensions/helpers/tenant.py new file mode 100644 index 00000000..7596debe --- /dev/null +++ b/futurex_openedx_extensions/helpers/tenant.py @@ -0,0 +1,14 @@ +"""Tenant management helpers""" + + +def get_accessible_tenants(user): + """ + Get the tenants that the user has access to. + + Args: + user (User): The user to check. + + Returns: + list of Tenant: The tenants that the user has access to. + """ + return Tenant.objects.filter(users=user) diff --git a/setup.py b/setup.py index 25bb3c47..7beaf092 100755 --- a/setup.py +++ b/setup.py @@ -138,6 +138,7 @@ def is_requirement(line): include=[ 'futurex_openedx_extensions', 'futurex_openedx_extensions.*', 'futurex_openedx_extensions.dashboard', 'futurex_openedx_extensions.dashboard.*', + 'futurex_openedx_extensions.helpers', 'futurex_openedx_extensions.helpers.*', ], exclude=["*tests"], ), @@ -160,6 +161,7 @@ def is_requirement(line): entry_points={ 'lms.djangoapp': [ 'dashboard = futurex_openedx_extensions.dashboard.apps:DashboardConfig', + 'helpers = futurex_openedx_extensions.helpers.apps:HelpersConfig', ], }, )