Added button to the GradingRecords overview to send mail when updating projects.
authorLennard de Rijk <ljvderijk@gmail.com>
Tue, 14 Jul 2009 18:36:16 +0200
changeset 2648 c6d1c9ccef4a
parent 2647 69ac7307bb50
child 2649 7faecb7f2765
Added button to the GradingRecords overview to send mail when updating projects. Note that this will mail all the projects for which a record is available.
app/soc/templates/soc/grading_survey_group/records.html
app/soc/views/models/grading_survey_group.py
--- a/app/soc/templates/soc/grading_survey_group/records.html	Tue Jul 14 18:35:20 2009 +0200
+++ b/app/soc/templates/soc/grading_survey_group/records.html	Tue Jul 14 18:36:16 2009 +0200
@@ -29,7 +29,10 @@
         <input type="submit" name="update_records" value="Start Updating Records" style="font-weight: bold;">
       </td>
       <td>
-        <input type="submit" name="update_projects" value="Update Projects with collected Grades" style="font-weight: bold;">
+        <input type="submit" name="update_projects" value="Update Projects with collected Records" style="font-weight: bold;">
+      </td>
+      <td>
+        <input type="submit" name="update_projects_and_mail" value="Update Projects with collected Records + send mail" style="font-weight: bold;">
       </td>
     </tr>
   </table>
--- a/app/soc/views/models/grading_survey_group.py	Tue Jul 14 18:35:20 2009 +0200
+++ b/app/soc/views/models/grading_survey_group.py	Tue Jul 14 18:36:16 2009 +0200
@@ -289,7 +289,7 @@
       fields = {'last_update_started': datetime.datetime.now()}
       survey_group_logic.updateEntityProperties(entity, fields)
 
-      context['message'] = 'Updating GradingRecords successfully started'
+      context['message'] = 'Updating GradingRecords successfully started.'
 
     if post_dict.get('update_projects'):
       # start the task to update all StudentProjects for the given group
@@ -300,7 +300,22 @@
       new_task = taskqueue.Task(params=task_params, url=task_url)
       new_task.add()
 
-      context['message'] = 'Updating StudentProjects successfully started'
+      context['message'] = 'Updating StudentProjects successfully started.'
+
+    if post_dict.get('update_projects_and_mail'):
+      # Start the task to update all StudentProjects for the given group and
+      # send out emails.
+      task_params = {
+          'group_key': entity.key().id_or_name(),
+          'send_mail': 'true'}
+      task_url = '/tasks/grading_survey_group/update_projects'
+
+      new_task = taskqueue.Task(params=task_params, url=task_url)
+      new_task.add()
+
+      context['message'] = ('Updating StudentProjects successfully started. '
+                           'And sending out e-mail with the results.')
+
 
     list_params = params.copy()
     list_params['logic'] = record_logic