55 rights['list'] = ['checkDocumentList'] |
55 rights['list'] = ['checkDocumentList'] |
56 rights['results'] = [('checkIsSurveyWritable', project_survey_logic)] |
56 rights['results'] = [('checkIsSurveyWritable', project_survey_logic)] |
57 rights['take'] = [('checkIsSurveyTakeable', project_survey_logic), |
57 rights['take'] = [('checkIsSurveyTakeable', project_survey_logic), |
58 ('checkIsAllowedToTakeProjectSurveyAs', |
58 ('checkIsAllowedToTakeProjectSurveyAs', |
59 [project_survey_logic, 'student', 'project'])] |
59 [project_survey_logic, 'student', 'project'])] |
|
60 rights['send_reminder'] = ['checkIsDeveloper'] #TODO: proper access check |
60 |
61 |
61 new_params = {} |
62 new_params = {} |
62 new_params['logic'] = project_survey_logic |
63 new_params['logic'] = project_survey_logic |
63 new_params['rights'] = rights |
64 new_params['rights'] = rights |
64 |
65 |
65 new_params['name'] = "Project Survey" |
66 new_params['name'] = "Project Survey" |
66 |
67 |
67 new_params['extra_dynaexclude'] = ['taking_access'] |
68 new_params['extra_dynaexclude'] = ['taking_access'] |
|
69 |
|
70 new_params['extra_django_patterns'] = [ |
|
71 (r'^%(url_name)s/(?P<access_type>send_reminder)/start/%(key_fields)s$', |
|
72 'soc.views.models.%(module_name)s.send_reminder', |
|
73 'Send Reminder for %(name)s')] |
|
74 |
|
75 # used for sending reminders |
|
76 new_params['survey_type'] = 'project' |
|
77 new_params['reminder_template'] = 'soc/project_survey/reminder.html' |
68 |
78 |
69 params = dicts.merge(params, new_params, sub_merge=True) |
79 params = dicts.merge(params, new_params, sub_merge=True) |
70 |
80 |
71 super(View, self).__init__(params=params) |
81 super(View, self).__init__(params=params) |
72 |
82 |
207 |
217 |
208 content = lists.getListContent(request, student_project_params, fields) |
218 content = lists.getListContent(request, student_project_params, fields) |
209 contents = [content] |
219 contents = [content] |
210 |
220 |
211 return self._list(request, student_project_params, contents, page_name) |
221 return self._list(request, student_project_params, contents, page_name) |
|
222 |
|
223 |
|
224 @decorators.merge_params |
|
225 @decorators.check_access |
|
226 def sendReminder(self, request, access_type, page_name=None, |
|
227 params=None, **kwargs): |
|
228 """Starts the task to send out reminders for the Survey given in kwargs. |
|
229 |
|
230 For args see base.View.public(). |
|
231 """ |
|
232 |
|
233 from google.appengine.api.labs import taskqueue |
|
234 |
|
235 from django import http |
|
236 |
|
237 survey_logic = params['logic'] |
|
238 |
|
239 try: |
|
240 entity = survey_logic.getFromKeyFieldsOr404(kwargs) |
|
241 except out_of_band.Error, error: |
|
242 return responses.errorResponse( |
|
243 error, request, template=params['error_public']) |
|
244 |
|
245 # get the context for this webpage |
|
246 context = responses.getUniversalContext(request) |
|
247 context['page_name'] = page_name |
|
248 |
|
249 if request.POST and request.POST.get('start'): |
|
250 # button has been pressed start the task |
|
251 task_params = { |
|
252 'program_key': survey_logic.getScope(entity).key().id_or_name(), |
|
253 'survey_key': entity.key().id_or_name(), |
|
254 'survey_type': params['survey_type']} |
|
255 task_url = '/tasks/surveys/projects/send_reminder/spawn' |
|
256 |
|
257 new_task = taskqueue.Task(params=task_params, url=task_url) |
|
258 new_task.add() |
|
259 |
|
260 context['message'] = "Task successfully started!" |
|
261 |
|
262 template = params['reminder_template'] |
|
263 return responses.respond(request, template, context) |
212 |
264 |
213 |
265 |
214 view = View() |
266 view = View() |
215 |
267 |
216 create = decorators.view(view.create) |
268 create = decorators.view(view.create) |
217 edit = decorators.view(view.edit) |
269 edit = decorators.view(view.edit) |
218 delete = decorators.view(view.delete) |
270 delete = decorators.view(view.delete) |
219 list = decorators.view(view.list) |
271 list = decorators.view(view.list) |
220 public = decorators.view(view.public) |
272 public = decorators.view(view.public) |
221 results = decorators.view(view.viewResults) |
273 results = decorators.view(view.viewResults) |
|
274 send_reminder = decorators.view(view.sendReminder) |
222 take = decorators.view(view.take) |
275 take = decorators.view(view.take) |