Parameterized patterns in role.py.
Patch by: Lennard de Rijk
Reviewed by: to-be-reviewed
--- 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/(?P<access_type>applicant)/%(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/(?P<access_type>list_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
--- 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
--- 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
--- 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/(?P<access_type>invite)/%(scope)s$',
- 'soc.views.models.%(module_name)s.invite',
- 'Create invite for %(name)s'),
- (r'^%(url_name)s/(?P<access_type>accept_invite)/%(scope)s/%(lnp)s$',
- 'soc.views.models.%(module_name)s.accept_invite',
- 'Accept invite for %(name)s'),
- (r'^%(url_name)s/(?P<access_type>request)/%(scope)s$',
- 'soc.views.models.%(module_name)s.request',
- 'Create a Request to become %(name)s'),
- (r'^%(url_name)s/(?P<access_type>process_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/(?P<access_type>invite)/%(scope)s$',
+ 'soc.views.models.%(module_name)s.invite',
+ 'Create invite for %(name)s'),
+ (r'^%(url_name)s/(?P<access_type>accept_invite)/%(scope)s/%(lnp)s$',
+ 'soc.views.models.%(module_name)s.accept_invite',
+ 'Accept invite for %(name)s'),
+ (r'^%(url_name)s/(?P<access_type>process_request)/%(scope)s/%(lnp)s$',
+ 'soc.views.models.%(module_name)s.process_request',
+ 'Process request for %(name)s'),
+ (r'^%(url_name)s/(?P<access_type>request)/%(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/(?P<access_type>invite)/%(scope)s$',
+ 'soc.views.models.%(module_name)s.invite',
+ 'Create invite for %(name)s'),
+ (r'^%(url_name)s/(?P<access_type>accept_invite)/%(scope)s/%(lnp)s$',
+ 'soc.views.models.%(module_name)s.accept_invite',
+ 'Accept invite for %(name)s'),
+ (r'^%(url_name)s/(?P<access_type>process_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)