Esempio n. 1
0
    def get(self):
        Dup = False
        if self.request.get('msg') == 'dup':
            Dup = True
        tknID = self.request.get('tknID')
        templateName = self.request.get('tName')

        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'

        langName = 'no language'
        for language in languages:
            if language.langCode == langCode:
                langName = language.langName

        q = Languages.query().order(Languages.langCode, Languages.langName)
        languages = q.fetch(999)

        langName = 'no language'
        for language in languages:
            if language.langCode == langCode:
                langName = language.langName

        q = Templates.query().order(Templates.Name)
        templates = q.fetch(99)

        if self.request.get('extyp'):
            extyp=self.request.get('extyp')
            self.session['extyp'] = extyp
        else:
            extyp = self.session.get('extyp')
        if not extyp:
            self.session['extyp'] = 'exercise'

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/tokens' )
        else:
              login = users.create_login_url('/tokens/create')
        Src = 'template'	  
        StatusList = ['Pending Translation', 'Pending Review', 'Published'];		  
        self.render_template('TokenCreate.html', {'templates': templates, 'Src': Src, 'extyp':extyp, 'templateName': templateName, 'Dup': Dup, 'tknID': tknID, 'StatusList': StatusList, 'languages':languages, 'langCode':langCode, 'langName':langName, 'currentuser':currentuser, 'login':login, 'logout': logout})
Esempio n. 2
0
    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, 99):
                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'

        y = 'hi there'
        TestVal1 = '' + Test1(y)
        logging.info('GGG: Test if function calls: %s' % TestVal1)

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/subjs' )
        else:
              login = users.create_login_url('/subjs')
		  
        self.render_template('Test1.html', {'TestVal1':TestVal1, 'currentuser':currentuser, 'login':login, 'logout': logout})
Esempio n. 3
0
 def get(self):
     languages = Languages.query().order(Languages.langName)
     logout = None
     login = None
     currentuser = users.get_current_user()
     if currentuser:
         logout = users.create_logout_url("/langs")
     else:
         login = users.create_login_url("/langs/create")
     self.render_template(
         "LangList.html", {"languages": languages, "currentuser": currentuser, "login": login, "logout": logout}
     )
Esempio n. 4
0
    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'

        SubjAreaFilter = self.session.get('SubjAreaFilter')
        if not SubjAreaFilter:
            self.session['SubjAreaFilter'] = 'Math'
            SubjAreaFilter = 'Math'

        SubjAreaList = []
        q = SubjectAreas.query(SubjectAreas.LangCode == langCode).order(SubjectAreas.Seq)
        SubjAreaResponseSet = q.fetch(999)
        for SubjArea in SubjAreaResponseSet:
            SubjAreaList.append(SubjArea.Name)

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/subjs' )
        else:
              login = users.create_login_url('/subjs')

#        SubjectList = ['Math', 'Biology', 'Chemistry'];		  
        self.render_template('LearnSubjCreate.html', {'SubjectList': SubjAreaList, 'SubjAreaFilter': SubjAreaFilter, 'currentuser':currentuser, 'login':login, 'logout': logout})
Esempio n. 5
0
    def get(self):
        languages = memcache.get("languages")
        if languages is not None:
           logging.info("get languages from memcache.")
        else:
           languages = Languages.query()
           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'

        LangName = 'no language'
        for language in languages:
            if language.langCode == langCode:
                langName = language.langName

        pagecontents = PageContents.query()

        NoContent = True
        if pagecontents:
		    NoContent = False
 
        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/pagecontents' )
        else:
              login = users.create_login_url('/pagecontents/create')
        self.render_template('PageContentList.html', {'pagecontents': pagecontents, 'NoContent': NoContent, 'currentuser':currentuser, 'login':login, 'logout': logout})
Esempio n. 6
0
    def get(self):
