Diff of /Allura/allura/model/project.py [783474] .. [b6dba6]  Maximize  Restore

  Switch to side-by-side view

--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -91,7 +91,7 @@
         return result
 
 class ProjectMapperExtension(MapperExtension):
-    def after_insert(self, obj, st):
+    def after_insert(self, obj, st, sess):
         g.zarkov_event('project_create', project=obj)
 
 class Project(MappedClass):
@@ -370,8 +370,22 @@
         from allura.app import SitemapEntry
         sitemap = SitemapEntry('root')
         entries = []
+
+        # Set menu mode
+        delta_ordinal = 0
+        max_ordinal = 0
+        neighborhood_admin_mode = False
+        if self == self.neighborhood.neighborhood_project:
+            delta_ordinal = 1
+            neighborhood_admin_mode = True
+            entries.append({'ordinal':0,'entry':SitemapEntry('Home', self.neighborhood.url(), ui_icon="tool-home")})
+
+
         for sub in self.direct_subprojects:
-            entries.append({'ordinal':sub.ordinal,'entry':SitemapEntry(sub.name, sub.url())})
+            ordinal = sub.ordinal + delta_ordinal
+            if ordinal > max_ordinal:
+                max_ordinal = ordinal
+            entries.append({'ordinal':sub.ordinal + delta_ordinal,'entry':SitemapEntry(sub.name, sub.url())})
         for ac in self.app_configs:
             if excluded_tools and ac.tool_name in excluded_tools:
                 continue
@@ -381,11 +395,18 @@
                 for sm in app.sitemap:
                     entry = sm.bind_app(app)
                     entry.ui_icon='tool-%s' % ac.tool_name.lower()
-                    ordinal = ac.options.get('ordinal', 0)
+                    ordinal = ac.options.get('ordinal', 0) + delta_ordinal
+                    if ordinal > max_ordinal:
+                        max_ordinal = ordinal
                     entries.append({'ordinal':ordinal,'entry':entry})
+
+        if neighborhood_admin_mode and h.has_access(self.neighborhood, 'admin'):
+            entries.append({'ordinal': max_ordinal + 1,'entry':SitemapEntry('Moderate', "%s_moderate/" % self.neighborhood.url(), ui_icon="tool-admin")})
+
         entries = sorted(entries, key=lambda e: e['ordinal'])
         for e in entries:
             sitemap.children.append(e['entry'])
+            log.info("ENTRY: %s %s" % (e['entry'].label, e['ordinal']))
         return sitemap.children
 
     def parent_iter(self):

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks