From 125c123010c36cec53f570b01b8560081fef254e Mon Sep 17 00:00:00 2001 From: sahama Date: Thu, 8 Aug 2024 00:28:01 +0330 Subject: [PATCH] allowed_scopes_queryset --- apps/gooyal_oauth2/models.py | 6 ++++-- templates/gooyal_oauth2/application_detail.html | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/gooyal_oauth2/models.py b/apps/gooyal_oauth2/models.py index deed4a4..9ccf728 100644 --- a/apps/gooyal_oauth2/models.py +++ b/apps/gooyal_oauth2/models.py @@ -54,8 +54,10 @@ class Application(AbstractApplication): app_scopes = set(self.allowed_scope.split()) return app_scopes.intersection(all_scopes) - # @property - # def available_scopes(self): + @property + def allowed_scopes_queryset(self): + allowed_scopes = self.allowed_scopes + return Scope.objects.filter(name__in=allowed_scopes).order_by('name') diff --git a/templates/gooyal_oauth2/application_detail.html b/templates/gooyal_oauth2/application_detail.html index 0835c07..1c15954 100644 --- a/templates/gooyal_oauth2/application_detail.html +++ b/templates/gooyal_oauth2/application_detail.html @@ -47,14 +47,15 @@ - {# actions#} + application - {% for scope in object.scopes.all %} + {% for scope in object.allowed_scopes_queryset %} {{ scope.name }} {{ scope.description }} + {{ scope.application }} {% endfor %}