434 context: the context for the webpage |
434 context: the context for the webpage |
435 template: the location of the template used for this view |
435 template: the location of the template used for this view |
436 record_entity: a GradingRecord entity |
436 record_entity: a GradingRecord entity |
437 """ |
437 """ |
438 |
438 |
|
439 from google.appengine.api.labs import taskqueue |
|
440 from soc.logic.models.student_project import logic as student_project_logic |
|
441 |
439 survey_logic = params['logic'] |
442 survey_logic = params['logic'] |
440 record_logic = survey_logic.getRecordLogic() |
443 record_logic = survey_logic.getRecordLogic() |
441 |
444 |
442 form = params['record_edit_form'](request.POST) |
445 post_dict = request.POST |
|
446 |
|
447 form = params['record_edit_form'](post_dict) |
443 |
448 |
444 if not form.is_valid(): |
449 if not form.is_valid(): |
445 return self._constructResponse(request, record_entity, context, form, |
450 return self._constructResponse(request, record_entity, context, form, |
446 params) |
451 params) |
447 |
452 |
448 _, fields = forms_helper.collectCleanedFields(form) |
453 _, fields = forms_helper.collectCleanedFields(form) |
449 |
454 |
450 record_entity = record_logic.updateEntityProperties(record_entity, fields) |
455 record_entity = record_logic.updateEntityProperties(record_entity, fields) |
|
456 |
|
457 if 'save_update' in post_dict: |
|
458 # also update the accompanying StudentProject |
|
459 student_project_logic.updateProjectsForGradingRecords([record_entity]) |
|
460 elif 'save_update_mail' in post_dict: |
|
461 # update the StudentProject and send an email about the result |
|
462 student_project_logic.updateProjectsForGradingRecords([record_entity]) |
|
463 |
|
464 # pass along these params as POST to the new task |
|
465 task_params = {'record_key': record_entity.key().id_or_name()} |
|
466 task_url = '/tasks/grading_survey_group/mail_result' |
|
467 |
|
468 mail_task = taskqueue.Task(params=task_params, url=task_url) |
|
469 mail_task.add('mail') |
451 |
470 |
452 # Redirect to the same page |
471 # Redirect to the same page |
453 redirect = request.META['HTTP_REFERER'] |
472 redirect = request.META['HTTP_REFERER'] |
454 return http.HttpResponseRedirect(redirect) |
473 return http.HttpResponseRedirect(redirect) |
455 |
474 |