From f256217d1bded4b85df10dbfecbd42d7cc946e44 Mon Sep 17 00:00:00 2001 From: Karthik Balakrishnan Date: Mon, 8 May 2023 10:36:10 +0530 Subject: [PATCH] Show domain setup to admins (#568) Prompts admin users to setup domains on the identity creation --- templates/identity/create.html | 53 ++++++++++++++++++++++------------ users/views/identity.py | 7 +++++ 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/templates/identity/create.html b/templates/identity/create.html index 9d8dd55..8d353d2 100644 --- a/templates/identity/create.html +++ b/templates/identity/create.html @@ -3,23 +3,38 @@ {% block title %}Create Identity{% endblock %} {% block content %} -
-

Create New Identity

-

- You can have multiple identities - they are totally separate, and share - nothing apart from your login details. They can also be shared among multiple - users, so you can use them for company or project accounts. -

- {% csrf_token %} -
- Identity Details - {% include "forms/_field.html" with field=form.username %} - {% include "forms/_field.html" with field=form.domain %} - {% include "forms/_field.html" with field=form.name %} - {% include "forms/_field.html" with field=form.discoverable %} -
-
- -
-
+ {% if no_valid_domains %} + {% if user.admin %} +
+

There are no domains configured for this user account.

+ + View domains + +
+ {% else %} +
+

There are no domains available for this user account.

+
+ {% endif %} + {% else %} +
+

Create New Identity

+

+ You can have multiple identities - they are totally separate, and share + nothing apart from your login details. They can also be shared among multiple + users, so you can use them for company or project accounts. +

+ {% csrf_token %} +
+ Identity Details + {% include "forms/_field.html" with field=form.username %} + {% include "forms/_field.html" with field=form.domain %} + {% include "forms/_field.html" with field=form.name %} + {% include "forms/_field.html" with field=form.discoverable %} +
+
+ +
+
+ {% endif %} {% endblock %} diff --git a/users/views/identity.py b/users/views/identity.py index cd6c8bc..a23177c 100644 --- a/users/views/identity.py +++ b/users/views/identity.py @@ -370,3 +370,10 @@ class CreateIdentity(FormView): ) self.request.session["identity_id"] = identity.id return redirect(identity.urls.view) + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["user"] = self.request.user + if len(context["form"].fields["domain"].choices) == 0: + context["no_valid_domains"] = True + return context