incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject git commit: [#5980] Added / fixed support for bool and int ConfigOptions
Date Fri, 22 Mar 2013 15:11:15 GMT
Updated Branches:
  refs/heads/master 0de02f8d6 -> edf791a52


[#5980] Added / fixed support for bool and int ConfigOptions

Signed-off-by: Cory Johns <johnsca@geek.net>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/edf791a5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/edf791a5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/edf791a5

Branch: refs/heads/master
Commit: edf791a5297b261a6e21c5be3ffeaae3fabbf384
Parents: 0de02f8
Author: Cory Johns <johnsca@geek.net>
Authored: Tue Mar 19 20:23:20 2013 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Fri Mar 22 15:10:37 2013 +0000

----------------------------------------------------------------------
 Allura/allura/app.py                           |   18 +++++++++++++-----
 Allura/allura/templates/app_admin_options.html |   10 +++++++---
 2 files changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/edf791a5/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index d691bf2..9965aa2 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -5,6 +5,7 @@ from cStringIO import StringIO
 from tg import expose, redirect, flash
 from tg.decorators import without_trailing_slash
 from pylons import request, app_globals as g, tmpl_context as c
+from paste.deploy.converters import asbool
 from bson import ObjectId
 
 from ming.orm import session, state
@@ -21,9 +22,9 @@ log = logging.getLogger(__name__)
 
 class ConfigOption(object):
 
-    def __init__(self, name, ming_type, default):
-        self.name, self.ming_type, self._default = (
-            name, ming_type, default)
+    def __init__(self, name, ming_type, default, label=None):
+        self.name, self.ming_type, self._default, self.label = (
+            name, ming_type, default, label or name)
 
     @property
     def default(self):
@@ -383,8 +384,15 @@ class DefaultAdminController(BaseController):
                     redirect('.')
                 c.project.uninstall_app(self.app.config.options.mount_point)
                 redirect('..')
-            for k,v in kw.iteritems():
-                self.app.config.options[k] = v
+            for opt in self.app.config_options:
+                if opt in Application.config_options:
+                    continue  # skip base options (mount_point, mount_label, ordinal)
+                val = kw.get(opt.name, '')
+                if opt.ming_type == bool:
+                    val = asbool(val or False)
+                elif opt.ming_type == int:
+                    val = asint(val or 0)
+                self.app.config.options[opt.name] = val
             if is_admin:
                 # possibly moving admin mount point
                 redirect('/'

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/edf791a5/Allura/allura/templates/app_admin_options.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/app_admin_options.html b/Allura/allura/templates/app_admin_options.html
index 53e10ba..67b954a 100644
--- a/Allura/allura/templates/app_admin_options.html
+++ b/Allura/allura/templates/app_admin_options.html
@@ -1,13 +1,17 @@
 <!DOCTYPE html>
 <form method="post" action="{{c.project.url()}}admin/{{app.config.options.mount_point}}/configure">
   {% for o in app.config_options if o.name not in ['mount_point', 'mount_label', 'ordinal']
%}
-    <label for="{{o.name}}" class="grid-4">{{o.name}}</label>
+    <label for="{{o.name}}" class="grid-4">{{o.label}}</label>
     <div class="grid-9">
       {% if not allow_config %}
            {{app.config.options.get(o.name, o.default)}}
       {% else%}
-        <input id="{{o.name}}" name="{{o.name}}" value="{{app.config.options.get(o.name,
o.default)}}">
-      {% endif %}  
+        {% if o.ming_type.__name__ == 'bool' %}
+            <input id="{{o.name}}" name="{{o.name}}" type="checkbox"{{ ' checked="checked"'
if app.config.options.get(o.name, o.default)}}>
+        {% else %}
+            <input id="{{o.name}}" name="{{o.name}}" value="{{app.config.options.get(o.name,
o.default)}}">
+        {% endif %}
+      {% endif %}
     </div>
   {% else %}
     <p>No options to administer for {{app.config.options.mount_point}}.</p>


Mime
View raw message