コード例 #1
0
ファイル: Duration.py プロジェクト: ergoregion/Rota-Program
    def _add_event(self, event, row):

        self._event_sheet.write(row, 0, date_string(event.date))
        self._event_sheet.write(row, 1, time_string(event.time))
        self._event_sheet.write(row, 2, event.title)
        self._event_sheet.write(row, 3, event.notes)
        self._event_sheet.write(row, 4, event.description)

        for r in GlobalRoleList.roles:
            self._vacancies_sheets[r.description].write(row, 0, event.title + '(' + date_string(event.date) + ')')

        event_jobs = map(_job, event.appointments)
        for d in self._jobs:
            for i, j in enumerate(self._jobs[d]):
                try:
                    index = event_jobs.index(j)
                    appointment = event.appointments[index]
                    if appointment.disabled:
                        self._vacancies_sheets[j[0]].write(row, i + 1, "Disabled", styleDisabled)
                    elif appointment.is_filled():
                        self._vacancies_sheets[j[0]].write(row, i + 1, appointment.person.name)
                    else:
                        self._vacancies_sheets[j[0]].write(row, i + 1, "")

                    event_jobs[index] = None

                except ValueError:
                    self._vacancies_sheets[j[0]].write(row, i + 1, "", styleInvalid)
コード例 #2
0
def MultipleProximalAppointmentsPersonCheck(appointments, population, permittedTimedelta):
    l = []
    for p in population:
        pAppointments = filter(lambda a: a.person == person, appointments)
        remainingPAppointments = set(pAppointments)
        for appointment in pAppointments:
            remainingPAppointments.remove(appointment)
            proximalAppointments = filter(lambda a: abs(a.datetime - appointment.datetime) <= permittedTimedelta,
                                          remainingPAppointments)
            for app in proximalAppointments:
                warning = CheckWarning(
                    'The person, ' + p.name + ' has 2 oppointments within a short timescale (one of them is' + appointment.role + date_string(
                        appointment.date) + time_string(appointment.time) + ') the other is (' + app.role + date_string(
                        app.date) + time_string(app.time) + +') within ' + str(permittedTimedelta))
                l.append(warning)

    return l
コード例 #3
0
ファイル: Event.py プロジェクト: ergoregion/Rota-Program
 def _html_header(self):
     title = 'Event '
     title += date_string(self._event.date)
     title += '   '
     title += time_string(self._event.time)
     title += '   '
     title += self._event.title
     return HTMLObjects.HTMLHeading(title)
コード例 #4
0
ファイル: Abstract.py プロジェクト: ergoregion/Rota-Program
def event_title(event):
    title = ""
    title += date_string(event.date)
    title += "   "
    title += time_string(event.time)
    title += "   "
    title += event.title
    return title
コード例 #5
0
ファイル: Person.py プロジェクト: ergoregion/Rota-Program
 def _html_table_row_for_appointment(self, appointment):
     html = HTMLObjects.HTMLTableRow()
     html.add(HTMLObjects.HTMLTableCell(date_string(appointment.date)))
     time = time_string(appointment.time)
     event = str(appointment.event.title)
     html.add(HTMLObjects.HTMLTableCell(time))
     html.add(HTMLObjects.HTMLTableCell(self._role_description(appointment)))
     html.add(HTMLObjects.HTMLTableCell(event))
     return html
コード例 #6
0
ファイル: Person.py プロジェクト: ergoregion/Rota-Program
 def _html_table_row_for_appointment(self, appointment):
     html = HTMLObjects.HTMLTableRow()
     html.add(HTMLObjects.HTMLTableCell(date_string(appointment.date)))
     time = time_string(appointment.time)
     event_link = HTMLObjects.HTMLLink(appointment.event.title, "../events/" + event_title(appointment.event) + ".html")
     html.add(HTMLObjects.HTMLTableCell(time))
     html.add(HTMLObjects.HTMLTableCell(self._role_description(appointment)))
     html.add(HTMLObjects.HTMLTableCell(event_link))
     return html
コード例 #7
0
def UnfilledAppointmentCheck(events):
    l = []
    for e in events:
        a = list(e.appointments)
        for appointment in a:
            if not appointment.is_filled() and not appointment.disabled:
                error = CheckError(
                    'The appointment, ' + appointment.role.description + ' is unfilled during the event (' + e.name + date_string(
                        e.date) + time_string(e.time) + ')')
                l.append(error)

    return l
コード例 #8
0
def IncompatibleMultitaskingPersonCheck(events):
    l = []
    for e in events:
        a = list(e.appointments)
        b = list(e.appointments)
        for appointment in a:
            b.remove(appointment)
            for otherAppointment in b:
                if appointment.is_filled() and appointment.person == otherAppointment.person and not appointment.role.compatible_with(
                        otherAppointment.role):
                    error = CheckError(
                        'The person, ' + appointment.person.name + ' is scheduled for conflicting appointments during the same event (' + e.name + date_string(
                            e.date) + time_string(e.time) + ')')
                    l.append(error)

    return l
コード例 #9
0
ファイル: Role.py プロジェクト: ergoregion/Rota-Program
 def _html_table(self):
     table = HTMLObjects.HTMLTable()
     row = HTMLObjects.HTMLTableRow(HTMLObjects.HTMLTableHeaderCell())
     for t in self._times():
         row.add(HTMLObjects.HTMLTableHeaderCell(time_string(t)))
     table.add(row)
     for d in self._dates():
         row = HTMLObjects.HTMLTableRow(HTMLObjects.HTMLTableHeaderCell(date_string(d)))
         for t in self._times():
             correct_appointments = filter(lambda x: x.date == d and x.time == t, self._all_appointments)
             names = map(person_name, correct_appointments)
             if len(names) > 0:
                 string = '<br>'.join(names)
             else:
                 string = ''
             row.add(HTMLObjects.HTMLTableCell(string))
         table.add(row)
     return table
コード例 #10
0
ファイル: Duration.py プロジェクト: ergoregion/Rota-Program
    def _get_events_order(self):

        if self._event_sheet.nrows - 2 != len(self._duration.events):
            raise ExcellImportExportError('There are the wrong number of event entries on the events sheet')

        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)

        ordered_events = [None for _ in range(len(self._duration.events))]

        for event in self._duration.events:
            for i, e in enumerate(table_events):
                if e is not None:
                    if e['title'] == event.title and e['notes'] == event.notes and e[
                        'description'] == event.description:
                        if e['date'] == date_string(event.date) and e['time'] == time_string(event.time):
                            ordered_events[i] = event
                            table_events[i] = None

        if None in ordered_events:
            raise ExcellImportExportError('Not all the events of the duration were incoprorated in the sheet')
        for e in table_events:
            if e is not None:
                raise ExcellImportExportError('Not all the events of the sheet were present in the duration')

        for s in self._vacancies_sheets:
            for i, e in enumerate(ordered_events):
                if self._vacancies_sheets[s].cell_value(i + 2, 0) != e.title + '(' + date_string(e.date) + ')':
                    raise ExcellImportExportError('The sheet about ' + s + ' did not have the matching events')

        return ordered_events
コード例 #11
0
ファイル: Role.py プロジェクト: ergoregion/Rota-Program
 def _html_table(self):
     table = HTMLObjects.HTMLTable()
     row = HTMLObjects.HTMLTableRow()
     row.add(HTMLObjects.HTMLTableHeaderCell("Date"))
     row.add(HTMLObjects.HTMLTableHeaderCell("Time"))
     row.add(HTMLObjects.HTMLTableHeaderCell("Event"))
     row.add(HTMLObjects.HTMLTableHeaderCell("People"))
     table.add(row)
     for e in sorted(self._events, key=lambda e: e.datetime()):
         correct_appointments = [a for a in self._all_appointments if e is a.event]
         if len(correct_appointments) > 0:
             link = HTMLObjects.HTMLLink(e.title, "../events/" + event_title(e) + ".html")
             row = HTMLObjects.HTMLTableRow(HTMLObjects.HTMLTableHeaderCell(date_string(e.date)))
             row.add(HTMLObjects.HTMLTableHeaderCell(time_string(e.time)))
             row.add(HTMLObjects.HTMLTableHeaderCell(link))
             names = map(person_name, correct_appointments)
             if len(names) > 0:
                 string = '<br>'.join(names)
             else:
                 string = ''
             row.add(HTMLObjects.HTMLTableCell(string))
             table.add(row)
     return table
コード例 #12
0
def MultitaskingPersonCheck(events, appointmentsWarningLimit):
    l = []
    for e in events:
        c = Counter(map(person, e.appointments))
        for p in c:
            if p and c[p] > appointmentsWarningLimit:
                error = CheckWarning('The person, ' + p.name + ' is scheduled for ' + str(
                        c[p]) + ' appointments during the same event (' + e.name + date_string(e.date) + time_string(
                    e.time) + ')')
                l.append(error)
            elif p and c[p] > 1:
                error = CheckInformation('The person, ' + p.name + ' is scheduled for ' + str(
                        c[p]) + ' appointments during the same event (' + e.name + date_string(e.date) + time_string(
                    e.time) + ')')
                l.append(error)
    return l