67 [org_app_logic.logic])] |
67 [org_app_logic.logic])] |
68 rights['review'] = ['checkIsHostForProgramInScope', |
68 rights['review'] = ['checkIsHostForProgramInScope', |
69 ('checkCanReviewGroupApp', [org_app_logic.logic])] |
69 ('checkCanReviewGroupApp', [org_app_logic.logic])] |
70 rights['review_overview'] = ['checkIsHostForProgramInScope'] |
70 rights['review_overview'] = ['checkIsHostForProgramInScope'] |
71 rights['bulk_accept'] = ['checkIsHostForProgramInScope'] |
71 rights['bulk_accept'] = ['checkIsHostForProgramInScope'] |
|
72 rights['bulk_reject'] = ['checkIsHostForProgramInScope'] |
72 rights['apply'] = ['checkIsUser', |
73 rights['apply'] = ['checkIsUser', |
73 ('checkCanCreateOrgApp', ['org_signup'])] |
74 ('checkCanCreateOrgApp', ['org_signup'])] |
74 |
75 |
75 new_params = {} |
76 new_params = {} |
76 |
77 |
85 patterns = [(r'^%(url_name)s/(?P<access_type>apply)/%(scope)s$', |
86 patterns = [(r'^%(url_name)s/(?P<access_type>apply)/%(scope)s$', |
86 'soc.views.models.%(module_name)s.create', |
87 'soc.views.models.%(module_name)s.create', |
87 'Create an %(name_plural)s'), |
88 'Create an %(name_plural)s'), |
88 (r'^%(url_name)s/(?P<access_type>bulk_accept)/%(scope)s$', |
89 (r'^%(url_name)s/(?P<access_type>bulk_accept)/%(scope)s$', |
89 'soc.views.models.%(module_name)s.bulk_accept', |
90 'soc.views.models.%(module_name)s.bulk_accept', |
90 'Bulk Acceptation of %(name_plural)s'),] |
91 'Bulk Acceptation of %(name_plural)s'), |
|
92 (r'^%(url_name)s/(?P<access_type>bulk_reject)/%(scope)s$', |
|
93 'soc.views.models.%(module_name)s.bulk_reject', |
|
94 'Bulk Rejection of %(name_plural)s'),] |
91 |
95 |
92 new_params['extra_django_patterns'] = patterns |
96 new_params['extra_django_patterns'] = patterns |
93 new_params['extra_key_order'] = ['admin_agreement', |
97 new_params['extra_key_order'] = ['admin_agreement', |
94 'agreed_to_admin_agreement'] |
98 'agreed_to_admin_agreement'] |
95 |
99 |
128 @ decorators.merge_params |
132 @ decorators.merge_params |
129 def reviewOverview(self, request, access_type, |
133 def reviewOverview(self, request, access_type, |
130 page_name=None, params=None, **kwargs): |
134 page_name=None, params=None, **kwargs): |
131 |
135 |
132 params['list_template'] = 'soc/org_app/review_overview.html' |
136 params['list_template'] = 'soc/org_app/review_overview.html' |
133 context = {'bulk_accept_link': '/org_app/bulk_accept/%(scope_path)s' %( |
137 context = { |
134 kwargs)} |
138 'bulk_accept_link': '/org_app/bulk_accept/%(scope_path)s' %(kwargs), |
|
139 'bulk_reject_link': '/org_app/bulk_reject/%(scope_path)s' %(kwargs),} |
135 |
140 |
136 return super(View, self).reviewOverview(request, access_type, |
141 return super(View, self).reviewOverview(request, access_type, |
137 page_name=page_name, params=params, context=context, **kwargs) |
142 page_name=page_name, params=params, context=context, **kwargs) |
138 |
143 |
139 def _editContext(self, request, context): |
144 def _editContext(self, request, context): |
160 |
165 |
161 content = entity.org_admin_agreement.content |
166 content = entity.org_admin_agreement.content |
162 |
167 |
163 form.fields['admin_agreement'].widget.text = content |
168 form.fields['admin_agreement'].widget.text = content |
164 |
169 |
165 |
|
166 def _review(self, request, params, app_entity, status, **kwargs): |
170 def _review(self, request, params, app_entity, status, **kwargs): |
167 """Sends out an email if an org_app has been reviewed and accepted. |
171 """Sends out an email if an org_app has been reviewed and accepted. |
168 |
172 |
169 For params see group_app.View._review(). |
173 For params see group_app.View._review(). |
170 """ |
174 """ |
171 |
175 |
172 if status == 'accepted': |
176 if status == 'accepted': |
173 #TODO(ljvderijk) create the email template |
177 #TODO(ljvderijk) create the email template |
174 pass |
178 pass |
175 |
179 elif status == 'rejected': |
|
180 #TODO(ljvderijk) create the rejected email template |
|
181 pass |
176 |
182 |
177 @decorators.merge_params |
183 @decorators.merge_params |
178 @decorators.check_access |
184 @decorators.check_access |
179 def bulkAccept(self, request, access_type, |
185 def bulkAccept(self, request, access_type, |
180 page_name=None, params=None, **kwargs): |
186 page_name=None, params=None, **kwargs): |
181 """Returns a HTTP Response containing JSON information needed |
187 """Returns a HTTP Response containing JSON information needed |
182 to bulk-accept orgs. |
188 to bulk-accept orgs. |
183 """ |
189 """ |
184 |
190 |
185 program_entity = program_logic.logic.getFromKeyName(kwargs['scope_path']) |
191 program_keyname = kwargs['scope_path'] |
186 |
192 return self._bulkReview(request, params, 'pre-accepted', 'accepted', |
187 # get all pre-accepted organization applications for the given program |
193 program_keyname) |
188 filter = {'scope' : program_entity, |
194 |
189 'status' : 'pre-accepted'} |
195 @decorators.merge_params |
190 org_app_entities = org_app_logic.logic.getForFields(filter=filter) |
196 @decorators.check_access |
|
197 def bulkReject(self, request, access_type, |
|
198 page_name=None, params=None, **kwargs): |
|
199 """Returns a HTTP Response containing JSON information needed |
|
200 to bulk-accept orgs. |
|
201 """ |
|
202 |
|
203 program_keyname = kwargs['scope_path'] |
|
204 return self._bulkReview(request, params, 'pre-rejected', 'rejected', |
|
205 program_keyname) |
|
206 |
|
207 def _bulkReview(self, request, params, from_status, to_status, |
|
208 program_keyname): |
|
209 """Returns a HTTP Response containing JSON information needed |
|
210 to bulk-review organization applications. |
|
211 |
|
212 Args: |
|
213 request: Standard Django HTTP Request object |
|
214 params: Params for this view |
|
215 from_status: The status for the applications which should |
|
216 be reviewed (can be a list) |
|
217 to_status: The status to which all applications should be changed to |
|
218 program_keyname: The keyname for the program to which |
|
219 the application belongs |
|
220 """ |
|
221 |
|
222 # get the program entity from the keyname |
|
223 program_entity = program_logic.logic.getFromKeyName(program_keyname) |
|
224 |
|
225 # get all the organization applications for the given program and from_status |
|
226 filter = {'scope': program_entity, |
|
227 'status': from_status} |
|
228 |
|
229 org_app_entities = params['logic'].getForFields(filter=filter) |
191 |
230 |
192 # convert each application into a dictionary containing only the fields |
231 # convert each application into a dictionary containing only the fields |
193 # given by the dict_filter |
232 # given by the dict_filter |
194 dict_filter = ['link_id', 'name'] |
233 dict_filter = ['link_id', 'name'] |
195 org_apps = [dicts.filter(i.toDict(), dict_filter) for i in org_app_entities] |
234 org_apps = [dicts.filter(i.toDict(), dict_filter) for i in org_app_entities] |
197 to_json = { |
236 to_json = { |
198 'program' : program_entity.name, |
237 'program' : program_entity.name, |
199 'nr_applications' : len(org_apps), |
238 'nr_applications' : len(org_apps), |
200 'application_type' : params['name_plural'], |
239 'application_type' : params['name_plural'], |
201 'applications': org_apps, |
240 'applications': org_apps, |
202 'link' : '/org_app/review/%s/(link_id)?status=accepted' %( |
241 'link' : '/%s/review/%s/(link_id)?status=%s' %( |
203 program_entity.key().name()), |
242 params['url_name'] ,program_entity.key().name(), to_status), |
204 } |
243 } |
205 |
244 |
206 json = simplejson.dumps(to_json) |
245 json = simplejson.dumps(to_json) |
207 |
246 |
208 # use the standard JSON template to return our response |
247 # use the standard JSON template to return our response |