# HG changeset patch # User Lennard de Rijk # Date 1232895792 0 # Node ID 1bbf226ade8ed08252d02c1be9d20081e9b0728a # Parent 9efcedcfeb3e3148c8531cf364d2678fd8a89454 Added request listing for Club Admins. This page will redirect them to the Request Processing page. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r 9efcedcfeb3e -r 1bbf226ade8e app/soc/views/models/club.py --- a/app/soc/views/models/club.py Sun Jan 25 15:01:55 2009 +0000 +++ b/app/soc/views/models/club.py Sun Jan 25 15:03:12 2009 +0000 @@ -27,18 +27,23 @@ from django import http from django import forms +from django.utils.translation import ugettext from soc.logic import dicts from soc.logic.models import user as user_logic from soc.logic.models import club_app as club_app_logic from soc.logic.models import club as club_logic +from soc.logic.models import request as request_logic from soc.views import out_of_band from soc.views.helper import access from soc.views.helper import decorators from soc.views.helper import dynaform +from soc.views.helper import lists as list_helper +from soc.views.helper import redirects from soc.views.helper import responses from soc.views.helper import widgets from soc.views.models import base +from soc.views.models.request import view as request_view import soc.logic.models.club import soc.views.helper @@ -61,6 +66,7 @@ rights['edit'] = [access.checkIsClubAdminForClub] rights['delete'] = [access.checkIsDeveloper] rights['list'] = [access.checkIsDeveloper] + rights['list_requests'] = [access.checkIsClubAdminForClub] rights['applicant'] = [access.checkIsApplicationAccepted(club_app_logic)] new_params = {} @@ -69,14 +75,13 @@ new_params['name'] = "Club" patterns = [] - - # TODO(ljvderijk) implement requests list for clubs - page_name = "Club Creation via Accepted Application" + patterns += [(r'^%(url_name)s/(?Papplicant)/%(key_fields)s$', - 'soc.views.models.%(module_name)s.applicant', page_name),] - #(r'^%(url_name)s/(?Plist_requests)/%(key_fields)s$', - #'soc.views.models.%(module_name)s.list_requests', - #'List of requests for %(name_plural)s')] + 'soc.views.models.%(module_name)s.applicant', + "%(name)s Creation via Accepted Application"), + (r'^%(url_name)s/(?Plist_requests)/%(key_fields)s$', + 'soc.views.models.%(module_name)s.list_requests', + 'List of requests for %(name)s')] new_params['extra_django_patterns'] = patterns @@ -188,6 +193,83 @@ # redirect to notifications list to see the admin invite return http.HttpResponseRedirect('/notification/list') + + @decorators.merge_params + @decorators.check_access + def listRequests(self, request, access_type, + page_name=None, params=None, **kwargs): + """Gives an overview of all the requests for a specific club. + + 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: the Key Fields for the specified entity + """ + + # set the pagename to include the link_id + page_name = '%s %s' %(page_name, kwargs['link_id']) + + club_roles = ['club_admin', 'club_member'] + + # list all incoming requests + filter = { + 'role': club_roles, + 'state': 'new' + } + + # create the list parameters + inc_req_params = request_view.getParams() + + # define the list redirect action to the request processing page + inc_req_params['list_action'] = (redirects.getProcessRequestRedirect, None) + inc_req_params['list_description'] = ugettext( + "An overview of the club's incoming requests.") + + inc_req_content = list_helper.getListContent( + request, inc_req_params, filter, 0) + + # list all outstanding invites + filter = { + 'role': club_roles, + 'state': 'group_accepted' + } + + # create the list parameters + out_inv_params = request_view.getParams() + + # define the list redirect action to the request processing page + out_inv_params['list_action'] = (redirects.getProcessRequestRedirect, None) + out_inv_params['list_description'] = ugettext( + "An overview of the club's outstanding invites.") + + out_inv_content = list_helper.getListContent( + request, out_inv_params, filter, 1) + + # list all ignored requests + filter = { + 'role': club_roles, + 'state': 'ignored' + } + + # create the list parameters + ignored_params = request_view.getParams() + + # define the list redirect action to the request processing page + ignored_params['list_action'] = (redirects.getProcessRequestRedirect, None) + ignored_params['list_description'] = ugettext( + "An overview of the club's ignored requests.") + + ignored_content = list_helper.getListContent( + request, ignored_params, filter, 2) + + + contents = [inc_req_content, out_inv_content, ignored_content] + + return self._list(request, params, contents, page_name) + + def _editGet(self, request, entity, form): """See base.View._editGet(). """ @@ -216,6 +298,7 @@ delete = view.delete edit = view.edit list = view.list +list_requests = view.listRequests public = view.public export = view.export pick = view.pick