# HG changeset patch # User Lennard de Rijk # Date 1254684352 -7200 # Node ID 525c65b0a320c4fad5d6d166bbe9c33d9f54441e # Parent d23d1dee5261f3163e07a6f35d20f0cec5e1f2c9 Added update for Surveys, ProjectSurveys and ProjectGradingSurveys. diff -r d23d1dee5261 -r 525c65b0a320 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