allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/3] allura git commit: Ensures there is a default wiki home for use with neighborhood landing pages
Date Mon, 12 Dec 2016 21:07:09 GMT
Ensures there is a default wiki home for use with neighborhood landing pages


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

Branch: refs/heads/master
Commit: e9bedee532ae15ceb51cba772c6ed11dde656bae
Parents: 8c4a787
Author: Kenton Taylor <ktaylor@slashdotmedia.com>
Authored: Mon Dec 12 16:29:00 2016 +0000
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Mon Dec 12 15:56:38 2016 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/project.py            | 23 ++++++++++++++++++--
 .../templates/neighborhood_admin_overview.html  |  2 +-
 .../widgets/neighborhood_overview_form.html     | 10 ++++++++-
 3 files changed, 31 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/e9bedee5/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 0cd083b..05ef643 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -96,7 +96,9 @@ class NeighborhoodController(object):
     def index(self, sort='alpha', limit=25, page=0, **kw):
         text = None
         if self.neighborhood.use_wiki_page_as_root:
-            text = g.markdown_wiki.convert('[[include ref=Home]]')
+            default_wiki_page = get_default_wiki_page()
+            if default_wiki_page:
+                text = g.markdown_wiki.convert('[[include ref=Home]]')
         elif self.neighborhood.redirect:
             redirect(self.neighborhood.redirect)
         elif not self.neighborhood.has_home_tool:
@@ -545,9 +547,12 @@ class NeighborhoodAdminController(object):
         set_nav(self.neighborhood)
         c.overview_form = W.neighborhood_overview_form
         allow_undelete = asbool(config.get('allow_project_undelete', True))
+        allow_wiki_as_root = True if get_default_wiki_page() else False
+
         return dict(
             neighborhood=self.neighborhood,
-            allow_project_undelete=allow_undelete)
+            allow_project_undelete=allow_undelete,
+            allow_wiki_as_root=allow_wiki_as_root)
 
     @without_trailing_slash
     @expose('jinja:allura:templates/neighborhood_admin_permissions.html')
@@ -1015,3 +1020,17 @@ class ProjectImporterController(object):
             return ep.load()(self.neighborhood), rest
 
         raise exc.HTTPNotFound
+
+
+def get_default_wiki_page():
+    """
+    Gets the default home page from the default Wiki setup.
+    """
+
+    from forgewiki import model as WM
+    wiki_page = None
+    wiki_app = c.project.app_instance('wiki')
+    if wiki_app:
+        wiki_app.config._id
+        wiki_page = WM.Page.query.get(app_config_id=wiki_app.config._id, title='Home')
+        return wiki_page

http://git-wip-us.apache.org/repos/asf/allura/blob/e9bedee5/Allura/allura/templates/neighborhood_admin_overview.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/neighborhood_admin_overview.html b/Allura/allura/templates/neighborhood_admin_overview.html
index 8944b22..da2be53 100644
--- a/Allura/allura/templates/neighborhood_admin_overview.html
+++ b/Allura/allura/templates/neighborhood_admin_overview.html
@@ -31,7 +31,7 @@
 {% endblock %}
 
 {% block content %}
-    {{c.overview_form.display(value=neighborhood, neighborhood=neighborhood)}}
+    {{c.overview_form.display(value=neighborhood, neighborhood=neighborhood, allow_wiki_as_root=allow_wiki_as_root)}}
 {% endblock %}
 
 {% block extra_css %}

http://git-wip-us.apache.org/repos/asf/allura/blob/e9bedee5/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 86e2221..7ba2a88 100644
--- a/Allura/allura/templates/widgets/neighborhood_overview_form.html
+++ b/Allura/allura/templates/widgets/neighborhood_overview_form.html
@@ -31,8 +31,16 @@
   {% 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>
+    <div class="grid-14">
+        {%if not allow_wiki_as_root %}
+        This feature is disabled because there is no "Home" page in the default Wiki.
+        {% else %}
+        {{widget.display_field(widget.fields.use_wiki_page_as_root)}}
+        {% endif %}
+    </div>
+
   {% if neighborhood.allow_custom_css %}
     <label class="grid-4">Custom CSS</label>
     <div class="grid-14">{{widget.display_field(widget.fields.css)}}</div>


Mime
View raw message