Skip to content
Snippets Groups Projects
Verified Commit 1fd13f93 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Add OAuth2 scopes to app config

(cherry picked from commit 1d3401aa)
parent f4d9a990
No related branches found
No related tags found
1 merge request!25Prepare release 2.0b1
from django.apps import apps
from django.utils.translation import gettext as _
from aleksis.core.util.apps import AppConfig
......@@ -14,3 +17,14 @@ class ResintConfig(AppConfig):
([2020, 2021], "Frank Poetzsch-Heffter", "p-h@katharineum.de"),
([2019], "Julian Leucker", "leuckeju@katharineum.de"),
)
@classmethod
def get_all_scopes(cls) -> dict[str, str]:
"""Return all OAuth scopes and their descriptions for this app."""
LiveDocument = apps.get_model("resint", "LiveDocument")
scopes = {}
for live_document in LiveDocument.objects.all():
scopes[live_document.scope] = _("Access PDF file for live document {}").format(
live_document.name
)
return scopes
......@@ -193,6 +193,11 @@ class LiveDocument(ExtensiblePolymorphicModel):
"""Get the filename without path of the PDF file."""
return f"{self.slug}.pdf"
@property
def scope(self) -> str:
"""Return OAuth2 scope name to access PDF file via API."""
return f"live_document_pdf_{self.slug}"
def save(self, *args, **kwargs):
with reversion.create_revision():
super().save(*args, **kwargs)
......
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