#        TopicSeqRecalc()
        
        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, 99):
                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('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'

        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'

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/units' )
        else:
              login = users.create_login_url('/units')

        SubjAreaList = []
        q = SubjectAreas.query(SubjectAreas.LangCode == langCode)
        SubjAreaResponseSet = q.fetch(999)
        for SubjArea in SubjAreaResponseSet:
            SubjAreaList.append(SubjArea.Name)
        StatusList = ['Pending Translation', 'Pending Review', 'Published'];
#        SubjAreaList = ['Math', 'Science'];	
        logging.info('QQQ: rq rq rq: %s' % self.request.get('rq'))
#        if self.request.get('rq') == '2':

        Cnt = memcache.get("Subj_EnCnt")
        if Cnt is not None:
            logging.info("PPP - got Subj_EnCnt from memcache.")
            count_en = Cnt
        else:
            logging.info("PPP - Could not get Subjs_EnCnt from memcache.")
            count_en = 0
            langCode_en = 'en'
            units = memcache.get("Subjs_En")
            if units is not None:
                logging.info("PPP - got Subjs_En_units from memcache.")
            else:
                # logging.info("PPP - Can not get SubjAreas_units from memcache.")
                q = Subjects.query(Subjects.LangCode == langCode_en)
                units = q.fetch(999, keys_only=True)
                if not memcache.add("Subjs_En", units, 999):
                    logging.info("PPP - Subjs_EnCnt_Memcache set failed.")
            for unit in units:
#                logging.info('QQQ: count_en: %d' % count_en)
                count_en = count_en + 1
            if not memcache.add("Subj_EnCnt", count_en, 999):
                    logging.info("PPP - Subj_EnCnt_Memcache set failed.")
        logging.info('QQQ: Total count_en: %d' % count_en)

        # count_en = 0
        # langCode_en = 'en'
        # q = Subjects.query(Subjects.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 = Subjects.query(Subjects.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)
        logging.info('GGG: SubjAreaFilter in LearnUnitList: %s' % SubjAreaFilter)
        if SubjAreaFilter == 'all':
            if StatusFilter == 'all':
                logging.info('GGG: Which Query in LearnUnitList: %s' % 'all and all')
                logging.info('GGG: LangCode in LearnUnitList: %s' % langCode)
                q = Subjects.query(Subjects.LangCode == langCode).order(Subjects.Seq, Subjects.LearningUnitID)
            else:
                logging.info('GGG: Which Query in LearnUnitList: %s' % 'all and StatusFilter')
                logging.info('GGG: LangCode in LearnUnitList: %s' % langCode)
                logging.info('GGG: StatusFilter in LearnUnitList: %s' % StatusFilter)
                q = Subjects.query(Subjects.LangCode == langCode, Subjects.Status == StatusFilter).order(Subjects.Seq, Subjects.LearningUnitID)
        else:
            if StatusFilter == 'all':
                logging.info('GGG: Which Query in LearnUnitList: %s' % 'SubjAreaFilter and all')
                logging.info('GGG: LangCode in LearnUnitList: %s' % langCode)
                logging.info('GGG: SubjAreaFilter in LearnUnitList: %s' % SubjAreaFilter)
                q = Subjects.query(Subjects.LangCode == langCode, Subjects.Subject == SubjAreaFilter).order(Subjects.Seq, Subjects.LearningUnitID)
            else:
                logging.info('GGG: Which Query in LearnUnitList: %s' % 'SubjAreaFilter and StatusFilter')
                logging.info('GGG: LangCode in LearnUnitList: %s' % langCode)
                logging.info('GGG: SubjAreaFilter in LearnUnitList: %s' % SubjAreaFilter)
                logging.info('GGG: StatusFilter in LearnUnitList: %s' % StatusFilter)
                q = Subjects.query(Subjects.LangCode == langCode, Subjects.Subject == SubjAreaFilter, Subjects.Status == StatusFilter).order(Subjects.Seq, Subjects.LearningUnitID)

        units = q.fetch(999)
    #    self.render_template('LearnSubjList.html', {'units': units, 'count_en': count_en, 'count_other_language': count_other_language, 'StatusList':StatusList, 'StatusFilter':StatusFilter, 'SubjAreaFilter':SubjAreaFilter, 'SubjAreaList':SubjAreaList, 'languages':languages, 'langCode':langCode, 'langName':langName, 'currentuser':currentuser, 'login':login, 'logout': logout})

#        else:
#            units = []
#            count_en = 0
#            count_other_language = 0
        self.render_template('LearnSubjList.html', {'units': units, 'count_en': count_en, 'count_other_language': count_other_language, 'StatusList':StatusList, 'StatusFilter':StatusFilter, 'SubjAreaFilter':SubjAreaFilter, 'Typ':Typ, 'SubjAreaList':SubjAreaList, 'languages':languages, 'langCode':langCode, 'langName':langName, 'currentuser':currentuser, 'login':login, 'logout': logout})
Esempio n. 7
0
    def get(self):
        languages = Languages.query()

        countmap_other_language={}
#		templateName2 = 'khan-exercise'	 and 'templateName', templateName2
        langCode2 = ''
        if self.request.get('langCode'):
            langCode2=self.request.get('langCode')
        if langCode2 == 'en':
            langCode2 = 'xx'
        if self.request.get('templateName'):
            templateName2=self.request.get('templateName')
        else:
            templateName2='none'
        if langCode2 != 'en': 
            logging.info('GGG: langCode_just_B4_Query1_NotEN: %s' % langCode2)
            logging.info('GGG: templateName_just_B4_Query1_NotEN: %s' % templateName2)
            q = TokenValues.query(TokenValues.langCode == langCode2, TokenValues.templateName == templateName2).order(TokenValues.langCode, TokenValues.templateName)
#		q = db.GqlQuery("SELECT * FROM TokenValues " + 
#                "WHERE langCode = :1 AND templateName = :2 " +
#                "ORDER BY tknID ASC",
#                langCode2, templateName2)
            tokens = q.fetch(999)		
#            tokens = TokenValues().all().filter('langCode =', langCode2)
            for token in tokens:
                logging.info('QQQ: token: %s' % token.langCode)
                if token.tknID not in countmap_other_language:
                        countmap_other_language[token.tknID]=1

        langCode='en'
        logging.info('GGG: langCode_just_B4_Query2_EN: %s' % langCode)
        logging.info('GGG: templateName_just_B4_Query2_EN: %s' % templateName2)
        q = TokenValues.query(TokenValues.langCode == langCode, TokenValues.templateName == templateName2).order(TokenValues.langCode, TokenValues.templateName)
#        q = db.GqlQuery("SELECT * FROM TokenValues " + 
#            "WHERE langCode = :1 AND templateName = :2 " +
#            "ORDER BY tknID ASC",
#            langCode, templateName2)
        tokens = q.fetch(999)
#        tokens = TokenValues.all().filter('langCode =', langCode)

        if self.request.get('extyp'):
            extyp=self.request.get('extyp')
            self.session['extyp'] = extyp
        else:
            extyp = self.session.get('extyp')
        if not extyp:
            self.session['extyp'] = 'exercise'

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/tokens' )
        else:
              login = users.create_login_url('/tokens/create')

        if langCode2 == 'xx':
            if extyp == 'exercise':
                return self.redirect('/tokens')
            else:
                return self.redirect('/tokens-step1')

#        self.render_template('TokenStep1.html', {'languages':languages, 'langCode':langCode, 'countmap_other_language':countmap_other_language, 'tokens': tokens,'currentuser':currentuser, 'login':login, 'logout': logout})
        else:		
            for token in tokens:
                if token.tknID not in countmap_other_language:
                    n = TokenValues(templateName=token.templateName
                        , langCode=self.request.get('langCode')
                        , tknID=token.tknID
                        , tknValue=token.tknValue
                        , tknValue2=token.tknValue2
                        )
                    n.put()
            if extyp == 'exercise':
                return self.redirect('/tokens')
            else:
                return self.redirect('/tokens-step1')
Esempio n. 8
0
    def get(self):
        #languages = Languages.all()
        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'

        langName = 'no language'
        for language in languages:
            if language.langCode == langCode:
                langName = language.langName

        PageCnt = self.session.get('PageCnt', 0)
        self.session['PageCnt'] = PageCnt + 1

        countmap_en={}
        langCode_en = 'en'
        q = TokenValues.query(TokenValues.langCode == langCode_en).order(TokenValues.langCode, TokenValues.tknID)
        tokens = q.fetch(999)
#        tokens = TokenValues.all().filter('langCode =', langCode_en)
        for token in tokens:
#            logging.info('QQQ: token_en: %s' % token.langCode)
            if token.templateName in countmap_en:
                    countmap_en[token.templateName]=countmap_en[token.templateName]+1
            else:
                    countmap_en[token.templateName]=1

        countmap_other_language={}
        if langCode != 'en':    
            q = TokenValues.query(TokenValues.langCode == langCode).order(TokenValues.langCode, TokenValues.tknID)
            tokens = q.fetch(999)
#		tokens = TokenValues().all().filter('langCode =', langCode)
            for token in tokens:
#                logging.info('QQQ: token_non-EN: %s' % token.langCode)
                if token.templateName in countmap_other_language:
                        countmap_other_language[token.templateName]=countmap_other_language[token.templateName]+1
                else:
                        countmap_other_language[token.templateName]=1

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/tokens' )
        else:
              login = users.create_login_url('/tokens')

        self.render_template('TokenStep1.html', {'PageCnt':PageCnt, 'languages':languages, 'langCode':langCode, 'langName':langName, 'countmap_en':countmap_en, 'countmap_other_language':countmap_other_language, 'tokens': tokens,'currentuser':currentuser, 'login':login, 'logout': logout})
Esempio n. 9
0
    def get(self):
        #langCode='en'

        if self.request.get('langCode'):
            langCode=self.request.get('langCode')
            self.session['langCode'] = langCode
        else:
            langCode = self.session.get('langCode')

        if self.request.get('templateName'):
            templateName=self.request.get('templateName')
            self.session['templateName'] = templateName
        else:
            templateName = self.session.get('templateName')

        if self.request.get('extyp'):
            extyp=self.request.get('extyp')
            self.session['extyp'] = extyp
        else:
            extyp = self.session.get('extyp')
        if not extyp:
            self.session['extyp'] = 'exercise'

        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('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'

        countmap_en=0
        langCode_en = 'en'
        q = TokenValues.query(TokenValues.langCode == langCode_en, TokenValues.templateName == templateName).order(TokenValues.langCode, TokenValues.tknID)
        tokens = q.fetch(999, keys_only=True)
#        tokens = TokenValues.all().filter('langCode =', langCode_en)
        for token in tokens:
#            logging.info('QQQ: token_en: %s' % token.langCode)
            countmap_en=countmap_en+1

        countmap_other_language=0
        if langCode != 'en':    
            q = TokenValues.query(TokenValues.langCode == langCode, TokenValues.templateName == templateName).order(TokenValues.langCode, TokenValues.tknID)
            tokens = q.fetch(999, keys_only=True)
#		tokens = TokenValues().all().filter('langCode =', langCode)
            for token in tokens:
#                logging.info('QQQ: token_non-EN: %s' % token.langCode)
                countmap_other_language=countmap_other_language+1

#        languages = Languages.all().filter('langCode =', langCode)
        q = Languages.query().order(Languages.langName)
        languages = q.fetch(999)

        langName = 'no language'
        for language in languages:
            if language.langCode == langCode:
                langName = language.langName

        q = TokenValues.query(TokenValues.langCode == langCode, TokenValues.templateName == templateName, TokenValues.Status != 'Published')
        TokensNotReady = q.get()

        if TokensNotReady:
            TemplateGenReady = False
        else:        
            TemplateGenReady = True
        
        q = GeneratedFiles.query(GeneratedFiles.LangCode == langCode, GeneratedFiles.TemplateName == templateName).order(-GeneratedFiles.CreatedDate)
        GenFile = q.get()

        if GenFile:
            GenFileReady = GenFile.key.id()
            SearchName = GenFile.SearchName
        else:        
            GenFileReady = None
            SearchName = None

        logging.info('GGG: StatusFilter in TokenList: %s' % StatusFilter)
        if StatusFilter == 'all':
            q = TokenValues.query(TokenValues.langCode == langCode, TokenValues.templateName == templateName).order(TokenValues.langCode, TokenValues.templateName, TokenValues.tknID)
        else:
            q = TokenValues.query(TokenValues.langCode == langCode, TokenValues.templateName == templateName, TokenValues.Status == StatusFilter).order(TokenValues.langCode, TokenValues.templateName, TokenValues.tknID)
        tokens = q.fetch(999)

        if StatusFilter == 'all':
            f = TokenValues.query(TokenValues.langCode == 'en', TokenValues.templateName == templateName)
        else:
            f = TokenValues.query(Subjects.LangCode == 'en', TokenValues.templateName == templateName, TokenValues.Status == StatusFilter)

        units_en = f.fetch(999)
        
        dict_units_en = {}
        dict_units_en['DummyTemplate'] = 'no content'
        dict_Context_en = {}
        dict_Context_en['DummyTemplate'] = 'no content'
        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)
#            if unit_en.Context:
#                dict_units_en[unit_en.tknID] = unit_en.tknValue + ' in (' + unit_en.Context + ')'
#            else:
#                dict_units_en[unit_en.tknID] = unit_en.tknValue
            dict_units_en[unit_en.tknID] = unit_en.tknValue
            dict_Context_en[unit_en.tknID] = unit_en.Context

        TryReady = False
        if GenFile:
            GenFileReady = GenFile.key.id()
            SearchName = GenFile.SearchName
            q2 = Templates.query(Templates.Name == GenFile.TemplateName)
            GenFileTemplate = q2.get()
            if GenFileTemplate.TemplateType == 'exercise':
                TryReady = True
            else:
                TryReady = False
        else:        
            GenFileReady = None
            SearchName = None
            TryReady = False
        logging.info('GGG: Token.py/TryReady: %s' % TryReady)

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/tokens' )
        else:
              login = users.create_login_url('/tokens')

        StatusList = ['Pending Translation', 'Pending Review', 'Published'];

        self.render_template('TokenListEdit.html', {'tokens': tokens, 'langName':langName, 'extyp':extyp, 'count_en':countmap_en, 'count_other_language':countmap_other_language, 'StatusList':StatusList, 'StatusFilter':StatusFilter, 'TopGrpFilter':TopGrpFilter, 'templateName':templateName, 'dict_units_en':dict_units_en, 'dict_Context_en':dict_Context_en, 'languages':languages, 'langCode':langCode, 'SearchName':SearchName, 'TryReady':TryReady, 'GenFileReady':GenFileReady, 'TemplateGenReady':TemplateGenReady, 'currentuser':currentuser, 'login':login, 'logout': logout})
Esempio n. 10
0
    def get(self):
#        AidSubjRecalc()
        AidSeqPop()
#        AidSeqRecalc()
        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('TopAreaFilter'):
            TopAreaFilter=self.request.get('TopAreaFilter')
            self.session['TopAreaFilter'] = TopAreaFilter
        else:
            TopAreaFilter = self.session.get('TopAreaFilter')
        if not TopAreaFilter:
            self.session['TopAreaFilter'] = 'all'
            TopAreaFilter = 'all'

        count_en = 0
        langCode_en = 'en'
        q = LearnAids.query(LearnAids.LangCode == langCode_en)
        aids = q.fetch(999)
        for aid in aids:
            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 = LearnAids.query(LearnAids.LangCode == langCode)
        aidsx = q2.fetch(999)
        for aid in aidsx:
            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 LearnAidList: %s' % StatusFilter)
        if StatusFilter == 'all':
            if TopAreaFilter == 'all':
                q = LearnAids.query(LearnAids.LangCode == langCode).order(LearnAids.Seq, LearnAids.LearnAidID)
            else:
                q = LearnAids.query(LearnAids.LangCode == langCode, LearnAids.Subject == TopAreaFilter).order(LearnAids.Seq, LearnAids.LearnAidID)
        else:
            if TopAreaFilter == 'all':
                q = LearnAids.query(LearnAids.LangCode == langCode, LearnAids.Status == StatusFilter).order(LearnAids.Seq, LearnAids.LearnAidID)
            else:
                q = LearnAids.query(LearnAids.LangCode == langCode, LearnAids.Status == StatusFilter, LearnAids.Subject == TopAreaFilter).order(LearnAids.Seq, LearnAids.LearnAidID)

        aids = q.fetch(999)

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/aids' )
        else:
              login = users.create_login_url('/aids')

        StatusList = ['Pending Translation', 'Pending Review', 'Published'];

        self.render_template('LearnAidList.html', {'aids': aids, 'count_en': count_en, 'count_other_language': count_other_language, 'StatusList':StatusList, 'StatusFilter':StatusFilter, 'SubjFilter':SubjFilter, 'TopAreaFilter':TopAreaFilter, 'languages':languages, 'langCode':langCode, 'langName':langName, 'currentuser':currentuser, 'login':login, 'logout': logout})
Esempio n. 11
0
      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'

        count_en = 0
        langCode_en = 'en'
        q = SubjectAreas.query(SubjectAreas.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 = SubjectAreas.query(SubjectAreas.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('GGG: StatusFilter in SubjAreasList: %s' % StatusFilter)
        if StatusFilter == 'all':
            q = SubjectAreas.query(SubjectAreas.LangCode == langCode).order(SubjectAreas.LearningUnitID)
        else:
            q = SubjectAreas.query(SubjectAreas.LangCode == langCode, SubjectAreas.Status == StatusFilter).order(SubjectAreas.LearningUnitID)
        units = q.fetch(999)

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/subjareas' )
        else:
              login = users.create_login_url('/subjareas')

        StatusList = ['Pending Translation', 'Pending Review', 'Published'];

        self.render_template('LearnSubjAreaList.html', {'units': units, 'count_en': count_en, 'count_other_language': count_other_language, 'StatusList':StatusList, 'StatusFilter':StatusFilter, 'languages':languages, 'langCode':langCode, 'langName':langName, 'currentuser':currentuser, 'login':login, 'logout': logout})
Esempio n. 12
0
    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'

        count_en = 0
        langCode_en = 'en'
        q = TopicAreas.query(TopicAreas.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 = TopicAreas.query(TopicAreas.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('GGG: StatusFilter in LearnUnitList: %s' % StatusFilter)
        if StatusFilter == 'all':
            if SubjFilter == 'all':
                q = TopicAreas.query(TopicAreas.LangCode == langCode).order(TopicAreas.Seq, TopicAreas.LearningUnitID)
            else:
                q = TopicAreas.query(TopicAreas.LangCode == langCode, TopicAreas.Subject == SubjFilter).order(TopicAreas.Seq, TopicAreas.LearningUnitID)
        else:
            if SubjFilter == 'all':
                q = TopicAreas.query(TopicAreas.LangCode == langCode, TopicAreas.Status == StatusFilter).order(TopicAreas.Seq, TopicAreas.LearningUnitID)
            else:
                q = TopicAreas.query(TopicAreas.LangCode == langCode, TopicAreas.Status == StatusFilter, TopicAreas.Subject == SubjFilter).order(TopicAreas.Seq, TopicAreas.LearningUnitID)
        units = q.fetch(999)

        if StatusFilter == 'all':
            if SubjFilter == 'all':
                f = TopicAreas.query(TopicAreas.LangCode == 'en')
            else:
                f = TopicAreas.query(TopicAreas.LangCode == 'en', TopicAreas.Subject == SubjFilter)
        else:
            if SubjFilter == 'all':
                f = TopicAreas.query(TopicAreas.LangCode == 'en', TopicAreas.Status == StatusFilter)
            else:
                f = TopicAreas.query(TopicAreas.LangCode == 'en', TopicAreas.Status == StatusFilter, TopicAreas.Subject == SubjFilter)
        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

        q4 = Subjects.query(Subjects.LangCode == langCode, Subjects.Subject == 'Math')
        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('/topareas' )
        else:
              login = users.create_login_url('/topareas')

        StatusList = ['Pending Translation', 'Pending Review', 'Published'];
#        SubjectList = ['Math', 'Science'];	
        self.render_template('LearnTopicAreaListEdit.html', {'units': units, 'count_en': count_en, 'count_other_language': count_other_language, 'StatusList':StatusList, 'SubjectList':SubjectList, 'StatusFilter':StatusFilter, 'SubjFilter':SubjFilter, 'dict_units_en':dict_units_en, 'languages':languages, 'langCode':langCode, 'langName':langName, 'currentuser':currentuser, 'login':login, 'logout': logout})
Esempio n. 13
0
    def get(self):
        languages = memcache.get("languages")
        if languages is not None:
            logging.info("PPP - got languages from memcache.")
        else:
            logging.info("PPP - Can not get languages from memcache.")
            q = Languages.query().order(Languages.langName)
            languages = q.fetch(99)
            if not memcache.add("languages", languages, 99):
                logging.info("PPP - Memcache set failed.")
            # languages = memcache.get("languages")
            # if languages is not None:
                # logging.info("PPP2 - got languages from memcache.")
            # else:
                # logging.info("PPP - Can not get languages from memcache.")
                # q = Languages.query().order(Languages.langName)
                # languages = q.fetch(99)
                # if not memcache.add("languages", languages, 99):
                    # logging.info("PPP - Memcache set failed.")
            
        langCode = 'en'
        if self.request.get('langCode'):
#            logging.info('GGG: SubjAreasList-Where: %s' % 'LangCode passed as param')
            langCode=self.request.get('langCode')
            self.session['langCode'] = langCode
        else:
#            logging.info('GGG: SubjAreasList-Where: %s' % 'LangCode NOT passed as param - prep get from session')
#            logging.info('GGG: SubjAreasList-LangCode before session.get = : %s' % langCode)
            langCode = self.session.get('langCode')
#            logging.info('GGG: SubjAreasList-LangCode after session.get = : %s' % langCode)
        if not langCode:
#            logging.info('GGG: SubjAreasList-Where: %s' % 'LangCode still blank')
            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('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'

        # count_en = 0
        # langCode_en = 'en'
        # units = memcache.get("SubjAreas")
        # if units is not None:
            # logging.info("PPP - got SubjAreas_units from memcache.")
        # else:
            # logging.info("PPP - Can not get SubjAreas_units from memcache.")
            # q = SubjectAreas.query(SubjectAreas.LangCode == langCode_en)
            # units = q.fetch(999)
            # if not memcache.add("SubjAreas", units, 999):
                # logging.info("PPP - SubjAreas_Memcache set failed.")
        # 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)

        Cnt = memcache.get("SubjAreas_EnCnt")
        if Cnt is not None:
            logging.info("PPP - got SubjAreas_EnCnt from memcache.")
            count_en = Cnt
        else:
            logging.info("PPP - Could not get SubjAreas_EnCnt from memcache.")
            count_en = 0
            langCode_en = 'en'
            units = memcache.get("SubjAreas")
            if units is not None:
                logging.info("PPP - got SubjAreas_units from memcache.")
            else:
                # logging.info("PPP - Can not get SubjAreas_units from memcache.")
                q = SubjectAreas.query(SubjectAreas.LangCode == langCode_en)
                units = q.fetch(999, keys_only=True)
                if not memcache.add("SubjAreas", units, 999):
                    logging.info("PPP - SubjAreas_Memcache set failed.")
            for unit in units:
#                logging.info('QQQ: count_en: %d' % count_en)
                count_en = count_en + 1
            if not memcache.add("SubjAreas_EnCnt", count_en, 999):
                    logging.info("PPP - SubjAreas_EnCnt_Memcache set failed.")
        logging.info('QQQ: Total count_en: %d' % count_en)

        logging.info('QQQ: langCode: %s' % langCode)
        count_other_language = 0
        q2 = SubjectAreas.query(SubjectAreas.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 SubjAreasList: %s' % StatusFilter)
        if StatusFilter == 'all':
            q = SubjectAreas.query(SubjectAreas.LangCode == langCode).order(SubjectAreas.Seq, SubjectAreas.LearningUnitID)
        else:
            q = SubjectAreas.query(SubjectAreas.LangCode == langCode, SubjectAreas.Status == StatusFilter).order(SubjectAreas.Seq, SubjectAreas.LearningUnitID)
        units = q.fetch(999)

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/subjareas' )
        else:
              login = users.create_login_url('/subjareas')

        StatusList = ['Pending Translation', 'Pending Review', 'Published'];

        self.render_template('LearnSubjAreaList.html', {'units': units, 'Typ': Typ, 'count_en': count_en, 'count_other_language': count_other_language, 'StatusList':StatusList, 'StatusFilter':StatusFilter, 'languages':languages, 'langCode':langCode, 'langName':langName, 'currentuser':currentuser, 'login':login, 'logout': logout})
    def get(self):
#        UnitSeqRecalc()
#        UnitSubjRecalc()
#        UnitTemplateSync()
        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'

        count_en = 0
        logging.info('QQQ: Total-Outside-1 unitCount_en: %d' % count_en)
        count_en = self.session.get('unitCount_en')
        logging.info('QQQ: Total-Outside-2 unitCount_en: %d' % count_en)
        if count_en < 1:
            count_en = 0
            langCode_en = 'en'
            q = LearningUnits.query(LearningUnits.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 unitCount_en: %d' % count_en)
            self.session['unitCount_en'] = 'count_en'
        logging.info('QQQ: Total-Outside-3 unitCount_en: %d' % count_en)

        count_other_language = self.session.get('unitCount_other_language')
        if not count_other_language:
            logging.info('QQQ: unitCount_other_language-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)
            self.session['unitCount_other_language'] = 'count_other_language'
        logging.info('QQQ: Total-Outside 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 == 'en').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)
        # 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)

        dictTryReadyFiles = {}
        logging.info('GGG: UnitList/dictTryReadyFiles.langCode: %s' % langCode)
        gf = GeneratedFiles.query(GeneratedFiles.LangCode == langCode)
        GenFiles = gf.fetch(999)
        if GenFiles:
            for GenFile in GenFiles:
                if GenFile.TemplateName:
                    logging.info('GGG: UnitList/dictTryReadyFiles.TemplateName: %s' % GenFile.TemplateName)
#                    logging.info('GGG: UnitList/dictTryReadyFiles.FolderName: %s' % GenFile.FolderName)
                    logging.info('GGG: UnitList/dictTryReadyFiles.SearchName: %s' % GenFile.SearchName)
                    dictTryReadyFiles[GenFile.TemplateName] = GenFile.SearchName

        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('LearnUnitList.html', {'units': units, 'count_en': count_en, 'count_other_language': count_other_language, 'StatusList':StatusList, 'StatusFilter':StatusFilter, 'TopGrpFilter':TopGrpFilter, 'dictTryReadyFiles':dictTryReadyFiles, '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('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})
Esempio n. 16
0
    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,
            },
        )