# HG changeset patch # User Sverre Rabbelier # Date 1234714283 0 # Node ID 88dac688b673c5635d29bfc60ec267f2af529136 # Parent b3bbc6fa18efde6540a1f56f0f927f8411e8fd8b Rename current 'roles' view to 'request' and add a real roles view Patch by: Sverre Rabbelier diff -r b3bbc6fa18ef -r 88dac688b673 app/soc/views/models/user_self.py --- a/app/soc/views/models/user_self.py Sun Feb 15 16:10:59 2009 +0000 +++ b/app/soc/views/models/user_self.py Sun Feb 15 16:11:23 2009 +0000 @@ -46,6 +46,7 @@ from soc.views.helper import widgets from soc.views.models import base from soc.views.models import user as user_view +from soc.views.models import role as role_view import soc.models.user @@ -54,6 +55,8 @@ """Views for User own profiles. """ + DEF_ROLE_LIST_MSG_FMT = ugettext("An overview of your roles as %(name)s.") + def __init__(self, params=None): """Defines the fields and methods required for the base View class to provide the user with list, public, create, edit and delete views. @@ -68,6 +71,7 @@ rights['create_profile'] = ['checkIsUnusedAccount'] rights['edit_profile'] = ['checkHasUserEntity'] rights['roles'] = ['checkIsUser'] + rights['requests'] = ['checkIsUser'] rights['signIn'] = ['checkNotLoggedIn'] rights['notification'] = ['checkIsUser'] @@ -105,6 +109,7 @@ ('/' + new_params['url_name'] + '/create_profile', 'Create Profile', 'create_profile'), ('/' + new_params['url_name'] + '/edit_profile', 'Edit Profile', 'edit_profile'), ('/' + new_params['url_name'] + '/roles', 'Roles', 'roles'), + ('/' + new_params['url_name'] + '/requests', 'Requests', 'requests'), ] patterns = [] @@ -119,6 +124,10 @@ page_name = ugettext("List of your roles") patterns += [(r'^%(url_name)s/(?Proles)$', + 'soc.views.models.user_self.roles', page_name)] + + page_name = ugettext("List of your requests") + patterns += [(r'^%(url_name)s/(?Prequests)$', 'soc.views.models.request.list_self', page_name)] new_params['django_patterns_defaults'] = patterns @@ -127,7 +136,6 @@ super(View, self).__init__(params=params) - @decorators.merge_params @decorators.check_access def editProfile(self, request, access_type, @@ -148,7 +156,6 @@ return self.edit(request, access_type, page_name=page_name, params=params, seed=seed, link_id=link_id, **kwargs) - def editGet(self, request, entity, context, seed, params=None): """Overwrite so we can add the contents of the ToS. For params see base.View.editGet(). @@ -187,7 +194,6 @@ return super(View, self).editPost(request, entity, context, params=params) - def _editPost(self, request, entity, fields): """See base.View._editPost(). """ @@ -213,6 +219,42 @@ super(View, self)._editPost(request, entity, fields) + @decorators.merge_params + @decorators.check_access + def roles(self, request, access_type, + page_name=None, params=None, **kwargs): + """Displays the unhandled requests for this user. + + Args: + request: the standard Django HTTP request object + access_type : the name of the access type which should be checked + page_name: the page name displayed in templates as page and header title + params: a dict with params for this View + kwargs: not used + """ + + user = user_logic.getForCurrentAccount() + + + # only select the roles for the current user + filter = { + 'link_id': user.link_id, + } + + contents = [] + + i = 0 + + for name, view in sorted(role_view.ROLE_VIEWS.iteritems()): + params = view.getParams().copy() + params['list_action'] = (redirects.getEditRedirect, params) + params['list_description'] = self.DEF_ROLE_LIST_MSG_FMT % params + + list = helper.lists.getListContent(request, params, filter, i) + contents.append(list) + i += 1 + + return self._list(request, params, contents, page_name) def getSidebarMenus(self, id, user, params=None): """See base.View.getSidebarMenus(). @@ -253,4 +295,4 @@ create = view.create edit = view.editProfile export = view.export - +roles = view.roles