Added update for Surveys, ProjectSurveys and ProjectGradingSurveys.
authorLennard de Rijk <ljvderijk@gmail.com>
Sun, 04 Oct 2009 21:25:52 +0200
changeset 3008 525c65b0a320
parent 3007 d23d1dee5261
child 3009 99f2d9b1ff7d
Added update for Surveys, ProjectSurveys and ProjectGradingSurveys.
app/soc/tasks/updates/module_conversion.py
--- a/app/soc/tasks/updates/module_conversion.py	Sun Oct 04 21:15:58 2009 +0200
+++ b/app/soc/tasks/updates/module_conversion.py	Sun Oct 04 21:25:52 2009 +0200
@@ -27,6 +27,7 @@
 
 from django.http import HttpResponse
 
+from soc.logic.models import survey as survey_logic
 from soc.logic.models.mentor import logic as mentor_logic
 from soc.logic.models.org_admin import logic as org_admin_logic
 from soc.logic.models.organization import logic as org_logic
@@ -327,3 +328,59 @@
 
   # task completed, return
   return
+
+
+@decorators.iterative_task(survey_logic.logic)
+def runSurveyUpdate(request, entities, context, *args, **kwargs):
+  """AppEngine Task that updates Survey entities.
+
+  Args:
+    request: Django Request object
+    entities: list of Survey entities to update
+    context: the context of this task
+  """
+  return _runSurveyUpdate(entities)
+
+
+@decorators.iterative_task(survey_logic.project_logic)
+def runProjectSurveyUpdate(request, entities, context, *args, **kwargs):
+  """AppEngine Task that updates ProjectSurvey entities.
+
+  Args:
+    request: Django Request object
+    entities: list of ProjectSurvey entities to update
+    context: the context of this task
+  """
+  return _runSurveyUpdate(entities)
+
+
+@decorators.iterative_task(survey_logic.grading_logic)
+def runGradingProjectSurveyUpdate(request, entities, context, *args, **kwargs):
+  """AppEngine Task that updates GradingProjectSurvey entities.
+
+  Args:
+    request: Django Request object
+    entities: list of GradingProjectSurvey entities to update
+    context: the context of this task
+  """
+  return _runSurveyUpdate(entities)
+
+
+def _runSurveyUpdate(entities):
+  """AppEngine Task that updates Survey entities.
+
+  Args:
+    entities: list of Survey entities to update
+  """
+
+  from soc.modules.gsoc.logic.models.program import logic as program_logic
+
+  for entity in entities:
+    entity.scope = program_logic.getFromKeyName(
+        entity.scope.key().id_or_name())
+
+  # store all Surveys
+  db.put(entities)
+
+  # task completed, return
+  return