Fixed the TimelineConversionUpdate to also update the GSoCProgram.
authorLennard de Rijk <ljvderijk@gmail.com>
Sun, 18 Oct 2009 17:10:01 +0200
changeset 3025 1ffc7cd7309c
parent 3024 e21d0f9bcecd
child 3026 75ef22dc5a8a
Fixed the TimelineConversionUpdate to also update the GSoCProgram.
app/soc/tasks/updates/module_conversion.py
--- a/app/soc/tasks/updates/module_conversion.py	Sun Oct 18 17:00:37 2009 +0200
+++ b/app/soc/tasks/updates/module_conversion.py	Sun Oct 18 17:10:01 2009 +0200
@@ -536,6 +536,8 @@
 def runTimelineConversionUpdate(request, entities, context, *args, **kwargs):
   """AppEngine Task that converts Timelines into GSoCTimelines.
 
+  It also updates all GSoCPrograms with a reference to the new GSoCTimeline.
+
   Args:
     request: Django Request object
     entities: list of Timeline entities to convert
@@ -549,8 +551,9 @@
   timeline_model = timeline_logic.getModel()
   timeline_properties = timeline_model.properties().keys()
 
-  # use this to store all the new GSoCTimelines
-  gsoc_timeline = []
+  # use this to store all the new GSoCTimelines and GSoCPrograms
+  gsoc_timelines = []
+  gsoc_programs = []
 
   for entity in entities:
     gsoc_properties = {}
@@ -559,7 +562,7 @@
       # copy over all the information from the timeline entity
       gsoc_properties[timeline_property] = getattr(entity, timeline_property)
 
-    gsoc_program = program_logic.getFromKeyName(entity.scope.key().id_or_name())
+    gsoc_program = program_logic.getFromKeyName(entity.key().id_or_name())
     gsoc_properties['scope'] = gsoc_program
 
     # create the new GSoCTimeline entity and prepare it to be stored
@@ -567,8 +570,13 @@
                                         **gsoc_properties)
     gsoc_timelines.append(gsoc_timeline_entity)
 
-  # store all the new GSoCPrograms
+    # set the timeline for the GSoCProgram entity and prepare it for storage
+    gsoc_program.timeline = gsoc_timeline_entity
+    gsoc_programs.append(gsoc_program)
+
+  # store all the new GSoCTimelines and GSoCPrograms
   db.put(gsoc_timelines)
+  db.put(gsoc_programs)
 
   # task completed, return
   return