示例#1
0
 def create_variation(self, var_obj, section):
     print "    Building variation %s" % var_obj.title.text
     var = GwoVariation(
         gwo_experiment=section.gwo_experiment,
         gwo_section=section,
         title=getattr(var_obj.title, 'text', ''),
         variation_id=getattr(var_obj.variation_id, 'text', ''),
         content=getattr(var_obj.content, 'text', ''),
     )
     var.save(local_only=True)
示例#2
0
 def sync_variation(self, var_obj, section):
     try:
         var = GwoVariation.objects.get(
             gwo_experiment=section.gwo_experiment,
             gwo_section=section,
             variation_id=var_obj.variation_id.text
         )
         created = False
     except GwoVariation.DoesNotExist:
         var = GwoVariation(
             gwo_experiment=section.gwo_experiment,
             gwo_section=section,
             variation_id=var_obj.variation_id.text
         )
         created = True
     
     if created:
         print "    Building variation %s" % var_obj.title.text
     else:
         print "    Updating variation %s" % var_obj.title.text
     
     var.title = var_obj.title.text
     var.content = getattr(var_obj.content, 'text', '')
     var.save(local_only=True)