Set the Mentors list to the user that is suggesting a Task.
authorLennard de Rijk <ljvderijk@gmail.com>
Thu, 22 Oct 2009 10:01:11 +0200
changeset 3028 1852a74ba03a
parent 3027 a223fff4cca8
child 3029 3c09b9396e2e
Set the Mentors list to the user that is suggesting a Task.
app/soc/modules/ghop/views/models/task.py
--- a/app/soc/modules/ghop/views/models/task.py	Thu Oct 22 09:54:01 2009 +0200
+++ b/app/soc/modules/ghop/views/models/task.py	Thu Oct 22 10:01:11 2009 +0200
@@ -629,6 +629,16 @@
     else:
       # TODO: Redirect to standard edit page which already has the ability to
       # hide certain fields.
+      # get the mentor entity of the current user that is suggesting the task
+      user_entity = user_logic.logic.getForCurrentAccount()
+
+      filter = {'user': user_entity,
+                'scope': fields['scope'],
+                'status': 'active'}
+
+      mentor_entity = ghop_mentor_logic.logic.getForFields(filter, unique=True)
+      fields['mentors'] = [mentor_entity.key()]
+
       entity = logic.updateOrCreateFromFields(fields)
 
     redirect = ghop_redirects.getSuggestTaskRedirect(