changeset 55:32b88d45d63c

WikiConfigHelp: remove macro, create admin view
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 02 Mar 2011 00:19:10 +0100
parents 2d6a32f75c2d
children a8d244c73d48
files MoinMoin/apps/admin/templates/index.html MoinMoin/apps/admin/templates/wikiconfighelp.html MoinMoin/apps/admin/views.py
diffstat 3 files changed, 61 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/admin/templates/index.html	Tue Mar 01 23:19:20 2011 +0100
+++ b/MoinMoin/apps/admin/templates/index.html	Wed Mar 02 00:19:10 2011 +0100
@@ -5,6 +5,7 @@
     <li><a href="{{ url_for('admin.userbrowser') }}">{{ _("User Browser") }}</a></li>
     <li><a href="{{ url_for('admin.sysitems_upgrade') }}">{{ _("Upgrade system items") }}</a></li>
     <li><a href="{{ url_for('admin.wikiconfig') }}">{{ _("Show Wiki Configuration") }}</a></li>
+    <li><a href="{{ url_for('admin.wikiconfighelp') }}">{{ _("Show Wiki Configuration Help") }}</a></li>
 </ul>
 {% endblock %}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/apps/admin/templates/wikiconfighelp.html	Wed Mar 02 00:19:10 2011 +0100
@@ -0,0 +1,29 @@
+{% extends theme("layout.html") %}
+{% block content %}
+<h1>{{ _("WikiConfig Help") }}</h1>
+{% for heading, desc, opts in groups %}
+    <h2>{{ heading }}</h2>
+    {% if desc %}
+        <p>{{ desc }}</p>
+    {% endif %}
+    <table>
+    <thead>
+    <tr>
+        <td><strong>{{ _('Variable name') }}</strong></td>
+        <td><strong>{{ _('Default') }}</strong></td>
+        <td><strong>{{ _('Description') }}</strong></td>
+    </tr>
+    </thead>
+    <tbody>
+    {% for name, default, description in opts %}
+        <tr>
+            <td>{{ name }}</td>
+            <td><code>{{ default }}</code></td>
+            <td>{{ description }}</td>
+        </tr>
+    {% endfor %}
+    </tbody>
+    </table>
+{% endfor %}
+{% endblock %}
+
--- a/MoinMoin/apps/admin/views.py	Tue Mar 01 23:19:20 2011 +0100
+++ b/MoinMoin/apps/admin/views.py	Wed Mar 02 00:19:10 2011 +0100
@@ -159,3 +159,34 @@
                            item_name="+admin/wikiconfig",
                            found=found, settings=settings)
 
+
+@admin.route('/wikiconfighelp', methods=['GET', ])
+def wikiconfighelp():
+    if not flaskg.user or not flaskg.user.isSuperUser():
+        return ''
+
+    def format_default(default):
+        if isinstance(default, defaultconfig.DefaultExpression):
+            default_txt = default.text
+        else:
+            default_txt = '%r' % (default, )
+            if len(default_txt) > 30:
+                default_txt = '...'
+        return default_txt
+
+    groups = []
+    for groupname in defaultconfig.options:
+        heading, desc, opts = defaultconfig.options[groupname]
+        opts = sorted([(groupname + '_' + name, format_default(default), description)
+                       for name, default, description in opts])
+        groups.append((heading, desc, opts))
+    for groupname in defaultconfig.options_no_group_name:
+        heading, desc, opts = defaultconfig.options_no_group_name[groupname]
+        opts = sorted([(name, format_default(default), description)
+                       for name, default, description in opts])
+        groups.append((heading, desc, opts))
+    groups.sort()
+    return render_template('admin/wikiconfighelp.html',
+                           item_name="+admin/wikiconfighelp",
+                           groups=groups)
+