241 entity = survey_group_logic.getFromKeyFieldsOr404(kwargs) |
241 entity = survey_group_logic.getFromKeyFieldsOr404(kwargs) |
242 except out_of_band.Error, error: |
242 except out_of_band.Error, error: |
243 return responses.errorResponse( |
243 return responses.errorResponse( |
244 error, request, template=params['error_public']) |
244 error, request, template=params['error_public']) |
245 |
245 |
|
246 # get the context for this webpage |
|
247 context = responses.getUniversalContext(request) |
|
248 responses.useJavaScript(context, params['js_uses_all']) |
|
249 context['page_name'] = "%s for %s named '%s'" %( |
|
250 page_name, params['name'], entity.name) |
|
251 context['entity'] = entity |
|
252 |
246 # get the POST request dictionary and check if we should take action |
253 # get the POST request dictionary and check if we should take action |
247 post_dict = request.POST |
254 post_dict = request.POST |
248 |
255 |
249 if post_dict.get('update_records'): |
256 if post_dict.get('update_records'): |
250 # start the task to update all GradingRecords for the given group |
257 # start the task to update all GradingRecords for the given group |
257 |
264 |
258 # update the GradingSurveyGroup with the new timestamp |
265 # update the GradingSurveyGroup with the new timestamp |
259 fields = {'last_update_started': datetime.datetime.now()} |
266 fields = {'last_update_started': datetime.datetime.now()} |
260 survey_group_logic.updateEntityProperties(entity, fields) |
267 survey_group_logic.updateEntityProperties(entity, fields) |
261 |
268 |
|
269 context['message'] = 'Updating GradingRecords successfully started' |
|
270 |
262 if post_dict.get('update_projects'): |
271 if post_dict.get('update_projects'): |
263 # start the task to update all StudentProjects for the given group |
272 # start the task to update all StudentProjects for the given group |
264 task_params = { |
273 task_params = { |
265 'group_key': entity.key().id_or_name()} |
274 'group_key': entity.key().id_or_name()} |
266 task_url = '/tasks/grading_survey_group/update_projects' |
275 task_url = '/tasks/grading_survey_group/update_projects' |
267 |
276 |
268 new_task = taskqueue.Task(params=task_params, url=task_url) |
277 new_task = taskqueue.Task(params=task_params, url=task_url) |
269 new_task.add() |
278 new_task.add() |
270 |
279 |
|
280 context['message'] = 'Updating StudentProjects successfully started' |
271 |
281 |
272 template = params['records_template'] |
282 template = params['records_template'] |
273 |
283 |
274 list_params = params.copy() |
284 list_params = params.copy() |
275 list_params['logic'] = record_logic |
285 list_params['logic'] = record_logic |
276 list_params['list_heading'] = params['records_heading_template'] |
286 list_params['list_heading'] = params['records_heading_template'] |
277 list_params['list_row'] = params['records_row_template'] |
287 list_params['list_row'] = params['records_row_template'] |
278 # TODO(ljvderijk) proper redirect to edit a record |
288 # TODO(ljvderijk) proper redirect to edit a record |
279 list_params['list_action'] = None |
289 list_params['list_action'] = None |
280 |
290 |
281 # get the context for this webpage |
|
282 context = responses.getUniversalContext(request) |
|
283 responses.useJavaScript(context, params['js_uses_all']) |
|
284 context['page_name'] = "%s for %s named '%s'" %( |
|
285 page_name, params['name'], entity.name) |
|
286 context['entity'] = entity |
|
287 |
|
288 fields = {'grading_survey_group': entity} |
291 fields = {'grading_survey_group': entity} |
289 |
292 |
290 # list all records with grading_decision set to pass |
293 # list all records with grading_decision set to pass |
291 fields['grade_decision'] = 'pass' |
294 fields['grade_decision'] = 'pass' |
292 |
295 |