# HG changeset patch # User Lennard de Rijk # Date 1232816846 0 # Node ID 24c0a9da6360a572980b1e5f0c83641f34c8f6a9 # Parent 606871fda11ca13ced8f112fcca61e25b5899458 Parameterized patterns in role.py. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r 606871fda11c -r 24c0a9da6360 app/soc/views/models/club.py --- a/app/soc/views/models/club.py Sat Jan 24 16:39:34 2009 +0000 +++ b/app/soc/views/models/club.py Sat Jan 24 17:07:26 2009 +0000 @@ -69,10 +69,14 @@ 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)] + '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')] new_params['extra_django_patterns'] = patterns diff -r 606871fda11c -r 24c0a9da6360 app/soc/views/models/club_admin.py --- a/app/soc/views/models/club_admin.py Sat Jan 24 16:39:34 2009 +0000 +++ b/app/soc/views/models/club_admin.py Sat Jan 24 17:07:26 2009 +0000 @@ -55,7 +55,6 @@ rights['delete'] = [access.checkIsDeveloper] rights['invite'] = [access.checkIsClubAdminForClub] rights['accept_invite'] = [access.checkCanCreateFromRequest('club_admin')] - rights['request'] = [access.deny] rights['process_request'] = [access.checkIsClubAdminForClub, access.checkCanProcessRequest('club_admin')] @@ -78,6 +77,8 @@ 'clean_blog' : cleaning.clean_url('blog'), 'clean_photo_url' : cleaning.clean_url('photo_url')} + new_params['allow_invites'] = True + params = dicts.merge(params, new_params) super(View, self).__init__(params=params) @@ -122,5 +123,4 @@ list = view.list process_request = view.processRequest public = view.public -request = view.request export = view.export diff -r 606871fda11c -r 24c0a9da6360 app/soc/views/models/host.py --- a/app/soc/views/models/host.py Sat Jan 24 16:39:34 2009 +0000 +++ b/app/soc/views/models/host.py Sat Jan 24 17:07:26 2009 +0000 @@ -64,11 +64,9 @@ rights['invite'] = [access.checkIsHost] rights['list'] = [access.checkIsHost] rights['accept_invite'] = [access.checkCanCreateFromRequest('host')] - rights['request'] = [access.deny] rights['process_request'] = [access.checkIsHost, access.checkCanProcessRequest('host')] - new_params = {} new_params['rights'] = rights new_params['logic'] = soc.logic.models.host.logic @@ -92,6 +90,8 @@ 'clean_blog': cleaning.clean_url('blog'), 'clean_photo_url': cleaning.clean_url('photo_url')} + new_params['allow_invites'] = True + params = dicts.merge(params, new_params) super(View, self).__init__(params=params) @@ -158,5 +158,4 @@ list = view.list process_request = view.processRequest public = view.public -request = view.request export = view.export diff -r 606871fda11c -r 24c0a9da6360 app/soc/views/models/role.py --- a/app/soc/views/models/role.py Sat Jan 24 16:39:34 2009 +0000 +++ b/app/soc/views/models/role.py Sat Jan 24 17:07:26 2009 +0000 @@ -61,18 +61,37 @@ new_params = {} # TODO(ljvderijk) parameterize these patterns - patterns = [(r'^%(url_name)s/(?Pinvite)/%(scope)s$', - 'soc.views.models.%(module_name)s.invite', - 'Create invite for %(name)s'), - (r'^%(url_name)s/(?Paccept_invite)/%(scope)s/%(lnp)s$', - 'soc.views.models.%(module_name)s.accept_invite', - 'Accept invite for %(name)s'), - (r'^%(url_name)s/(?Prequest)/%(scope)s$', - 'soc.views.models.%(module_name)s.request', - 'Create a Request to become %(name)s'), - (r'^%(url_name)s/(?Pprocess_request)/%(scope)s/%(lnp)s$', - 'soc.views.models.%(module_name)s.process_request', - 'Process request for %(name)s')] + + patterns = params.get('extra_django_patterns') + + if not patterns: + patterns = [] + + if params.get('allow_requests_and_invites'): + # add patterns concerning requests and invites + patterns += [(r'^%(url_name)s/(?Pinvite)/%(scope)s$', + 'soc.views.models.%(module_name)s.invite', + 'Create invite for %(name)s'), + (r'^%(url_name)s/(?Paccept_invite)/%(scope)s/%(lnp)s$', + 'soc.views.models.%(module_name)s.accept_invite', + 'Accept invite for %(name)s'), + (r'^%(url_name)s/(?Pprocess_request)/%(scope)s/%(lnp)s$', + 'soc.views.models.%(module_name)s.process_request', + 'Process request for %(name)s'), + (r'^%(url_name)s/(?Prequest)/%(scope)s$', + 'soc.views.models.%(module_name)s.request', + 'Create a Request to become %(name)s')] + elif params.get('allow_invites'): + # add patterns concerning only invites + patterns += [(r'^%(url_name)s/(?Pinvite)/%(scope)s$', + 'soc.views.models.%(module_name)s.invite', + 'Create invite for %(name)s'), + (r'^%(url_name)s/(?Paccept_invite)/%(scope)s/%(lnp)s$', + 'soc.views.models.%(module_name)s.accept_invite', + 'Accept invite for %(name)s'), + (r'^%(url_name)s/(?Pprocess_request)/%(scope)s/%(lnp)s$', + 'soc.views.models.%(module_name)s.process_request', + 'Process request for %(name)s')] new_params['extra_django_patterns'] = patterns new_params['scope_redirect'] = redirects.getInviteRedirect @@ -465,4 +484,4 @@ #display the request processing page using the appropriate template template = request_view.view.getParams()['request_processing_template'] - return responses.respond(request, template, context=context) \ No newline at end of file + return responses.respond(request, template, context=context)