Skip to content

Commit

Permalink
do not show USERPROFILES ns within a list of selectable namespaces #60
Browse files Browse the repository at this point in the history
previously USERPROFILES ns was shown as grayed and not selectable
  • Loading branch information
RogerHaase committed Jan 26, 2025
1 parent 769c38d commit fa0cdb7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
8 changes: 2 additions & 6 deletions src/moin/apps/admin/templates/user/index_user.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
10 changes: 3 additions & 7 deletions src/moin/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
21 changes: 11 additions & 10 deletions src/moin/themes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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):
"""
Expand Down

0 comments on commit fa0cdb7

Please sign in to comment.