Beispiel #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}
Beispiel #2
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}
Beispiel #3
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}
Beispiel #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)}
Beispiel #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)
        }
Beispiel #6
0
    def generate_table(cls, offset=0):
        ''' generate a dict of the structure below
        table - date : [ 7 date ]
              - ( place1, [ 7 * [ len(cls.TIME)* [] ] ] )
              - ( place2, 同上
              - ( place3, 同上
        [[], []] 的第一个是早上,二个是下午
        '''
        content = { place: [ {time: [] for time, t in cls.TIME} \
                                for i in range(7)] \
                                for place, p in cls.PLACE }

        field_used_this_week_applications = \
                cls.get_applications_a_week(offset)
        first_day = timezone.now().date() + timedelta(days=7*offset)
        last_day = first_day + timedelta(days=6)
        for app in field_used_this_week_applications:
            for i in range((app.end_date-app.start_date).days+1):
                d = app.start_date + timedelta(days=i)
                if d < first_day or d > last_day: 
                    continue
                for time in app.time:
                    for place in app.place:
                        content[place][(d-first_day).days] \
                                [time].append(app)
        # sort in the order of time
        for place, p in cls.PLACE:
            for i in range(7):
                content[place][i] = [content[place][i][time] \
                                        for time, t in cls.TIME]
                # 特殊处理PublicityApplication的情况,
                # 由于表格要求十二个格子,
                # TIME只有11个,加一个空的补足12
                if len(content[place][i]) == 11:
                    content[place][i].append([])
        # 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}
Beispiel #7
0
    def generate_table(cls, offset=0):
        ''' generate a dict of the structure below
        table - date : [ 7 date ]
              - ( place1, [ 7 * [ len(cls.TIME)* [] ] ] )
              - ( place2, 同上
              - ( place3, 同上
        [[], []] 的第一个是早上,二个是下午
        '''
        content = { place: [ {time: [] for time, t in cls.TIME} \
                                for i in range(7)] \
                                for place, p in cls.PLACE }

        field_used_this_week_applications = \
                cls.get_applications_a_week(offset)
        first_day = datetime.now().date() + timedelta(days=7*offset)
        last_day = first_day + timedelta(days=6)
        for app in field_used_this_week_applications:
            for i in range((app.end_date-app.start_date).days+1):
                d = app.start_date + timedelta(days=i)
                if d < first_day or d > last_day: 
                    continue
                for time in app.time:
                    for place in app.place:
                        content[place][(d-first_day).days] \
                                [time].append(app)
        # sort in the order of time
        for place, p in cls.PLACE:
            for i in range(7):
                content[place][i] = [content[place][i][time] \
                                        for time, t in cls.TIME]
                # 特殊处理PublicityApplication的情况,
                # 由于表格要求十二个格子,
                # TIME只有11个,加一个空的补足12
                if len(content[place][i]) == 11:
                    content[place][i].append([])
        # 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}