From ddca46e24aaa05625bd0005904e2087e466be368 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 19 Sep 2020 00:25:28 +0200 Subject: [PATCH] outposts: add modal to show setup information --- .../administration/outpost/list.html | 6 ++- passbook/outposts/models.py | 9 ++++ .../templates/outposts/deployment_modal.html | 43 +++++++++++++++++++ passbook/providers/saml/models.py | 2 +- 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 passbook/outposts/templates/outposts/deployment_modal.html diff --git a/passbook/admin/templates/administration/outpost/list.html b/passbook/admin/templates/administration/outpost/list.html index f8a0dc27d..2821164d4 100644 --- a/passbook/admin/templates/administration/outpost/list.html +++ b/passbook/admin/templates/administration/outpost/list.html @@ -3,6 +3,7 @@ {% load i18n %} {% load humanize %} {% load passbook_utils %} +{% load admin_reflection %} {% block head %} {{ block.super }} @@ -69,7 +70,10 @@ {% trans 'Edit' %} {% trans 'Delete' %} - {% trans 'Deploy' %} + {% get_htmls outpost as htmls %} + {% for html in htmls %} + {{ html|safe }} + {% endfor %} {% endfor %} diff --git a/passbook/outposts/models.py b/passbook/outposts/models.py index 9ebd90bc9..147ed432c 100644 --- a/passbook/outposts/models.py +++ b/passbook/outposts/models.py @@ -9,12 +9,14 @@ from django.contrib.postgres.fields import ArrayField from django.core.cache import cache from django.db import models, transaction from django.db.models.base import Model +from django.http import HttpRequest from django.utils.translation import gettext_lazy as _ from guardian.models import UserObjectPermission from guardian.shortcuts import assign_perm from passbook.core.models import Provider, Token, TokenIntents, User from passbook.lib.config import CONFIG +from passbook.lib.utils.template import render_to_string @dataclass @@ -149,5 +151,12 @@ class Outpost(models.Model): objects.append(provider) return objects + def html_deployment_view(self, request: HttpRequest) -> Optional[str]: + """return template and context modal to view token and other config info""" + return render_to_string( + "outposts/deployment_modal.html", + {"outpost": self, "full_url": request.build_absolute_uri("/")}, + ) + def __str__(self) -> str: return f"Outpost {self.name}" diff --git a/passbook/outposts/templates/outposts/deployment_modal.html b/passbook/outposts/templates/outposts/deployment_modal.html new file mode 100644 index 000000000..831068233 --- /dev/null +++ b/passbook/outposts/templates/outposts/deployment_modal.html @@ -0,0 +1,43 @@ +{% load i18n %} +{% load static %} + + + diff --git a/passbook/providers/saml/models.py b/passbook/providers/saml/models.py index c9460cbab..ce680c370 100644 --- a/passbook/providers/saml/models.py +++ b/passbook/providers/saml/models.py @@ -129,7 +129,7 @@ class SAMLProvider(Provider): return None def html_metadata_view(self, request: HttpRequest) -> Optional[str]: - """return template and context modal with to view Metadata without downloading it""" + """return template and context modal to view Metadata without downloading it""" from passbook.providers.saml.views import DescriptorDownloadView try: