allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject git commit: [#6833] make socialnetworks configurable
Date Mon, 04 Nov 2013 20:18:59 GMT
Updated Branches:
  refs/heads/master e04f78d1f -> 6e780416c


[#6833] make socialnetworks configurable


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

Branch: refs/heads/master
Commit: 6e780416c2823056c15cabc98cdeb67582f03268
Parents: e04f78d
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Fri Nov 1 21:48:31 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Mon Nov 4 20:18:26 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/widgets/forms.py | 49 +++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6e780416/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 9d3f602..554750a 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -17,27 +17,28 @@
 
 import logging
 import warnings
+
 from pylons import app_globals as g
+from formencode import validators as fev
+import formencode
+import ew as ew_core
+import ew.jinja2_ew as ew
+from pytz import common_timezones, country_timezones, country_names
+from paste.deploy.converters import aslist
+import tg
+
 from allura.lib import validators as V
 from allura.lib import helpers as h
 from allura.lib import plugin
 from allura.lib.widgets import form_fields as ffw
 from allura.lib import exceptions as forge_exc
+from allura.lib.utils import LazyProperty
 from allura import model as M
-from datetime import datetime
 
-from formencode import validators as fev
-import formencode
-
-import ew as ew_core
-import ew.jinja2_ew as ew
-
-from pytz import common_timezones, country_timezones, country_names
 
 log = logging.getLogger(__name__)
 
-socialnetworks=['Facebook','Linkedin','Twitter','Google+']
-weekdays=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
+weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
 
 class _HTMLExplanation(ew.InputField):
     template=ew.Snippet(
@@ -323,17 +324,23 @@ class RemoveTextValueForm(ForgeForm):
 class AddSocialNetworkForm(ForgeForm):
     defaults=dict(ForgeForm.defaults)
 
-    class fields(ew_core.NameList):
-        socialnetwork = ew.SingleSelectField(
-            label='Social network',
-            options=[ew.Option(py_value=name, label=name)
-                     for name in socialnetworks],
-            validator=formencode.All(
-                V.OneOfValidator(socialnetworks),
-                fev.UnicodeString(not_empty=True)))
-        accounturl = ew.TextField(
-            label='Account url',
-            validator=fev.UnicodeString(not_empty=True))
+    @property
+    def fields(self):
+        socialnetworks = aslist(tg.config.get('socialnetworks',
+                                              ['Facebook', 'Linkedin', 'Twitter', 'Google+']),
+                                ',')
+        return [
+            ew.SingleSelectField(
+                name='socialnetwork',
+                label='Social network',
+                options=[ew.Option(py_value=name, label=name)
+                         for name in socialnetworks]),
+            ew.TextField(
+                name='accounturl',
+                label='Account url',
+                validator=fev.UnicodeString(not_empty=True))
+        ]
+
 
 class RemoveSocialNetworkForm(ForgeForm):
     defaults=dict(ForgeForm.defaults, submit_text=None, show_errors=False)


Mime
View raw message