Added sidebar entries for club entities.
Added the right['home'] to club and sponsor view.
Fixed some comments in the group view.
Also added a TODO for the sponsor sidebar entries.
Patch by: Lennard de Rijk
Reviewed by: to-be-reviewed
--- a/app/soc/views/helper/redirects.py Mon Jan 26 17:08:27 2009 +0000
+++ b/app/soc/views/helper/redirects.py Mon Jan 26 17:11:54 2009 +0000
@@ -95,6 +95,16 @@
return result
+def getInviteRedirect(entity, role_name):
+ """Returns the redirect to create an invite for a specific role.
+ """
+
+ result ='/%s/invite/%s' % (
+ role_name, entity.key().name())
+
+ return result
+
+
def getListRequestsRedirect(entity, params):
"""Returns the redirect for the List Requests paged for the given
Group entity and Group View params.
@@ -106,6 +116,17 @@
return result
+def getListRolesRedirect(entity, params):
+ """Returns the redirect for the List Roles paged for the given
+ Group entity and Group View params.
+ """
+
+ result = '/%s/list_roles/%s' % (
+ params['url_name'], entity.key().name())
+
+ return result
+
+
def getProcessRequestRedirect(entity, _):
"""Returns the redirect for processing the specified request entity
"""
@@ -145,6 +166,7 @@
return wrapped
+
def getInviteAcceptedRedirect(entity, _):
"""Returns the redirect for accepting an invite.
"""
--- a/app/soc/views/models/club.py Mon Jan 26 17:08:27 2009 +0000
+++ b/app/soc/views/models/club.py Mon Jan 26 17:11:54 2009 +0000
@@ -37,6 +37,7 @@
from soc.views.helper import access
from soc.views.helper import decorators
from soc.views.helper import dynaform
+from soc.views.helper import redirects
from soc.views.helper import responses
from soc.views.helper import widgets
from soc.views.models import group
@@ -61,6 +62,7 @@
rights['create'] = [access.checkIsDeveloper]
rights['edit'] = [access.checkIsClubAdminForClub]
rights['delete'] = [access.checkIsDeveloper]
+ rights['home'] = [access.allow]
rights['list'] = [access.checkIsDeveloper]
rights['list_requests'] = [access.checkIsClubAdminForClub]
rights['list_roles'] = [access.checkIsClubAdminForClub]
@@ -209,12 +211,50 @@
super(View, self)._editPost(request, entity, fields)
+ def _getExtraMenuItems(self, role_description, params=None):
+ """Used to create the specific club menu entries.
+
+ For args see group.View._getExtraMenuItems().
+ """
+
+ submenus = []
+
+ group_entity = role_description['group']
+ roles = role_description['roles']
+
+ if roles.get('club_admin'):
+ # add a link to the management page
+ submenu = (redirects.getListRolesRedirect(group_entity, params),
+ "Manage Admins and Members", 'any_access')
+ submenus.append(submenu)
+
+ # add a link to invite an admin
+ submenu = (redirects.getInviteRedirect(group_entity, 'club_admin'),
+ "Invite an Admin", 'any_access')
+ submenus.append(submenu)
+
+ # add a link to invite an user
+ submenu = (redirects.getInviteRedirect(group_entity, 'club_member'),
+ "Invite an User", 'any_access')
+ submenus.append(submenu)
+
+ # add a link to the request page
+ submenu = (redirects.getListRequestsRedirect(group_entity, params),
+ "List Requests and Invites", 'any_access')
+ submenus.append(submenu)
+
+ # TODO(ljvderijk) add more usefull links, like resign as admin/member
+
+ return submenus
+
+
view = View()
applicant = view.applicant
create = view.create
delete = view.delete
edit = view.edit
+home = view.home
list = view.list
list_requests = view.listRequests
list_roles = view.listRoles
--- a/app/soc/views/models/group.py Mon Jan 26 17:08:27 2009 +0000
+++ b/app/soc/views/models/group.py Mon Jan 26 17:11:54 2009 +0000
@@ -338,7 +338,7 @@
menu['heading'] = '%s %s' %(params['name'],
group_entity.short_name)
- # TODO add homepage thing to groups
+ # get the documents for this group entity
doc_items = document_view.view.getMenusForScope(group_entity, params)
doc_items = sidebar.getSidebarMenu(doc_items, params=doc_params)
@@ -346,8 +346,10 @@
group_items = self._getExtraMenuItems(role_description, params)
group_items = sidebar.getSidebarMenu(group_items, params=self._params)
+ # add the items together
menu['items'] = doc_items + group_items
+ # append this as a new menu
menus.append(menu)
return menus
--- a/app/soc/views/models/sponsor.py Mon Jan 26 17:08:27 2009 +0000
+++ b/app/soc/views/models/sponsor.py Mon Jan 26 17:11:54 2009 +0000
@@ -49,6 +49,7 @@
rights['create'] = [access.checkIsDeveloper]
rights['edit'] = [access.checkIsHostForSponsor]
rights['delete'] = [access.checkIsDeveloper]
+ rights['home'] = [access.checkIsHostForSponsor]
rights['list'] = [access.checkIsDeveloper]
rights['list_requests'] = [access.checkIsHostForSponsor]
rights['list_roles'] = [access.checkIsHostForSponsor]
@@ -64,12 +65,17 @@
super(View, self).__init__(params=params)
+ # TODO(ljvderijk) add sidebar entries for specific sponsors
+ #def _getExtraMenuItems(self, role_description, params=None):
+
+
view = View()
create = view.create
delete = view.delete
edit = view.edit
+home = view.home
list = view.list
list_requests = view.listRequests
list_roles = view.listRoles