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