Esempio n. 1
0
    def get_set(self, school = None,):
        """
        得到某学校食谱设置
        """
        from kinger.helpers import CookbookHelper
        cookbook_set_items = {
                'breakfast':{
                    'is_show':True,
                    'name':'早餐'
                },
                'light_breakfast':{
                    'is_show':True,
                    'name':'早点'
                },
                'lunch':{
                    'is_show':True,
                    'name':'午餐'
                },
                'light_lunch':{
                    'is_show':True,
                    'name':'午点'
                },
                'dinner':{
                    'is_show':True,
                    'name':'晚餐'
                },
                'light_dinner':{
                    'is_show':True,
                    'name':'晚点'
                },
        }
        if school:
            cookbook_set = self.filter(school = school)
            
            items = CookbookHelper.get_items()

            if cookbook_set.count() > 0:
                for item in items:
                    cookbook_set_items[item]['is_show'] = getattr(cookbook_set[0], item)

        return cookbook_set_items
Esempio n. 2
0
    def get_cookbook_date(self, date, group = None, school = None):
        """
        返回具体某天的学校或班级食谱
        """
        from kinger.helpers import CookbookHelper
        school_cookbook_day = self.filter(school=school,date=date)
        # group_cookbook_day = self.filter(group=group,date=date)

        cur_day_con = {
            'year':date.year,
            'month':date.month,
            'day':date.day,
            'is_pub':False,
            'con':{
                'breakfast':{
                    'con':'',
                    'comefrom':'school'
                },
                'light_breakfast':{
                    'con':'',
                    'comefrom':'school'
                },
                'lunch':{
                    'con':'',
                    'comefrom':'school'
                },
                'light_lunch':{
                    'con':'',
                    'comefrom':'school'
                },
                'dinner':{
                    'con':'',
                    'comefrom':'school'
                },
                'light_dinner':{
                    'con':'',
                    'comefrom':'school'
                },
            },
            'items':[]
        } 

        school_pub = True if school_cookbook_day.count() > 0 else False
        # group_pub = True if group_cookbook_day.count() > 0 else False

        items = CookbookHelper.get_items()

        # school
        if not group:
            if school_pub:
                cur_day_con['is_pub'] = True

                for item in items: 
                    school_con = getattr(school_cookbook_day[0], item)        

                    cur_day_con['con'][item]['con'] = school_con
                    cur_day_con['con'][item]['comefrom'] = 'school' 
        # group
        else:     
            group_cookbook_day = self.filter(group=group,date=date)
            group_pub = True if group_cookbook_day.count() > 0 else False
              
            if school_pub or group_pub:
                cur_day_con['is_pub'] = True               

                for item in items:                 

                    group_con = getattr(group_cookbook_day[0], item) if group_pub else ''
                    school_con = getattr(school_cookbook_day[0], item) if school_pub else ''               

                    # 读取班级
                    if group_con != '':
                        cur_day_con['con'][item]['con'] = group_con
                        cur_day_con['con'][item]['comefrom'] = 'group'

                    # 读取学校
                    else:
                        cur_day_con['con'][item]['con'] = school_con
                        cur_day_con['con'][item]['comefrom'] = 'school' 

        return cur_day_con
Esempio n. 3
0
 def get_items(self,):
     from kinger.helpers import CookbookHelper
     return CookbookHelper.get_items()