incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [7/48] git commit: [#5145] Refactor to avoid need to double-set add project form tools options
Date Tue, 30 Oct 2012 17:30:05 GMT
[#5145] Refactor to avoid need to double-set add project form tools options

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

Branch: refs/heads/cj/5005
Commit: 882aa4aa3356e7ce330bdda945b8164bb9ad2070
Parents: c19bc21
Author: Cory Johns <johnsca@geek.net>
Authored: Wed Oct 24 18:39:33 2012 +0000
Committer: Cory Johns <johnsca@geek.net>
Committed: Fri Oct 26 20:32:11 2012 +0000

----------------------------------------------------------------------
 Allura/allura/lib/plugin.py        |   13 -------------
 Allura/allura/lib/widgets/forms.py |   10 ++++++++++
 2 files changed, 10 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/882aa4aa/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 02d652a..b8f565c 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -311,19 +311,6 @@ class ProjectRegistrationProvider(object):
     def __init__(self):
         from allura.lib.widgets import forms
         self.add_project_widget = forms.NeighborhoodAddProjectForm
-        ## Dynamically generating CheckboxSet of installable tools
-        self.add_project_widget.fields.tools = forms.ew.CheckboxSet(
-            name="tools", options=[
-                forms.ew.Option(label=tool.tool_label, html_value=ep)
-                for ep,tool in g.entry_points["tool"].iteritems()
-                if tool.installable and tool.status == 'production'
-            ], selected=True
-        )
-        # have to update it via index as well because of crazy
-        # implementation of EasyWidget's NamedList "helper";
-        # otherwise, validation doesn't see the new options
-        tfi = utils.index_matching(lambda x: x.name == 'tools', self.add_project_widget.fields)
-        self.add_project_widget.fields[tfi] = self.add_project_widget.fields.tools
 
     @classmethod
     def get(cls):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/882aa4aa/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index b000ea8..35281d1 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -273,6 +273,16 @@ class NeighborhoodAddProjectForm(ForgeForm):
             ew.Option(label='Wiki', html_value='wiki', selected=True)
         ])
 
+    def __init__(self, *args, **kwargs):
+        super(NeighborhoodAddProjectForm, self).__init__(*args, **kwargs)
+        ## Dynamically generating CheckboxSet of installable tools
+        from allura.lib.widgets import forms
+        self.fields.tools.options = [
+                forms.ew.Option(label=tool.tool_label, html_value=ep)
+                    for ep,tool in g.entry_points["tool"].iteritems()
+                    if tool.installable and tool.status == 'production'
+            ]
+
     def resources(self):
         for r in super(NeighborhoodAddProjectForm, self).resources(): yield r
         yield ew.CSSLink('css/add_project.css')


Mime
View raw message