Exemple #1
0
    def get(self):
        if self.request.get('langCode'):
            langCode = self.request.get('langCode')

            q = LearnAids.query(LearnAids.LangCode == langCode)
            aids = q.fetch(999)

            countmap_other_language={}
            for aid in aids:
                logging.info('QQQ: LangCode in clone: %s' % aid.LangCode)
                if aid.LearnAidID not in countmap_other_language:
                    logging.info('QQQ: LearnAidID in clone: %s' % aid.LearnAidID)
                    countmap_other_language[aid.LearnAidID] = 1

            q = LearnAids.query(LearnAids.LangCode == 'en')
            aids_en = q.fetch(999)

            for aid2 in aids_en:
                if aid2.LearnAidID not in countmap_other_language:
                    logging.info('QQQ: LearnAidID to add in clone: %s' % aid2.LearnAidID)
                    logging.info('QQQ: LangCode to add in clone: %s' % langCode)
                    n = LearnAids(LearnAidID = aid2.LearnAidID
                        , Subject = aid2.Subject
                        , Name = aid2.Name
                        , Seq = aid2.Seq
                        , VideoStatus = 'Pending Translation'
                        , LangCode = langCode
                        , Description = aid2.Description
                        , Status = 'Pending Translation'
                        )
                    n.put()
            return self.redirect('/aids')        

        else:
            return self.redirect('/aids')  
Exemple #2
0
 def post(self):
     #logging.error('QQQ: templatecreate POST')
     n = LearnAids(LearnAidID = self.request.get('Name')
               , Subject=self.request.get('Subject')
               , Name = self.request.get('Name')
               , Seq = 999
               , LangCode = 'en'
               , Description=self.request.get('Description')
               , Status = 'Pending Review'
               )
     n.put()
     return self.redirect('/aids/create')
Exemple #3
0
def AidSeqPop():
    q2 = LearnAids.query(LearnAids.LangCode == 'en')
    unitsen = q2.fetch(999)
    for uniten in unitsen:
        Seq = uniten.Seq
        if Seq == None:
            Seq = 999
        uniten.Seq = Seq
        uniten.put()
    return
Exemple #4
0
def AidSubjRecalc():
    dic_en = {}
    q2 = LearnAids.query(LearnAids.LangCode == 'en')
    unitsen = q2.fetch(999)
    for uniten in unitsen:
        logging.info('GGG: AidSubjRecalc / Subj before: %s' % uniten.Subject)
        Subj = uniten.Subject
        if Subj == None:
            Subj = 'Math2'
        logging.info('GGG: AidSubjRecalc / Adding Aids to Dic: %s' % uniten.LearnAidID)
        logging.info('GGG: aidSubjRecalc / Adding Subj to Dic: %s' % Subj)
        dic_en[uniten.LearnAidID] = Subj

    q = LearnAids.query(LearningUnits.LangCode != 'en')
    units = q.fetch(999)
    for unit in units:
        logging.info('GGG: AidsSubjRecalc / Updating Aids %s' % unit.LearnAidID)
        logging.info('GGG: AidsSubjRecalc / Updating Aids Subj: %s' % dic_en[unit.LearnAidID])
        unit.Subject = dic_en[unit.LearnAidID]
        unit.put()
    return  
Exemple #5
0
def AidSeqRecalc():
    dic_en = {}
    q2 = LearnAids.query(LearnAids.LangCode == 'en')
    unitsen = q2.fetch(999)
    for uniten in unitsen:
        logging.info('GGG: AidSeqRecalc / Seq before: %s' % uniten.Seq)
        Seq = uniten.Seq
        if Seq == None:
            Seq = 999
        logging.info('GGG: AidSeqRecalc / Adding Aids to Dic: %s' % uniten.LearnAidID)
        logging.info('GGG: aidSeqRecalc / Adding Seq to Dic: %s' % Seq)
        dic_en[uniten.LearnAidID] = Seq

    q = LearnAids.query(LearningUnits.LangCode != 'en')
    units = q.fetch(999)
    for unit in units:
        logging.info('GGG: AidsSubjRecalc / Updating Aids %s' % unit.LearnAidID)
        logging.info('GGG: AidsSubjRecalc / Updating Aids Seq: %s' % dic_en[unit.LearnAidID])
        unit.Seq = dic_en[unit.LearnAidID]
        unit.put()
    return  
Exemple #6
0
    def get(self, aid_id):
        iden = int(aid_id)
        aid = ndb.Key('LearnAids', iden).get()

        f = LearnAids.query(LearnAids.LangCode == 'en', LearnAids.LearnAidID == aid.LearnAidID)
        units_en = f.get()

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

        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)

        q4 = TopicAreas.query(TopicAreas.Subject == SubjFilter)
        subjects = q4.fetch(999)
        SubjectList = []
        if subjects:
            for subject in subjects:
                SubjectList.append(subject.Name)
        else:
            SubjectList.append('none')

        StatusList = ['Pending Translation', 'Pending Review', 'Published'];		  
        VideoStatusList = ['Pending Translation', 'Pending Review', 'Published'];		  
        self.render_template('LearnAidEdit.html', {'aid': aid, 'units_en':units_en, 'SubjectList': SubjectList, 'StatusList': StatusList, 'VideoStatusList': VideoStatusList, 'currentuser':currentuser, 'login':login, 'logout': logout})
Exemple #7
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})