diff --git a/aleksis/core/util/core_helpers.py b/aleksis/core/util/core_helpers.py index f273016659cf08bf7d4e924296d2950dc9e20694..55c329bf383357625fe6e650ff604c8430141b04 100644 --- a/aleksis/core/util/core_helpers.py +++ b/aleksis/core/util/core_helpers.py @@ -1,7 +1,7 @@ import os import pkgutil from importlib import import_module -from typing import Any, Callable, Sequence, Union +from typing import Any, Callable, Sequence, Union, List from uuid import uuid4 from django.conf import settings @@ -148,3 +148,23 @@ def school_information_processor(request: HttpRequest) -> dict: return { "SCHOOL": School.get_default, } + + +def get_app_licence_information() -> List[dict]: + """ Get a list of the attribute LICENCE_INFORMATION from every app and the core """ + + licence_information = [] + + packages = list(get_app_packages()) + packages.insert(0, "aleksis.core") + + for app in packages: + app_mod = import_module(app) + try: + app_licence_information = app_mod.LICENCE_INFORMATION + app_licence_information["copyright_holders"].sort(key=lambda x: x[1].split(" ")[-1]) + licence_information.append(app_licence_information) + except AttributeError: + pass + + return licence_information diff --git a/aleksis/core/views.py b/aleksis/core/views.py index 931475d2af68ad099bba70b5182f83780cebe4f7..6391a23638aa76aaf18d29348313f95753b6c727 100644 --- a/aleksis/core/views.py +++ b/aleksis/core/views.py @@ -20,7 +20,7 @@ from .forms import ( from .models import Activity, Group, Notification, Person, School, DashboardWidget from .tables import GroupsTable, PersonsTable from .util import messages -from .util.core_helpers import get_app_packages +from .util.core_helpers import get_app_licence_information @person_required @@ -47,21 +47,7 @@ def offline(request): def about(request): context = {} - licence_information = [] - - packages = list(get_app_packages()) - packages.insert(0, "aleksis.core") - - for app in packages: - app_mod = import_module(app) - try: - app_licence_information = app_mod.LICENCE_INFORMATION - app_licence_information["copyright_holders"].sort(key=lambda x: x[1].split(" ")[-1]) - licence_information.append(app_licence_information) - except AttributeError: - pass - - context["licence_information"] = licence_information + context["licence_information"] = get_app_licence_information() return render(request, "core/about.html", context)