def get(self): if self.request.get("langCode"): langCode = self.request.get("langCode") q = TopicGrps.query(TopicGrps.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 = TopicGrps.query(TopicGrps.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 = TopicGrps( LearningUnitID=unit2.LearningUnitID, Subject=unit2.Subject, Seq=unit2.Seq, Name=unit2.Name, LangCode=langCode, Description=unit2.Description, Status="Pending Translation", ) n.put() return self.redirect("/topgrps") else: return self.redirect("/topgrps")
def post(self): # logging.error('QQQ: templatecreate POST') Subject = self.request.get("Subject") n = TopicGrps( LearningUnitID=self.request.get("Name"), Subject=Subject, Name=self.request.get("Name"), Seq=999, LangCode="en", Description=self.request.get("Description"), Status="Pending Review", ) n.put() logging.info("PPP - Preparing to delete TopGrp_units from memcache.") memcache.delete("TopGrps_En") memcache.delete("TopGrp_EnCnt") return self.redirect("/topgrps/create?SubjFilter=" + Subject)
def get(self, unit_id): iden = int(unit_id) unit = ndb.Key("TopicGrps", iden).get() f = TopicGrps.query(TopicGrps.LangCode == "en", TopicGrps.LearningUnitID == unit.LearningUnitID) units_en = f.get() if self.request.get("SubjFilter"): SubjFilter = self.request.get("SubjFilter") self.session["SubjFilter"] = SubjFilter else: SubjFilter = self.session.get("SubjFilter") if not SubjFilter: self.session["SubjFilter"] = "all" SubjFilter = "all" logging.info("QQQ: SubjFilter in Topic Grp Edit: %s" % SubjFilter) if self.request.get("SubjAreaFilter"): SubjAreaFilter = self.request.get("SubjAreaFilter") self.session["SubjAreaFilter"] = SubjAreaFilter else: SubjAreaFilter = self.session.get("SubjAreaFilter") if not SubjAreaFilter: self.session["SubjAreaFilter"] = "Math" SubjAreaFilter = "Math" q3 = Subjects.query(Subjects.Subject == SubjAreaFilter).order(Subjects.Seq) subjects = q3.fetch(999) SubjectList = [] if subjects: for subject in subjects: SubjectList.append(subject.Name) else: SubjectList.append("none") logout = None login = None currentuser = users.get_current_user() if currentuser: logout = users.create_logout_url("/topgrps") else: login = users.create_login_url("/topgrps") # SubjectList = ['Math', 'Biology', 'Chemistry']; StatusList = ["Pending Translation", "Pending Review", "Published"] self.render_template( "LearnTopicGrpEdit.html", { "unit": unit, "units_en": units_en, "SubjectList": SubjectList, "SubjFilter": SubjFilter, "StatusList": StatusList, "currentuser": currentuser, "login": login, "logout": logout, }, )
def get(self): logout = None login = None currentuser = users.get_current_user() if currentuser: logout = users.create_logout_url('/units' ) else: login = users.create_login_url('/units') if self.request.get('SubjFilter'): SubjFilter=self.request.get('SubjFilter') self.session['SubjFilter'] = SubjFilter else: SubjFilter = self.session.get('SubjFilter') if not SubjFilter: self.session['SubjFilter'] = 'all' SubjFilter = 'all' logging.info('QQQ: SubjFilter in Topic Grp Edit: %s' % SubjFilter) if self.request.get('TopGrpFilter'): TopGrpFilter=self.request.get('TopGrpFilter') self.session['TopGrpFilter'] = TopGrpFilter else: TopGrpFilter = self.session.get('TopGrpFilter') if not TopGrpFilter: self.session['TopGrpFilter'] = 'all' TopGrpFilter = 'all' logging.info('QQQ: SubjFilter in Topic Grp Edit: %s' % SubjFilter) q3 = TopicGrps.query(TopicGrps.Subject == SubjFilter).order(TopicGrps.Seq) subjects = q3.fetch(999) SubjectList = [] TknGrpCnt = 0 if subjects: for subject in subjects: TknGrpCnt = TknGrpCnt + 1 logging.info('QQQ: TopicGrpList in Topic Grp List Build: %s' % subject.Name) SubjectList.append(subject.Name) else: SubjectList.append('none') logging.info('QQQ: TknGrpCnt in Topic Grp List Build: %d' % TknGrpCnt) # SubjectList = ['Math', 'Biology', 'Chemistry']; self.render_template('LearnUnitCreate.html', {'SubjectList': SubjectList, 'TopGrpFilter': TopGrpFilter, 'currentuser':currentuser, 'login':login, 'logout': logout})
def get(self, unit_id): iden = int(unit_id) unit = ndb.Key('LearningUnits', iden).get() f = LearningUnits.query(LearningUnits.LangCode == 'en', LearningUnits.LearningUnitID == unit.LearningUnitID) units_en = f.get() if self.request.get('SubjFilter'): SubjFilter=self.request.get('SubjFilter') self.session['SubjFilter'] = SubjFilter else: SubjFilter = self.session.get('SubjFilter') if not SubjFilter: self.session['SubjFilter'] = 'all' SubjFilter = 'all' logging.info('QQQ: SubjFilter in Topic Grp Edit: %s' % SubjFilter) q3 = TopicGrps.query(TopicGrps.Subject == SubjFilter).order(TopicGrps.Seq) subjects = q3.fetch(999) SubjectList = [] if subjects: for subject in subjects: SubjectList.append(subject.Name) else: SubjectList.append('none') logout = None login = None currentuser = users.get_current_user() if currentuser: logout = users.create_logout_url('/units' ) else: login = users.create_login_url('/units') # SubjectList = ['Math', 'Biology', 'Chemistry']; StatusList = ['Pending Translation', 'Pending Review', 'Published']; self.render_template('LearnUnitEdit.html', {'unit': unit, 'units_en': units_en, 'SubjectList': SubjectList, 'StatusList': StatusList, 'currentuser':currentuser, 'login':login, 'logout': logout})
def get(self): languages = memcache.get("languages") if languages is not None: logging.info("get languages from memcache.") else: q = Languages.query().order(Languages.langName) languages = q.fetch(99) logging.info("Can not get languages from memcache.") if not memcache.add("languages", languages, 10): logging.info("Memcache set failed.") if self.request.get('langCode'): langCode=self.request.get('langCode') self.session['langCode'] = langCode else: langCode = self.session.get('langCode') if not langCode: self.session['langCode'] = 'en' langCode = 'en' langName = 'no language' for language in languages: if language.langCode == langCode: langName = language.langName if self.request.get('StatusFilter'): StatusFilter=self.request.get('StatusFilter') self.session['StatusFilter'] = StatusFilter else: StatusFilter = self.session.get('StatusFilter') if not StatusFilter: self.session['StatusFilter'] = 'all' StatusFilter = 'all' # if self.request.get('SubjFilter'): # SubjFilter=self.request.get('SubjFilter') # self.session['SubjFilter'] = SubjFilter # else: # SubjFilter = self.session.get('SubjFilter') # if not SubjFilter: # self.session['SubjFilter'] = 'all' # SubjFilter = 'all' if self.request.get('TopGrpFilter'): TopGrpFilter=self.request.get('TopGrpFilter') self.session['TopGrpFilter'] = TopGrpFilter else: TopGrpFilter = self.session.get('TopGrpFilter') if not TopGrpFilter: self.session['TopGrpFilter'] = 'all' TopGrpFilter = 'all' TopGrpList = [] if langCode == 'en': q = TopicGrps.query(TopicGrps.LangCode == 'en').order(TopicGrps.Seq, TopicGrps.Name) SubjAreaResponseSet = q.fetch(999) for SubjArea in SubjAreaResponseSet: TopGrpList.append(SubjArea.Name) # count_en = 0 # langCode_en = 'en' # q = LearningUnits.query(LearningUnits.LangCode == langCode_en) # units = q.fetch(999) # for unit in units: # # logging.info('QQQ: count_en: %d' % count_en) # count_en = count_en + 1 # logging.info('QQQ: Total count_en: %d' % count_en) # logging.info('QQQ: langCode: %s' % langCode) # count_other_language = 0 # q2 = LearningUnits.query(LearningUnits.LangCode == langCode) # unitsx = q2.fetch(999) # for unit in unitsx: # # logging.info('QQQ: count_other_language: %d' % count_other_language) # count_other_language = count_other_language + 1 # logging.info('QQQ: Total count_other_language: %d' % count_other_language) # logging.info('LLL: StatusFilter in LearnUnitList: %s' % StatusFilter) # logging.info('LLL: TopGrpFilter in LearnUnitList: %s' % TopGrpFilter) # logging.info('LLL: langCode in LearnUnitList: %s' % langCode) #TopGrpFilter = 'all' #StatusFilter = 'all' if StatusFilter == 'all': if TopGrpFilter == 'all': logging.info('LLL: in LearnUnitList: now in all/all') q = LearningUnits.query(LearningUnits.LangCode == langCode).order(LearningUnits.Seq, LearningUnits.LearningUnitID) else: logging.info('LLL: in LearnUnitList: now in all/TopGrpFilter') q = LearningUnits.query(LearningUnits.LangCode == langCode, LearningUnits.Subject == TopGrpFilter).order(LearningUnits.Seq, LearningUnits.LearningUnitID) else: if TopGrpFilter == 'all': logging.info('LLL: in LearnUnitList: now in StatusFilter/all') q = LearningUnits.query(LearningUnits.LangCode == langCode, LearningUnits.Status == StatusFilter).order(LearningUnits.Seq, LearningUnits.LearningUnitID) else: logging.info('LLL: in LearnUnitList: now in StatusFilter/TopGrpFilter') q = LearningUnits.query(LearningUnits.LangCode == langCode, LearningUnits.Status == StatusFilter, LearningUnits.Subject == TopGrpFilter).order(LearningUnits.Seq, LearningUnits.LearningUnitID) # q = LearningUnits.query(LearningUnits.LangCode == langCode_en, LearningUnits.Subject == 'Math').order(LearningUnits.LearningUnitID) logging.info('LLL: q in LearnUnitList: %s' % q) units = q.fetch(999) dict_units_en = self.session.get('listEditUnits_en') if not dict_units_en: f = LearningUnits.query(LearningUnits.LangCode == 'en') units_en = f.fetch(999) dict_units_en = {} for unit_en in units_en: # logging.info('GGG: Subjects.py/LearningUnitID: %s' % unit_en.LearningUnitID) # logging.info('GGG: Subjects.py/Description: %s' % unit_en.Description) dict_units_en[unit_en.LearningUnitID] = unit_en.Description self.session['listEditUnits_en'] = dict_units_en # if StatusFilter == 'all': # if TopGrpFilter == 'all': # f = LearningUnits.query(LearningUnits.LangCode == 'en') # else: # f = LearningUnits.query(LearningUnits.LangCode == 'en', LearningUnits.Subject == TopGrpFilter) # else: # if TopGrpFilter == 'all': # f = LearningUnits.query(LearningUnits.LangCode == 'en', LearningUnits.Status == StatusFilter) # else: # f = LearningUnits.query(LearningUnits.LangCode == 'en', LearningUnits.Status == StatusFilter, LearningUnits.Subject == TopGrpFilter) # units_en = f.fetch(999) # dict_units_en = {} # for unit_en in units_en: # # logging.info('GGG: Subjects.py/LearningUnitID: %s' % unit_en.LearningUnitID) # # logging.info('GGG: Subjects.py/Description: %s' % unit_en.Description) # dict_units_en[unit_en.LearningUnitID] = unit_en.Description # unitcnt = 0 # for uni in units: # logging.info('QQQ: uni.LearningUnitID in LearnUnitList: %s' % uni.LearningUnitID) # unitcnt = unitcnt + 1 # logging.info('QQQ: unitcnt in LearnUnitList: %d' % unitcnt) logout = None login = None currentuser = users.get_current_user() if currentuser: logout = users.create_logout_url('/units' ) else: login = users.create_login_url('/units') StatusList = ['Pending Translation', 'Pending Review', 'Published']; self.render_template('LearnUnitListEdit.html', {'units': units, 'TopGrpList':TopGrpList, 'StatusList':StatusList, 'StatusFilter':StatusFilter, 'TopGrpFilter':TopGrpFilter, 'dict_units_en':dict_units_en, 'languages':languages, 'langCode':langCode, 'langName':langName, 'currentuser':currentuser, 'login':login, 'logout': logout})
def get(self): languages = memcache.get("languages") if languages is not None: logging.info("get languages from memcache.") else: q = Languages.query().order(Languages.langName) languages = q.fetch(99) logging.info("Can not get languages from memcache.") if not memcache.add("languages", languages, 10): logging.info("Memcache set failed.") if self.request.get("langCode"): langCode = self.request.get("langCode") self.session["langCode"] = langCode else: langCode = self.session.get("langCode") if not langCode: self.session["langCode"] = "en" langCode = "en" langName = "no language" for language in languages: if language.langCode == langCode: langName = language.langName if self.request.get("Typ"): Typ = self.request.get("Typ") self.session["Typ"] = Typ else: Typ = self.session.get("Typ") if not Typ: self.session["Typ"] = "ex" Typ = "ex" if self.request.get("StatusFilter"): StatusFilter = self.request.get("StatusFilter") self.session["StatusFilter"] = StatusFilter else: StatusFilter = self.session.get("StatusFilter") if not StatusFilter: self.session["StatusFilter"] = "all" StatusFilter = "all" if self.request.get("SubjFilter"): SubjFilter = self.request.get("SubjFilter") self.session["SubjFilter"] = SubjFilter else: SubjFilter = self.session.get("SubjFilter") if not SubjFilter: self.session["SubjFilter"] = "all" SubjFilter = "all" Cnt = memcache.get("TopGrp_EnCnt") if Cnt is not None: logging.info("PPP - got TopGrp_EnCnt from memcache.") count_en = Cnt else: logging.info("PPP - Could not get TopGrp_EnCnt from memcache.") count_en = 0 langCode_en = "en" units = memcache.get("TopGrps_En") if units is not None: logging.info("PPP - got TopGrps_En from memcache.") else: logging.info("PPP - Can not get TopGrps_En_units from memcache.") q = TopicGrps.query(TopicGrps.LangCode == langCode_en) units = q.fetch(999, keys_only=True) if not memcache.add("TopGrps_En", units, 999): logging.info("PPP - TopGrps_En_Memcache set failed.") for unit in units: # logging.info('QQQ: count_en: %d' % count_en) count_en = count_en + 1 if not memcache.add("TopGrp_EnCnt", count_en, 999): logging.info("PPP - TopGrp_EnCnt_Memcache set failed.") logging.info("QQQ: Total count_en: %d" % count_en) # count_en = 0 # langCode_en = 'en' # q = TopicGrps.query(TopicGrps.LangCode == langCode_en) # units = q.fetch(999) # for unit in units: # logging.info('QQQ: count_en: %d' % count_en) # count_en = count_en + 1 # logging.info('QQQ: Total count_en: %d' % count_en) logging.info("QQQ: langCode: %s" % langCode) count_other_language = 0 q2 = TopicGrps.query(TopicGrps.LangCode == langCode) unitsx = q2.fetch(999, keys_only=True) for unit in unitsx: logging.info("QQQ: count_other_language: %d" % count_other_language) count_other_language = count_other_language + 1 logging.info("QQQ: Total count_other_language: %d" % count_other_language) logging.info("GGG: StatusFilter in LearnUnitList: %s" % StatusFilter) if StatusFilter == "all": if SubjFilter == "all": q = TopicGrps.query(TopicGrps.LangCode == langCode).order(TopicGrps.Seq, TopicGrps.LearningUnitID) else: q = TopicGrps.query(TopicGrps.LangCode == langCode, TopicGrps.Subject == SubjFilter).order( TopicGrps.Seq, TopicGrps.LearningUnitID ) else: if SubjFilter == "all": q = TopicGrps.query(TopicGrps.LangCode == langCode, TopicGrps.Status == StatusFilter).order( TopicGrps.Seq, TopicGrps.LearningUnitID ) else: q = TopicGrps.query( TopicGrps.LangCode == langCode, TopicGrps.Status == StatusFilter, TopicGrps.Subject == SubjFilter ).order(TopicGrps.Seq, TopicGrps.LearningUnitID) units = q.fetch(999) q4 = Subjects.query(Subjects.LangCode == langCode, Subjects.Subject == SubjFilter).order(Subjects.Seq) subjects = q4.fetch(999) SubjectList = [] if subjects: for subject in subjects: SubjectList.append(subject.Name) else: SubjectList.append("none") logout = None login = None currentuser = users.get_current_user() if currentuser: logout = users.create_logout_url("/topgrps") else: login = users.create_login_url("/topgrps") StatusList = ["Pending Translation", "Pending Review", "Published"] # SubjectList = ['Math', 'Science']; self.render_template( "LearnTopicGrpList.html", { "units": units, "count_en": count_en, "count_other_language": count_other_language, "StatusList": StatusList, "SubjectList": SubjectList, "StatusFilter": StatusFilter, "Typ": Typ, "SubjFilter": SubjFilter, "languages": languages, "langCode": langCode, "langName": langName, "currentuser": currentuser, "login": login, "logout": logout, }, )