21 '"Daniel Diniz" <ajaksu@gmail.com>', |
21 '"Daniel Diniz" <ajaksu@gmail.com>', |
22 '"Lennard de Rijk" <ljvderijk@gmail.com>', |
22 '"Lennard de Rijk" <ljvderijk@gmail.com>', |
23 ] |
23 ] |
24 |
24 |
25 |
25 |
|
26 import datetime |
26 import time |
27 import time |
27 |
28 |
28 from google.appengine.ext.db import djangoforms |
29 from google.appengine.ext.db import djangoforms |
29 |
30 |
30 from django import forms |
31 from django import forms |
227 """View which shows all collected records for a given GradingSurveyGroup. |
228 """View which shows all collected records for a given GradingSurveyGroup. |
228 |
229 |
229 For args see base.View.public(). |
230 For args see base.View.public(). |
230 """ |
231 """ |
231 |
232 |
|
233 from google.appengine.api.labs import taskqueue |
|
234 |
232 from soc.logic import lists as lists_logic |
235 from soc.logic import lists as lists_logic |
233 from soc.logic.models.grading_record import logic as record_logic |
236 from soc.logic.models.grading_record import logic as record_logic |
234 |
237 |
235 survey_group_logic = params['logic'] |
238 survey_group_logic = params['logic'] |
236 |
239 |
237 try: |
240 try: |
238 entity = survey_group_logic.getFromKeyFieldsOr404(kwargs) |
241 entity = survey_group_logic.getFromKeyFieldsOr404(kwargs) |
239 except out_of_band.Error, error: |
242 except out_of_band.Error, error: |
240 return responses.errorResponse( |
243 return responses.errorResponse( |
241 error, request, template=params['error_public']) |
244 error, request, template=params['error_public']) |
|
245 |
|
246 # get the POST request dictionary and check if we should take action |
|
247 post_dict = request.POST |
|
248 |
|
249 if post_dict.get('update_records'): |
|
250 # start the task to update all GradingRecords for the given group |
|
251 task_params = { |
|
252 'group_key': entity.key().id_or_name()} |
|
253 task_url = '/tasks/grading_survey_group/update_records' |
|
254 |
|
255 new_task = taskqueue.Task(params=task_params, url=task_url) |
|
256 new_task.add() |
|
257 |
|
258 # update the GradingSurveyGroup with the new timestamp |
|
259 fields = {'last_update_started': datetime.datetime.now()} |
|
260 survey_group_logic.updateEntityProperties(entity, fields) |
|
261 |
|
262 if post_dict.get('update_projects'): |
|
263 # start the task to update all StudentProjects for the given group |
|
264 task_params = { |
|
265 'group_key': entity.key().id_or_name()} |
|
266 task_url = '/tasks/grading_survey_group/update_projects' |
|
267 |
|
268 new_task = taskqueue.Task(params=task_params, url=task_url) |
|
269 new_task.add() |
|
270 |
242 |
271 |
243 template = params['records_template'] |
272 template = params['records_template'] |
244 |
273 |
245 list_params = params.copy() |
274 list_params = params.copy() |
246 list_params['logic'] = record_logic |
275 list_params['logic'] = record_logic |