Ejemplo n.º 1
0
    def loadEvents(self, parent, durationIndex=None, personCacheDict=None):

        if durationIndex:
            dx = durationIndex
            tx = 0
        else:
            dx = 0
            tx = 1

        listOfEvents = []

        with self._connection:
            _c = self._connection.cursor()
            _c.execute('SELECT * FROM Events WHERE templateType = ? AND duration = ?', (tx, dx))
            for row in _c.fetchall():
                dt = row[5]
                if durationIndex:
                    e = Event(parent)
                    e._datetime = dt
                else:
                    e = EventPrototype(parent)
                    e.time = dt.time()
                    e.name = row[4]
                e.title = row[1]
                e.notes = row[2]
                e.description = row[3]
                appointmentsOfThisEvent = []
                for row in _c.execute('SELECT * FROM Appointments WHERE event = ?', (row[0],)):
                    r = role(row[3])
                    if durationIndex:
                        a = Appointment(e, r, e)
                    else:
                        a = AppointmentPrototype(e,r)
                    a.note = row[1]
                    if row[2] == 1:
                        a.disabled = True
                    if personCacheDict and len(row[4]) > 0:
                        p = personCacheDict[row[4]]
                        a.appoint(p)
                    appointmentsOfThisEvent.append(a)
                e.appointments = appointmentsOfThisEvent
                listOfEvents.append(e)

        if durationIndex:
            parent.events = listOfEvents
        else:
            parent.templates = listOfEvents
Ejemplo n.º 2
0
    def _get_events(self):
        if len(self._duration.events) > 0:
            raise ExcellImportExportError('This duration already has events')

        self._duration.events = []

        table_events = []
        for i in range(2, self._event_sheet.nrows):
            if self._event_sheet.cell_type(i, 0) is 0:
                break
            else:
                e = {}
                e['date'] = self._event_sheet.cell_value(i, 0)
                e['time'] = self._event_sheet.cell_value(i, 1)
                e['title'] = self._event_sheet.cell_value(i, 2)
                e['notes'] = self._event_sheet.cell_value(i, 3)
                e['description'] = self._event_sheet.cell_value(i, 4)
                table_events.append(e)

        for e in table_events:
            event = Event(self._duration)
            event.title = e['title']
            event.notes = e['notes']
            event.description = e['description']
            event.date = get_date(e['date'])
            event.time = get_time(e['time'])
            self._duration.events.append(event)
Ejemplo n.º 3
0
    def setUp(self):
        GlobalRoleList.add_role(Role('Baker', 'B', 10))
        GlobalRoleList.add_role(Role('Steward', 'S', 9))
        GlobalRoleList.add_role(Role('Fisherman', 'F', 7))
        GlobalRoleList.add_role(Role('Cook', 'C', 7))
        self.institution = Institution()
        self.duration = Duration(self.institution)

        e = Event(self.duration)
        e.title = 'A'
        e.add_appointment(Appointment(e, role("C"), e))
        e.add_appointment(Appointment(e, role("S"), e))
        e.appointments[1].note = 'with car'
        e.add_appointment(Appointment(e, role("F"), e))
        e.add_appointment(Appointment(e, role("F"), e))
        e.appointments[3].disabled = True
        e.add_appointment(Appointment(e, role("F"), e))
        self.duration.events.append(e)

        e = Event(self.duration)
        e.title = 'B'
        e.add_appointment(Appointment(e, role("F"), e))
        e.add_appointment(Appointment(e, role("F"), e))
        e.appointments[1].note = 'with car'
        e.add_appointment(Appointment(e, role("S"), e))
        e.appointments[2].note = 'with car'
        e.add_appointment(Appointment(e, role("B"), e))
        self.duration.events.append(e)