From fa0cdb7727cf7d504ce96bcd10f8cf3756b61dee Mon Sep 17 00:00:00 2001
From: RogerHaase <haaserd@gmail.com>
Date: Sun, 26 Jan 2025 11:32:02 -0700
Subject: [PATCH] do not show USERPROFILES ns within a list of selectable
 namespaces #60

previously USERPROFILES ns was shown as grayed and not selectable
---
 .../apps/admin/templates/user/index_user.html |  8 ++-----
 src/moin/templates/index.html                 | 10 +++------
 src/moin/themes/__init__.py                   | 21 ++++++++++---------
 3 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/src/moin/apps/admin/templates/user/index_user.html b/src/moin/apps/admin/templates/user/index_user.html
index 7b36c1780..a7a016e4a 100644
--- a/src/moin/apps/admin/templates/user/index_user.html
+++ b/src/moin/apps/admin/templates/user/index_user.html
@@ -25,13 +25,9 @@ <h2>{{ _("Reports") }}</h2>
     <h2>{{ _("Namespaces") }}</h2>
     <ul class="moin-namespaces">
         <li><a href="{{ url_for('frontend.global_views') }}">{{ _("all") }}</a></li>
-        {% for namespace, root in theme_supp.get_namespaces()|sort -%}
+        {% for namespace, root in theme_supp.get_namespaces() -%}
             <li>
-                {% if namespace == NAMESPACE_USERPROFILES %}
-                    {{ namespace }}
-                {% else %}
-                    <a href="{{ url_for('frontend.show_item', item_name=root) }}">{{ namespace }}</a>
-                {% endif %}
+                <a href="{{ url_for('frontend.show_item', item_name=root) }}">{{ namespace }}</a>
             </li>
         {%- endfor %}
     </ul>
diff --git a/src/moin/templates/index.html b/src/moin/templates/index.html
index 7dd42bf80..723847b40 100644
--- a/src/moin/templates/index.html
+++ b/src/moin/templates/index.html
@@ -160,15 +160,11 @@ <h1>{{ title }}</h1>
         <p> {{ _("Click home icon to view namespace home page or click name to view namespace index.") }} </p>
         <ul class="moin-namespaces">
             <li><i class="fa fa-home"></i> <a href="{{ url_for('frontend.index', item_name='all') }}">{{ _("all") }}</a></li>
-            {% for namespace, root in theme_supp.get_namespaces()|sort -%}
+            {% for namespace, root in theme_supp.get_namespaces() -%}
                 {% set index = '%s/%s' % ('+index', root.namespace) %}
                 <li>
-                    {% if namespace == NAMESPACE_USERPROFILES %}
-                        <i class="fa fa-home"></i> {{ namespace }}
-                    {% else %}
-                        <a href="{{ url_for('frontend.show_item', item_name=root) }}"><i class="fa fa-home"></i></a>
-                        <a href="{{ url_for('frontend.show_item', item_name=index) }}">{{ namespace }}</a>
-                    {% endif %}
+                    <a href="{{ url_for('frontend.show_item', item_name=root) }}"><i class="fa fa-home"></i></a>
+                    <a href="{{ url_for('frontend.show_item', item_name=index) }}">{{ namespace }}</a>
                 </li>
             {%- endfor %}
         </ul>
diff --git a/src/moin/themes/__init__.py b/src/moin/themes/__init__.py
index 3bbaf1e90..845151769 100644
--- a/src/moin/themes/__init__.py
+++ b/src/moin/themes/__init__.py
@@ -27,7 +27,7 @@
 from moin.constants.keys import USERID, ADDRESS, HOSTNAME, REVID, ITEMID, NAME_EXACT, ASSIGNED_TO, NAME, NAMESPACE
 from moin.constants.contenttypes import CONTENTTYPES_MAP, CONTENTTYPE_MARKUP, CONTENTTYPE_TEXT, CONTENTTYPE_MOIN_19
 from moin.constants.misc import VALID_ITEMLINK_VIEWS, FLASH_REPEAT
-from moin.constants.namespaces import NAMESPACE_DEFAULT, NAMESPACE_USERS, NAMESPACE_ALL
+from moin.constants.namespaces import NAMESPACE_DEFAULT, NAMESPACE_USERS, NAMESPACE_USERPROFILES, NAMESPACE_ALL
 from moin.constants.rights import SUPERUSER
 from moin.search import SearchForm
 from moin.utils.interwiki import (
@@ -524,20 +524,21 @@ def login_url(self):
             url = url or url_for("frontend.login")
         return url
 
-    def get_namespaces(self, ns=None):
+    def get_namespaces(self):
         """
-        Return the list of tuples (composite name, namespace) referring to namespaces other
-        than the current namespace.
+        Return a sorted list of tuples (namespace name, fq name of ns home item).
+
+        The special userprofiles NS is omitted because it can never be selected
+        by a wiki user.
         """
-        if ns is not None and ns.value == "~":
-            ns = ""
         namespace_root_mapping = []
         for namespace, _unused in app.cfg.namespace_mapping:
+            if namespace == NAMESPACE_USERPROFILES:
+                continue
             namespace = namespace.rstrip("/")
-            if ns is None or namespace != ns:
-                fq_namespace = CompositeName(namespace, NAME_EXACT, "")
-                namespace_root_mapping.append((namespace or "~", fq_namespace.get_root_fqname()))
-        return namespace_root_mapping
+            fq_namespace = CompositeName(namespace, NAME_EXACT, "")
+            namespace_root_mapping.append((namespace or "~", fq_namespace.get_root_fqname()))
+        return sorted(namespace_root_mapping)
 
     def item_exists(self, itemname):
         """