Added capability to update a single GradingRecord on the edit page.
authorLennard de Rijk <ljvderijk@gmail.com>
Sun, 09 Aug 2009 13:03:47 -0700
changeset 2739 22f41aafcedc
parent 2738 5723f329d098
child 2740 4b8aa5b9cb23
Added capability to update a single GradingRecord on the edit page.
app/soc/templates/soc/grading_record/edit.html
app/soc/views/models/grading_survey_group.py
--- a/app/soc/templates/soc/grading_record/edit.html	Sat Aug 08 18:42:22 2009 +0100
+++ b/app/soc/templates/soc/grading_record/edit.html	Sun Aug 09 13:03:47 2009 -0700
@@ -49,13 +49,16 @@
   </tr>
   <tr>
    <td> 
-    <input style="font-weight: bold" type="submit" name="save" value="Save Changes"/></span>
+    <input style="font-weight: bold" type="submit" name="save" value="Save Changes"/>
    </td>
    <td> 
-    <input style="font-weight: bold" type="submit" name="save_update" value="Save Changes and Update Project"/></span>
+    <input style="font-weight: bold" type="submit" name="save_update" value="Save Changes and Update Project"/>
    </td>
    <td> 
-    <input style="font-weight: bold" type="submit" name="save_update_mail" value="Save Changes, Update Project and Send Mail"/></span>
+    <input style="font-weight: bold" type="submit" name="save_update_mail" value="Save Changes, Update Project and Send Mail"/>
+   </td>
+   <td>
+     <input type="button" value="Auto-Update this Record" onClick="parent.location='?id={{entity.key.id_or_name}}&update=1'">
    </td>
    <td>
      <input type="button" value="Back to Previous Page" onClick="javascript:history.go(-1)">
--- a/app/soc/views/models/grading_survey_group.py	Sat Aug 08 18:42:22 2009 +0100
+++ b/app/soc/views/models/grading_survey_group.py	Sun Aug 09 13:03:47 2009 -0700
@@ -420,6 +420,18 @@
       record_entity: a GradingRecord entity
     """
 
+    survey_group_logic = params['logic']
+    record_logic = survey_group_logic.getRecordLogic()
+
+    get_dict = request.GET
+
+    if get_dict.get('update'):
+      # try to update this record
+      properties = record_logic.getFieldsForGradingRecord(
+          record_entity.project, record_entity.grading_survey_group,
+          record_entity)
+      record_logic.updateEntityProperties(record_entity, properties)
+
     form = params['record_edit_form'](instance=record_entity)
     context['form'] = form