Skip to content
Snippets Groups Projects
Verified Commit d3578f67 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Define API for app metadata, copyright and license information

parent a8b649b3
No related branches found
No related tags found
1 merge request!146Resolve "Add licence information page"
Pipeline #1497 failed
......@@ -14,18 +14,3 @@ except Exception:
__version__ = "unknown"
default_app_config = "aleksis.core.apps.CoreConfig"
LICENCE_INFORMATION = {
"name": _("Core"),
"repository": "https://edugit.org/AlekSIS/AlekSIS/",
"licence": _("EUPL, version 1.2 or later"),
"copyright_holders": [
([2017, 2018, 2019, 2020], "Jonathan Weth", "wethjo@katharineum.de"),
([2017, 2018, 2019], "Frank Poetzsch-Heffter", "p-h@katharineum.de"),
([2018, 2019, 2020], "Hangzhi Yu", "yuha@katharineum.de"),
([2018, 2019, 2020], "Julian Leucker", "leuckeju@katharineum.de"),
([2019, 2020], "Dominik George", "dominik.george@teckids.org"),
([2019, 2020], "mirabilos", "thorsten.glaser@teckids.org"),
([2019, 2020], "Tom Teichler", "tom.teichler@teckids.org"),
]
}
......@@ -13,6 +13,20 @@ class CoreConfig(AppConfig):
name = "aleksis.core"
verbose_name = "AlekSIS — The Free School Information System"
urls = {
"Repository": "https://edugit.org/AlekSIS/official/AlekSIS/",
}
licence = "EUPL-1.2+"
copyright = (
([2017, 2018, 2019, 2020], "Jonathan Weth", "wethjo@katharineum.de"),
([2017, 2018, 2019], "Frank Poetzsch-Heffter", "p-h@katharineum.de"),
([2018, 2019, 2020], "Hangzhi Yu", "yuha@katharineum.de"),
([2018, 2019, 2020], "Julian Leucker", "leuckeju@katharineum.de"),
([2019, 2020], "Dominik George", "dominik.george@teckids.org"),
([2019, 2020], "mirabilos", "thorsten.glaser@teckids.org"),
([2019, 2020], "Tom Teichler", "tom.teichler@teckids.org"),
)
def config_updated(self, *args, **kwargs) -> None:
clean_scss()
......
......@@ -7,6 +7,8 @@ from django.db.models.signals import post_migrate, pre_migrate
from django.http import HttpRequest
from constance.signals import config_updated
from license_expression import Licensing, LicenseSymbol
from spdx_license_list import LICENSES
class AppConfig(django.apps.AppConfig):
......@@ -41,6 +43,50 @@ class AppConfig(django.apps.AppConfig):
# ImportErrors are non-fatal because checks are optional.
pass
def get_name(self):
return getattr(self, "verbose_name", self.name)
# TODO Try getting from distribution if not set
def get_version(self):
try:
from .. import __version__ # noqa
except ImportError:
__version__ = None
return getattr(self, "version", __version__)
def get_licence(self) -> Tuple:
licence = getattr(self, "licence", None)
default_dict = {
'isDeprecatedLicenseId': False,
'isFsfLibre': False,
'isOsiApproved': False,
'licenseId': 'unknown',
'name': 'Unknown Licence',
'referenceNumber': -1,
'url': '',
}
if licence:
licensing = Licensing(LICENSES.keys())
parsed = licensing.parse(licence).simplify()
readable = parsed.render_as_readable()
licence_dicts = [LICENSES.get(symbol.key, default_dict) for symbol in parsed.symbols]
return (readable, licence_dicts)
else:
return ("Unknown", [default_dict])
def get_urls(self):
return getattr(self, "urls", {})
# TODO Try getting from distribution if not set
def get_copyright(self):
return getattr(self, "copyright", tuple())
# TODO Try getting from distribution if not set
def config_updated(
self,
key: Optional[str] = "",
......
......@@ -71,6 +71,8 @@ django-memoize = "^2.2.1"
django-haystack = "^3.0"
celery-haystack = {version="^0.3.1", optional=true}
django-dbbackup = "^3.3.0"
spdx-license-list = "^0.4.0"
license-expression = "^1.2"
[tool.poetry.extras]
ldap = ["django-auth-ldap"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment