コード例 #1
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)
コード例 #2
0
ファイル: Events.py プロジェクト: ergoregion/Rota-Program
    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
コード例 #3
0
ファイル: Population.py プロジェクト: ergoregion/Rota-Program
    def _get_roles(self):
        self._sheet_role_list = []

        for i, cell in enumerate(self._qualifications_sheet.row(0)):

            if cell.ctype is 0:
                break
            try:
                r = role(cell.value)
            except:
                raise ExcellImportExportError('There was an unidentified role: ' + cell.value)
            if r is None:
                if i > 0:
                    raise ExcellImportExportError('There was an unidentified role: ' + cell.value)
            else:
                self._sheet_role_list.append(r)

        for r in GlobalRoleList.roles:
            if r not in self._sheet_role_list:
                raise ExcellImportExportError('There was an role unlisted on the sheet: ' + r.description)