Exemplo n.º 1
0
class ExhibitApplication(CampusFieldApplication):

    PLACE = (
        (u'CD座文化长廊', u'CD座文化长廊'),
        (u'A座文化大厅', u'A座文化大厅'),
        (u'西南餐厅前空地', u'西南餐厅前空地'),
        (u'荔山餐厅前空地', u'荔山餐厅前空地'),
    )

    TIME = (
        (u'早上', u'早上'),
        (u'下午', u'下午'),
    )

    EXHIBITION = (
        (u'图片', u'图片'),
        (u'海报', u'海报'),
    )

    place = MultiSelectField(max_length=200, choices=PLACE)
    time = MultiSelectField(max_length=100, choices=TIME)
    exhibition = models.CharField(max_length=20,
                                  choices=EXHIBITION,
                                  blank=True,
                                  null=True)
    other_exhibition = models.CharField(max_length=20, blank=True, null=True)
    exhibit_board_number = models.PositiveIntegerField()
Exemplo n.º 2
0
class MeetingRoomApplication(models.Model):

    TIME = generate_time_table()

    PLACE = (
        # (u'学生活动中心307会议室', u'学生活动中心307会议室'),
        (u'石头坞一楼会议室', u'石头坞一楼会议室'),
        #(u'石头坞二楼会议室', u'石头坞二楼会议室'),
        #(u'学生活动中心305会议室', u'学生活动中心305会议室'),
    )

    meeting_topic = models.CharField(max_length=50)
    organization = models.ForeignKey(Organization)
    date = models.DateField()
    place = models.CharField(max_length=50, choices=PLACE)
    # 如果多选的时候,最高要存30个时间,所以这里开到400
    time = MultiSelectField(max_length=400, choices=TIME)
    applicant_name = models.CharField(max_length=10)
    applicant_stu_id = models.CharField(max_length=15)
    applicant_college = models.CharField(max_length=50)
    applicant_phone_number = models.CharField(max_length=30)
    meeting_summary = models.CharField(max_length=200)
    remarks = models.CharField(max_length=300, blank=True, null=True)
    approved = models.BooleanField(default=False)
    application_time = models.DateTimeField(auto_now_add=True)
    deleted = models.BooleanField(default=False)

    @classmethod
    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
        }
Exemplo n.º 3
0
class PublicityApplication(CampusFieldApplication):

    PLACE = (
        (u'荔山餐厅前空地', u'荔山餐厅前空地'),
        (u'西南餐厅前空地', u'西南餐厅前空地'),
        (u'文山湖路口', u'文山湖路口'),
        (u'桂庙路口', u'桂庙路口'),
        (u'CD座文化长廊', u'CD座文化长廊'),
        (u'A座文化大厅', u'A座文化大厅'),
    )

    TIME = (
        (u'8点-9点', u'8点-9点'),
        (u'9点-10点', u'9点-10点'),
        (u'10点-11点', u'10点-11点'),
        (u'11点-12点', u'11点-12点'),
        (u'12点-13点', u'12点-13点'),
        (u'13点-14点', u'13点-14点'),
        (u'14点-15点', u'14点-15点'),
        (u'15点-16点', u'15点-16点'),
        (u'16点-17点', u'16点-17点'),
        (u'17点-18点', u'17点-18点'),
        (u'18点-19点', u'18点-19点'),
    )

    ACTIVITY_TYPE = (
        (u'派传单', u'派传单'),
        (u'设点', u'设点'),
    )

    activity_type = models.CharField(max_length=10,
                                     choices=ACTIVITY_TYPE,
                                     blank=True,
                                     null=True)
    other_activity_type = models.CharField(max_length=10,
                                           blank=True,
                                           null=True)
    place = MultiSelectField(max_length=200, choices=PLACE)
    time = MultiSelectField(max_length=300, choices=TIME)
Exemplo n.º 4
0
class SouthStadiumApplication(models.Model):

    TIME = (
        (u'早上08:00-12:00', u'早上08:00-12:00'),
        (u'下午14:00-17:00', u'下午14:00-17:00'),
        (u'晚上19:00-22:30', u'晚上19:00-22:30'),
    )

    organization = models.ForeignKey(Organization)
    date = models.DateField()
    time = MultiSelectField(max_length=100, choices=TIME)
    activity = models.CharField(max_length=30)
    approved = models.BooleanField(default=False)
    application_time = models.DateTimeField(auto_now_add=True)

    plan_file = models.FileField(upload_to=file_save_path('south_stadium'),
                                 validators=[validate_file_extension])
    applicant_name = models.CharField(max_length=10)
    applicant_phone_number = models.CharField(max_length=30)
    activity_summary = models.CharField(max_length=200)
    sponsor = models.CharField(max_length=30, blank=True, null=True)
    sponsorship = models.CharField(max_length=30, blank=True, null=True)
    sponsorship_usage = models.CharField(max_length=40, blank=True, null=True)
    remarks = models.CharField(max_length=300, blank=True, null=True)
    deleted = models.BooleanField(default=False)

    @classmethod
    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)
        }