def create_event(self, author_id):
        from .term import Term
        from .event import Event

        Event.objects.filter(reservation=self).delete()

        semester = self.semester

        ev = Event()
        ev.title = self.title
        ev.description = 'Rezerwacja cykliczna - ' + self.title
        ev.reservation = self
        ev.type = Event.TYPE_GENERIC
        ev.visible = True
        ev.status = Event.STATUS_ACCEPTED
        ev.author_id = author_id
        ev.save()

        term_days = semester.get_all_days_of_week(
            day_of_week=self.dayOfWeek,
            start_date=max(datetime.now().date(), semester.lectures_beginning))

        for day in term_days:
            term = Term()
            term.event = ev
            term.day = day
            term.start = self.start_time
            term.end = self.end_time
            term.room = self.classroom
            term.save()
예제 #2
0
        def create_event(title, visible=True):
            ev = Event()
            ev.title = title
            ev.type = '4'
            ev.visible = visible
            ev.status = '1'
            ev.author_id = 1
            ev.save()

            return ev