Keep a global list of all known Roles
authorSverre Rabbelier <srabbelier@gmail.com>
Sun, 15 Feb 2009 16:10:59 +0000
changeset 1346 b3bbc6fa18ef
parent 1345 1c5c6271f02e
child 1347 88dac688b673
Keep a global list of all known Roles This is to facilitate a view with a list of a user's roles. Patch by: Sverre Rabbelier
app/soc/views/models/role.py
app/soc/views/sitemap/build.py
--- a/app/soc/views/models/role.py	Sun Feb 15 15:53:38 2009 +0000
+++ b/app/soc/views/models/role.py	Sun Feb 15 16:10:59 2009 +0000
@@ -45,6 +45,19 @@
 import soc.views.helper.widgets
 
 
+ROLE_VIEWS = {}
+
+
+def addRole(view):
+  """Adds the specified view to the known role views.
+  """
+
+  global ROLE_VIEWS
+  params = view.getParams()
+  name = params['url_name']
+  ROLE_VIEWS[name] = view
+
+
 class View(base.View):
   """Views for all entities that inherit from Role.
 
--- a/app/soc/views/sitemap/build.py	Sun Feb 15 15:53:38 2009 +0000
+++ b/app/soc/views/sitemap/build.py	Sun Feb 15 16:10:59 2009 +0000
@@ -43,10 +43,15 @@
 from soc.views.models import user
 from soc.views.models import user_self
 
+from soc.views.models import role
+
 from soc.views.sitemap import sidebar
 from soc.views.sitemap import sitemap
 
 
+# TODO: instead of commenting out club stuff, make it depend on a setting
+
+
 sidebar.addMenu(user_self.view.getSidebarMenus)
 #sidebar.addMenu(club.view.getSidebarMenus)
 #sidebar.addMenu(club.view.getExtraMenus)
@@ -87,6 +92,12 @@
 sitemap.addPages(user_self.view.getDjangoURLPatterns())
 sitemap.addPages(user.view.getDjangoURLPatterns())
 
+#role.addRole(club_admin.view)
+#role.addRole(club_member.view)
+role.addRole(host.view)
+role.addRole(org_admin.view)
+role.addRole(mentor.view)
+
 
 def getPatterns():
   return defaults.patterns(None, *sitemap.SITEMAP)