71 patterns = [] |
71 patterns = [] |
72 |
72 |
73 patterns += [ |
73 patterns += [ |
74 (r'^%(url_name)s/(?P<access_type>list_requests)/%(key_fields)s$', |
74 (r'^%(url_name)s/(?P<access_type>list_requests)/%(key_fields)s$', |
75 'soc.views.models.%(module_name)s.list_requests', |
75 'soc.views.models.%(module_name)s.list_requests', |
76 'List of requests for %(name)s')] |
76 'List of requests for %(name)s'), |
|
77 (r'^%(url_name)s/(?P<access_type>list_roles)/%(key_fields)s$', |
|
78 'soc.views.models.%(module_name)s.list_roles', |
|
79 'List of roles for %(name)s')] |
77 |
80 |
78 new_params['extra_django_patterns'] = patterns |
81 new_params['extra_django_patterns'] = patterns |
79 |
82 |
80 # TODO(tlarsen): Add support for Django style template lookup |
83 # TODO(tlarsen): Add support for Django style template lookup |
81 new_params['public_template'] = 'soc/group/public.html' |
84 new_params['public_template'] = 'soc/group/public.html' |
82 |
85 |
83 new_params['list_row'] = 'soc/group/list/row.html' |
86 new_params['list_row'] = 'soc/group/list/row.html' |
84 new_params['list_heading'] = 'soc/group/list/heading.html' |
87 new_params['list_heading'] = 'soc/group/list/heading.html' |
|
88 |
|
89 new_params['role_views'] = {} |
85 |
90 |
86 params = dicts.merge(params, new_params) |
91 params = dicts.merge(params, new_params) |
87 |
92 |
88 super(View, self).__init__(params=params) |
93 super(View, self).__init__(params=params) |
89 |
94 |
127 # get the group from the request |
132 # get the group from the request |
128 group_logic = params['logic'] |
133 group_logic = params['logic'] |
129 |
134 |
130 group_entity = group_logic.getFromFields(**kwargs) |
135 group_entity = group_logic.getFromFields(**kwargs) |
131 |
136 |
132 role_names = params['roles_logic'].keys() |
137 role_names = params['role_views'].keys() |
133 |
138 |
134 # list all incoming requests |
139 # list all incoming requests |
135 filter = { |
140 filter = { |
136 'scope' : group_entity, |
141 'scope' : group_entity, |
137 'role': role_names, |
142 'role': role_names, |
186 request, ignored_params, filter, 2) |
191 request, ignored_params, filter, 2) |
187 |
192 |
188 contents = [inc_req_content, out_inv_content, ignored_content] |
193 contents = [inc_req_content, out_inv_content, ignored_content] |
189 |
194 |
190 return self._list(request, params, contents, page_name) |
195 return self._list(request, params, contents, page_name) |
|
196 |
|
197 |
|
198 @decorators.merge_params |
|
199 @decorators.check_access |
|
200 def listRoles(self, request, access_type, |
|
201 page_name=None, params=None, **kwargs): |
|
202 """Gives an overview of all the roles in a specific group. |
|
203 |
|
204 Args: |
|
205 request: the standard Django HTTP request object |
|
206 access_type : the name of the access type which should be checked |
|
207 page_name: the page name displayed in templates as page and header title |
|
208 params: a dict with params for this View |
|
209 kwargs: the Key Fields for the specified entity |
|
210 """ |
|
211 |
|
212 # set the pagename to include the link_id |
|
213 page_name = '%s %s' %(page_name, kwargs['link_id']) |
|
214 |
|
215 # get the group from the request |
|
216 group_logic = params['logic'] |
|
217 |
|
218 group_entity = group_logic.getFromFields(**kwargs) |
|
219 |
|
220 # create the filter |
|
221 filter = { |
|
222 'scope' : group_entity, |
|
223 'state': 'active' |
|
224 } |
|
225 |
|
226 role_views = params['role_views'] |
|
227 contents = [] |
|
228 index = 0 |
|
229 |
|
230 # for each role we create a separate list |
|
231 for role_name in role_views.keys(): |
|
232 # create the list parameters |
|
233 list_params = role_views[role_name].getParams().copy() |
|
234 |
|
235 # TODO(ljvderijk) define the list redirect action to the managing page |
|
236 list_params['list_action'] = (redirects.getEditRedirect, list_params) |
|
237 list_params['list_description'] = ugettext( |
|
238 "An overview of the %s for this %s." % ( |
|
239 list_params['name_plural'], params['name'])) |
|
240 |
|
241 new_list_content = list_helper.getListContent( |
|
242 request, list_params, filter, index) |
|
243 |
|
244 contents += [new_list_content] |
|
245 |
|
246 index += 1 |
|
247 |
|
248 # call the _list method from base.View to show the list |
|
249 return self._list(request, params, contents, page_name) |
|
250 |
|
251 |
|
252 def registerRole(self, role_name, role_view): |
|
253 """Adds a role to the role_views param. |
|
254 |
|
255 Args: |
|
256 role_name: The name of the role that needs to be added |
|
257 role_view: The view that needs to be added to role_views. |
|
258 """ |
|
259 |
|
260 role_views = self._params['role_views'] |
|
261 role_views[role_name] = role_view |