From 6593c34bfafc05325d4ab1b7e4b948efea38f372 Mon Sep 17 00:00:00 2001 From: Dominik George <dominik.george@teckids.org> Date: Tue, 28 Sep 2021 17:15:29 +0200 Subject: [PATCH] Turn get_*_scopes methods into classmethods --- aleksis/core/apps.py | 3 ++- aleksis/core/util/apps.py | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/aleksis/core/apps.py b/aleksis/core/apps.py index d9a3f38fa..c14af908f 100644 --- a/aleksis/core/apps.py +++ b/aleksis/core/apps.py @@ -138,7 +138,8 @@ class CoreConfig(AppConfig): # Save the associated person to pick up defaults user.person.save() - def get_all_scopes(self) -> dict[str, str]: + @classmethod + def get_all_scopes(cls) -> dict[str, str]: scopes = { "read": "Read anything the resource owner can read", "write": "Write anything the resource owner can write", diff --git a/aleksis/core/util/apps.py b/aleksis/core/util/apps.py index 5c31ae54a..8157f1dcf 100644 --- a/aleksis/core/util/apps.py +++ b/aleksis/core/util/apps.py @@ -217,22 +217,25 @@ class AppConfig(django.apps.AppConfig): """ pass - def get_all_scopes(self) -> dict[str, str]: + @classmethod + def get_all_scopes(cls) -> dict[str, str]: """Return all OAuth scopes and their descriptions for this app.""" return {} + @classmethod def get_available_scopes( - self, + cls, application: Optional["AbstractApplication"] = None, request: Optional[HttpRequest] = None, *args, **kwargs, ) -> list[str]: """Return a list of all OAuth scopes available to the request and application.""" - return list(self.get_all_scopes().keys()) + return list(cls.get_all_scopes().keys()) + @classmethod def get_default_scopes( - self, + cls, application: Optional["AbstractApplication"] = None, request: Optional[HttpRequest] = None, *args, -- GitLab