Example #1
0
 def generate_table(cls, offset=0):
     ''' generate table
     table - date : [ 7 * date ]
           - time_list : [ 30 * time ]
           - content - 石头坞一楼会议室      : [ 7*[ 30*[] ] ]
                     - 石头坞二楼会议室      : [ 7*[ 30*[] ] ] 
                     - 学生活动中心305会议室 : [ 7*[ 30*[] ] ] 
                     - 学生活动中心307会议室 : [ 7*[ 30*[] ] ] 
     '''
     content = { place: [ {time: [] for time, t in cls.TIME} \
                     for j in range(7)] \
                 for place, p in cls.PLACE}
     apps_whose_field_used_within_7days \
         = get_applications_a_week(cls, offset)
     first_day = date.today() + timedelta(days=offset*7)
     for app in apps_whose_field_used_within_7days:
         for t in app.time:
             content[app.place][(app.date-first_day).days][t].append(app)
     # sort in the order of TIME
     for place in content:
         for day in range(7):
             content[place][day] = [content[place][day][time] \
                                     for time, t in cls.TIME ]
     # sort int the order of PLACE
     content = [(place, content[place]) for place, p in cls.PLACE]
     return {'date': gennerate_date_list_7days(offset),
             'time_list': tuple(time for time, t in cls.TIME),
             'content': content}
Example #2
0
 def generate_table(cls, offset=0):
     ''' generate table
     table - date : [ 7 * date ]
           - time_list : [ 30 * time ]
           - content - 石头坞一楼会议室      : [ 7*[ 30*app ] ]
                     - 石头坞二楼会议室      : [ 7*[ 30*app ] ] 
                     - 学生活动中心305会议室 : [ 7*[ 30*app ] ] 
                     - 学生活动中心307会议室 : [ 7*[ 30*app ] ] 
     '''
     content = { place: [ {time: None for time, t in cls.TIME} \
                     for j in range(7)] \
                 for place, p in cls.PLACE}
     apps_whose_field_used_within_7days \
         = get_applications_a_week(cls, offset)
     first_day = date.today() + timedelta(days=offset*7)
     for app in apps_whose_field_used_within_7days:
         for t in app.time:
             content[app.place][(app.date-first_day).days][t] = app
     # sort in the order of TIME
     for place in content:
         for day in range(7):
             content[place][day] = [content[place][day][time] \
                                     for time, t in cls.TIME ]
     # sort int the order of PLACE
     content = [(place, content[place]) for place, p in cls.PLACE]
     return {'date': gennerate_date_list_7days(offset),
             'time_list': tuple(time for time, t in cls.TIME),
             'content': content}
Example #3
0
    def generate_table(cls, offset=0):
        ''' generate dict
        -date : [ 7 * date ] 
        -content: 
          学生活动中心前广场      : [7 * [ [], [],[] ] ]
          一楼影视报告厅          : 同上 
          学生活动中心三楼天台(东): 同上 
          学生活动中心三楼天台(西): 同上 
          石头坞广场              : 同上 
        '''
        field_used_this_week_applications = \
                get_applications_a_week(cls, offset)

        empty_time_dict = { time: [] for time, l in cls.TIME }
        content = {place: [ copy.deepcopy(empty_time_dict) for i in range(7)] \
                                for place, p in cls.PLACE }
        first_day = date.today() + timedelta(days=offset*7)
        for app in field_used_this_week_applications:
            content[app.place][(app.date-first_day).days][app.time].append(app)
        # sort in the order of time
        for place in content:
            for day in range(7):
                content[place][day] = [content[place][day][time] \
                                            for time, t in cls.TIME]
        # sort in the order of place
        content = [(place, content[place]) for place, p in cls.PLACE]
        return {'date': gennerate_date_list_7days(offset),
                'content': content}
Example #4
0
    def generate_table(cls, offset=0):
        ''' generate table
        - date [ 7 * date ]
        - content - ('早上08:00-12:00', [ 7 * [] ] )
                  - ('下午14:00-17:00', [ 7 * [] ] )
                  - ('晚上19:00-22:30', [ 7 * [] ] )
        '''
        apps_whose_field_used_within_7days \
            = get_applications_a_week(cls, offset)
        content = { time: [ [] for i in range(0, 7)] \
                    for time, t in cls.TIME }
        first_day = date.today() + timedelta(offset*7)
        for app in apps_whose_field_used_within_7days:
            for t in app.time:
                content[t][(app.date-first_day).days].append(app)

        return {'date': gennerate_date_list_7days(offset),
                'content': ( (time, content[time]) for time, t in cls.TIME)}
Example #5
0
    def generate_table(cls, offset=0):
        ''' generate table
        - date [ 7 * date ]
        - content - ('早上08:00-12:00', [ 7 * [] ] )
                  - ('下午14:00-17:00', [ 7 * [] ] )
                  - ('晚上19:00-22:30', [ 7 * [] ] )
        '''
        apps_whose_field_used_within_7days \
            = get_applications_a_week(cls, offset)
        content = { time: [ [] for i in range(0, 7)] \
                    for time, t in cls.TIME }
        first_day = date.today() + timedelta(offset * 7)
        for app in apps_whose_field_used_within_7days:
            for t in app.time:
                content[t][(app.date - first_day).days].append(app)

        return {
            'date': gennerate_date_list_7days(offset),
            'content': ((time, content[time]) for time, t in cls.TIME)
        }