def get(self): #This function clones ALL the Learning Units for a language - not just the ones for the current Topic Group if self.request.get('langCode'): langCode = self.request.get('langCode') q = LearningUnits.query(LearningUnits.LangCode == langCode) units = q.fetch(999) countmap_other_language={} for unit in units: logging.info('QQQ: LangCode in clone: %s' % unit.LangCode) if unit.LearningUnitID not in countmap_other_language: logging.info('QQQ: LearningUnitID in clone: %s' % unit.LearningUnitID) countmap_other_language[unit.LearningUnitID] = 1 q = LearningUnits.query(LearningUnits.LangCode == 'en') units_en = q.fetch(999) for unit2 in units_en: if unit2.LearningUnitID not in countmap_other_language: logging.info('QQQ: LearningUnitID to add in clone: %s' % unit2.LearningUnitID) logging.info('QQQ: LangCode to add in clone: %s' % langCode) n = LearningUnits(LearningUnitID = unit2.LearningUnitID , Subject = unit2.Subject , Name = unit2.Name , LangCode = langCode , Seq = unit2.Seq , Description = unit2.Description , TemplateName = unit2.TemplateName , Status = 'Pending Translation' ) n.put() return self.redirect('/units') else: return self.redirect('/units')
def post(self): #logging.error('QQQ: templatecreate POST') n = LearningUnits(LearningUnitID = self.request.get('Name') , Subject=self.request.get('Subject') , Name = self.request.get('Name') , LangCode = 'en' , Description=self.request.get('Description') , Status = 'Pending Review' ) n.put() return self.redirect('/units/create')