diff MoinMoin/apps/admin/views.py @ 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 2e0766600e8f
line wrap: on
line diff
--- 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)
+