Module Conversion also changes the RankerRoots associated with an Organization.
authorLennard de Rijk <ljvderijk@gmail.com>
Mon, 26 Oct 2009 15:38:13 -0700
changeset 3063 0b69dd9a5252
parent 3062 4b5a7e5746a0
child 3064 bc1eecbd1a7c
Module Conversion also changes the RankerRoots associated with an Organization.
app/soc/tasks/updates/module_conversion.py
--- a/app/soc/tasks/updates/module_conversion.py	Mon Oct 26 10:25:01 2009 -0700
+++ b/app/soc/tasks/updates/module_conversion.py	Mon Oct 26 15:38:13 2009 -0700
@@ -108,12 +108,16 @@
 def runOrgConversionUpdate(request, entities, context, *args, **kwargs):
   """AppEngine Task that converts Organizations into GSoCOrganizations.
 
+  Also updates the RankerRoots that are associated with the Organization.
+
   Args:
     request: Django Request object
     entities: list of Organization entities to convert
     context: the context of this task
   """
 
+  from soc.logic.models.ranker_root import logic as ranker_root_logic
+
   from soc.modules.gsoc.logic.models.program import logic as gsoc_program_logic
   from soc.modules.gsoc.models.organization import GSoCOrganization
 
@@ -123,6 +127,7 @@
 
   # use this to store all the new GSoCOrganization
   gsoc_orgs = []
+  gsoc_rankers = []
 
   for entity in entities:
     gsoc_properties = {}
@@ -142,8 +147,19 @@
                                        **gsoc_properties)
     gsoc_orgs.append(gsoc_org_entity)
 
+    # retrieve the RankerRoots belonging to the Organization
+    fields = {'scope': entity}
+    rankers = ranker_root_logic.getForFields(fields)
+
+    for ranker in rankers:
+      ranker.scope = gsoc_org_entity
+      # append the adjusted ranker
+      gsoc_rankers.append(ranker)
+
   # store all the new GSoCOrganizations
   db.put(gsoc_orgs)
+  # store all the new rankers
+  db.put(gsoc_rankers)
 
   # task completed, return
   return