You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2016/12/12 21:07:10 UTC

[3/3] allura git commit: Adds ability for neighborhood home to use Wiki home content

Adds ability for neighborhood home to use Wiki home content


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

Branch: refs/heads/master
Commit: 8c4a787c7f59e5bfbf202f3319732070ff2b7733
Parents: d5b26ed
Author: Kenton Taylor <kt...@slashdotmedia.com>
Authored: Wed Dec 7 19:37:00 2016 +0000
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Mon Dec 12 15:56:38 2016 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/project.py               | 17 +++++++++++++----
 Allura/allura/lib/widgets/forms.py                 |  1 +
 Allura/allura/model/neighborhood.py                |  1 +
 .../templates/neighborhood_project_list.html       |  3 +++
 .../widgets/neighborhood_overview_form.html        |  2 ++
 .../allura/tests/functional/test_neighborhood.py   |  7 ++++++-
 6 files changed, 26 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/8c4a787c/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 5f956d9..0cd083b 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -94,9 +94,12 @@ class NeighborhoodController(object):
     @expose('jinja:allura:templates/neighborhood_project_list.html')
     @with_trailing_slash
     def index(self, sort='alpha', limit=25, page=0, **kw):
-        if self.neighborhood.redirect:
+        text = None
+        if self.neighborhood.use_wiki_page_as_root:
+            text = g.markdown_wiki.convert('[[include ref=Home]]')
+        elif self.neighborhood.redirect:
             redirect(self.neighborhood.redirect)
-        if not self.neighborhood.has_home_tool:
+        elif not self.neighborhood.has_home_tool:
             mount = c.project.ordered_mounts()[0]
             if mount is not None:
                 if 'ac' in mount:
@@ -105,6 +108,10 @@ class NeighborhoodController(object):
                     redirect(mount['sub'].url())
             else:
                 redirect(c.project.app_configs[0].options.mount_point + '/')
+        else:
+            text=g.markdown.cached_convert(
+                self.neighborhood, 'homepage'),
+
         c.project_summary = W.project_summary
         c.page_list = W.page_list
         limit, page, start = g.handle_paging(limit, page)
@@ -134,8 +141,7 @@ class NeighborhoodController(object):
         ]
         return dict(neighborhood=self.neighborhood,
                     title="Welcome to " + self.neighborhood.name,
-                    text=g.markdown.cached_convert(
-                        self.neighborhood, 'homepage'),
+                    text=text,
                     projects=projects,
                     sort=sort,
                     limit=limit, page=page, count=count)
@@ -615,6 +621,9 @@ class NeighborhoodAdminController(object):
         show_title = kw.get('show_title', False)
         h.log_if_changed(nbhd, 'show_title', show_title,
                          'change neighborhood show title to %s' % show_title)
+        use_wiki_page_as_root = kw.get('use_wiki_page_as_root', False)
+        h.log_if_changed(nbhd, 'use_wiki_page_as_root', use_wiki_page_as_root,
+                         'change use wiki page as root to %s' % use_wiki_page_as_root)
         project_list_url = kw.get('project_list_url', '')
         h.log_if_changed(nbhd, 'project_list_url', project_list_url,
                          'change neighborhood project list url to %s'

http://git-wip-us.apache.org/repos/asf/allura/blob/8c4a787c/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 7bb982a..bf2da98 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -801,6 +801,7 @@ class NeighborhoodOverviewForm(ForgeForm):
         homepage = ffw.AutoResizeTextarea()
         allow_browse = ew.Checkbox(label='')
         show_title = ew.Checkbox(label='')
+        use_wiki_page_as_root = ew.Checkbox(label='')
         css = ffw.AutoResizeTextarea()
         project_template = ffw.AutoResizeTextarea(
             validator=V.JsonValidator(if_empty=''))

http://git-wip-us.apache.org/repos/asf/allura/blob/8c4a787c/Allura/allura/model/neighborhood.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/neighborhood.py b/Allura/allura/model/neighborhood.py
index 5695fd1..b27be4d 100644
--- a/Allura/allura/model/neighborhood.py
+++ b/Allura/allura/model/neighborhood.py
@@ -90,6 +90,7 @@ class Neighborhood(MappedClass):
         google_analytics=bool))
     anchored_tools = FieldProperty(str, if_missing='')
     prohibited_tools = FieldProperty(str, if_missing='')
+    use_wiki_page_as_root = FieldProperty(bool, if_missing=False)
 
     def parent_security_context(self):
         return None

http://git-wip-us.apache.org/repos/asf/allura/blob/8c4a787c/Allura/allura/templates/neighborhood_project_list.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/neighborhood_project_list.html b/Allura/allura/templates/neighborhood_project_list.html
index b747af0..ea4d3c5 100644
--- a/Allura/allura/templates/neighborhood_project_list.html
+++ b/Allura/allura/templates/neighborhood_project_list.html
@@ -49,6 +49,9 @@
 {% block header_classes %} colored{% endblock %}
 
 {% block content %}
+    {% if neighborhood.use_wiki_page_as_root and text %}
+      {{ text }}
+    {% endif %}
     {% if neighborhood.homepage %}
       {{neighborhood.homepage|safe}}
     {% endif %}

http://git-wip-us.apache.org/repos/asf/allura/blob/8c4a787c/Allura/allura/templates/widgets/neighborhood_overview_form.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/neighborhood_overview_form.html b/Allura/allura/templates/widgets/neighborhood_overview_form.html
index c555a4d..86e2221 100644
--- a/Allura/allura/templates/widgets/neighborhood_overview_form.html
+++ b/Allura/allura/templates/widgets/neighborhood_overview_form.html
@@ -31,6 +31,8 @@
   {% endif %}
     <label class="grid-4">Show Title</label>
     <div class="grid-14">{{widget.display_field(widget.fields.show_title)}}</div>
+    <label class="grid-4">"Home" Wiki as Root</label>
+    <div class="grid-14">{{widget.display_field(widget.fields.use_wiki_page_as_root)}}</div>
   {% if neighborhood.allow_custom_css %}
     <label class="grid-4">Custom CSS</label>
     <div class="grid-14">{{widget.display_field(widget.fields.css)}}</div>

http://git-wip-us.apache.org/repos/asf/allura/blob/8c4a787c/Allura/allura/tests/functional/test_neighborhood.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_neighborhood.py b/Allura/allura/tests/functional/test_neighborhood.py
index e11dbac..81f2aee 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -40,7 +40,7 @@ from alluratest.controller import setup_trove_categories
 
 class TestNeighborhood(TestController):
     def test_home_project(self):
-        r = self.app.get('/adobe/wiki/')
+        r = self.app.get('/adobe/wiki/', status=302)
         assert r.location.endswith('/adobe/wiki/Home/')
         r = r.follow()
         assert 'This is the "Adobe" neighborhood' in str(r), str(r)
@@ -55,6 +55,11 @@ class TestNeighborhood(TestController):
         r = self.app.get('/adobe/')
         assert r.location.endswith('/adobe/wiki/Home/')
 
+    @patch('allura.model.neighborhood.Neighborhood.use_wiki_page_as_root', True)
+    def test_wiki_as_home(self):
+        r = self.app.get('/adobe/', status=200)
+        assert 'This is the "Adobe" neighborhood' in str(r), str(r)
+
     def test_admin(self):
         r = self.app.get('/adobe/_admin/', extra_environ=dict(username='root'))
         r = self.app.get('/adobe/_admin/overview',