allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject git commit: [#6833] make socialnetworks configurable
Date Fri, 01 Nov 2013 21:48:37 GMT
Updated Branches:
  refs/heads/db/6833 [created] e128ccffc


[#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/e128ccff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/e128ccff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/e128ccff

Branch: refs/heads/db/6833
Commit: e128ccffca9f9af3c175e3c2f52be20cbee1c72b
Parents: 2ccaae5
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Fri Nov 1 21:48:31 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Nov 1 21:48:31 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/e128ccff/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