Esempio n. 1
0
 def save(self, *args, **kwargs):
     from tools import convert2PY
     if not self.pinyin or len(self.pinyin) == 0:
         self.pinyin = convert2PY(self.name)
     rate_distribution_key = 'rate_distribution'
     delCache(rate_distribution_key)
     super(Teacher, self).save(*args, **kwargs)
Esempio n. 2
0
    def save(self, *args, **kwargs):
        from tools import convert2PY
        if not self.pinyin or len(self.pinyin) == 0:
            self.pinyin = convert2PY(self.name)
        # delete cache
        rate_distribution_key = 'rate_distribution'
        delCache(rate_distribution_key)

        teacher_rate_key = 'rate_%s' % self.id
        delCache(teacher_rate_key)

        super(Teacher, self).save(*args, **kwargs)
Esempio n. 3
0
    def getAll():
        key = 'college_list'
        #delCache(key)
        if getCache(key):
            return getCache(key)

        from tools import convert2PY
        colleges = list(College.objects.all().filter(display=True).order_by('name'))
        for college in colleges:
            college.pinyin = convert2PY(college.name[:1])
            college.name = college.name
        colleges = sorted(colleges, key=lambda college: college.pinyin)
        setCache(key,colleges)

        return colleges
Esempio n. 4
0
    def getAll():
        key = 'college_list'
        #delCache(key)
        if getCache(key):
            return getCache(key)

        from tools import convert2PY
        colleges = list(
            College.objects.all().filter(display=True).order_by('name'))
        for college in colleges:
            college.pinyin = convert2PY(college.name[:1])
            college.name = college.name
        colleges = sorted(colleges, key=lambda college: college.pinyin)
        setCache(key, colleges)

        return colleges