Exemplo n.º 1
0
 def __init__(self):
     self.templates, event = containedEvent(
         GradebookTemplates(_('Report Sheet Templates')), self, 'templates')
     self.deployed, event = containedEvent(
         GradebookDeployed(_('Deployed Report Sheets')), self, 'deployed')
     self.layouts, event = containedEvent(
         GradebookLayouts(_('Report Card Layouts')), self, 'layouts')
Exemplo n.º 2
0
 def setUpTimetable(self, timetable, old_timetable):
     if IWeekDayTemplates.providedBy(old_timetable.time_slots):
         timetable.time_slots, object_event = containedEvent(
             WeekDayTemplates(), timetable, 'time_slots')
     elif ISchoolDayTemplates.providedBy(old_timetable.time_slots):
         timetable.time_slots, object_event = containedEvent(
             SchoolDayTemplates(), timetable, 'time_slots')
     notify(object_event)
     timetable.time_slots.initTemplates()
     old_templates = old_timetable.time_slots.templates
     for old_template_key, old_template in old_templates.items():
         template = DayTemplate(old_template.title)
         timetable.time_slots.templates[old_template_key] = template
         for old_timeslot_key, old_timeslot in old_template.items():
             timeslot = TimeSlot(old_timeslot.tstart, old_timeslot.duration,
                                 old_timeslot.activity_type)
             template[old_timeslot_key] = timeslot
     if IWeekDayTemplates.providedBy(old_timetable.periods):
         timetable.periods, object_event = containedEvent(
             WeekDayTemplates(), timetable, 'periods')
     elif ISchoolDayTemplates.providedBy(old_timetable.periods):
         timetable.periods, object_event = containedEvent(
             SchoolDayTemplates(), timetable, 'periods')
     notify(object_event)
     timetable.periods.initTemplates()
     old_templates = old_timetable.periods.templates
     for old_template_key, old_template in old_templates.items():
         template = DayTemplate(old_template.title)
         timetable.periods.templates[old_template_key] = template
         for old_period_key, old_period in old_template.items():
             period = Period(old_period.title, old_period.activity_type)
             template[old_period_key] = period
Exemplo n.º 3
0
 def setUpTimetable(self, timetable, old_timetable):
     if IWeekDayTemplates.providedBy(old_timetable.time_slots):
         timetable.time_slots, object_event = containedEvent(
             WeekDayTemplates(), timetable, 'time_slots')
     elif ISchoolDayTemplates.providedBy(old_timetable.time_slots):
         timetable.time_slots, object_event = containedEvent(
             SchoolDayTemplates(), timetable, 'time_slots')
     notify(object_event)
     timetable.time_slots.initTemplates()
     old_templates = old_timetable.time_slots.templates
     for old_template_key, old_template in old_templates.items():
         template = DayTemplate(old_template.title)
         timetable.time_slots.templates[old_template_key] = template
         for old_timeslot_key, old_timeslot in old_template.items():
             timeslot = TimeSlot(old_timeslot.tstart,
                                 old_timeslot.duration,
                                 old_timeslot.activity_type)
             template[old_timeslot_key] = timeslot
     if IWeekDayTemplates.providedBy(old_timetable.periods):
         timetable.periods, object_event = containedEvent(
             WeekDayTemplates(), timetable, 'periods')
     elif ISchoolDayTemplates.providedBy(old_timetable.periods):
         timetable.periods, object_event = containedEvent(
             SchoolDayTemplates(), timetable, 'periods')
     notify(object_event)
     timetable.periods.initTemplates()
     old_templates = old_timetable.periods.templates
     for old_template_key, old_template in old_templates.items():
         template = DayTemplate(old_template.title)
         timetable.periods.templates[old_template_key] = template
         for old_period_key, old_period in old_template.items():
             period = Period(old_period.title, old_period.activity_type)
             template[old_period_key] = period
Exemplo n.º 4
0
    def createPeriods(self, timetable, model, day_titles,
                      period_names, homeroom_periods):
        if model == 'weekly':
            timetable.periods, object_event = containedEvent(
                WeekDayTemplates(), timetable, 'periods')
            day_ids = [unicode(n) for n in range(min(len(day_titles), 7))]
        elif model == 'rotating':
            timetable.periods, object_event = containedEvent(
                SchoolDayTemplates(), timetable, 'periods')
            day_ids = [unicode(n) for n in range(len(day_titles))]
        else:
            raise NotImplementedError()

        notify(object_event)
        timetable.periods.initTemplates()

        periods = []
        for titles, homeroom_titles in zip(period_names, homeroom_periods):
            periods.append(
                [(title, title in homeroom_titles and 'homeroom' or 'lesson')
                 for title in titles])

        days = zip(day_ids, day_titles, periods)

        self.addPeriodTemplates(timetable.periods, days)
Exemplo n.º 5
0
 def setUp(self, periods=(), time_slots=()):
     self.periods, event = containedEvent(
         OneTemplateSchedule(), self, 'periods')
     zope.event.notify(event)
     self.periods.initTemplates()
     self.time_slots, event = containedEvent(
         OneTemplateSchedule(), self, 'time_slots')
     zope.event.notify(event)
     self.time_slots.initTemplates()
     for n, title in enumerate(periods):
         self.periods.default['%d' % (n+1)] = Period(title=title)
     for n, tstart in enumerate(time_slots):
         duration = timedelta(0, 900)
         self.time_slots.default['%d' % (n+1)] = TimeSlot(tstart, duration)
Exemplo n.º 6
0
 def setUp(self, periods=(), time_slots=()):
     self.periods, event = containedEvent(OneTemplateSchedule(), self,
                                          'periods')
     zope.event.notify(event)
     self.periods.initTemplates()
     self.time_slots, event = containedEvent(OneTemplateSchedule(), self,
                                             'time_slots')
     zope.event.notify(event)
     self.time_slots.initTemplates()
     for n, title in enumerate(periods):
         self.periods.default['%d' % (n + 1)] = Period(title=title)
     for n, tstart in enumerate(time_slots):
         duration = timedelta(0, 900)
         self.time_slots.default['%d' % (n + 1)] = TimeSlot(
             tstart, duration)
Exemplo n.º 7
0
def evolve(context):
    root = context.connection.root().get(ZopePublication.root_name, None)

    old_site = getSite()
    apps = findObjectsProviding(root, ISchoolToolApplication)
    for app in apps:
        gb = app.get(GRADEBOOK_ROOT_KEY)
        gb.templates, event = containedEvent(gb.templates, gb, 'templates')
        zope.event.notify(event)
        gb.deployed, event = containedEvent(gb.deployed, gb, 'deployed')
        zope.event.notify(event)
        gb.layouts, event = containedEvent(gb.layouts, gb, 'layouts')
        zope.event.notify(event)

    setSite(old_site)
Exemplo n.º 8
0
 def __setitem__(self, key, value):
     if not key:
         raise ValueError("empty names are not allowed")
     object, event = containedEvent(value, self, key)
     self._setitemf(key, value)
     if event:
         notify(event)
         notifyContainerModified(self)
Exemplo n.º 9
0
 def __setitem__(self, key, value):
     if not key:
         raise ValueError("empty names are not allowed")
     object, event = containedEvent(value, self, key)
     self._setitemf(key, value)
     if event:
         notify(event)
         notifyContainerModified(self)
Exemplo n.º 10
0
 def __setitem__(self, requirement, value):
     """See zope.interface.common.mapping.IWriteMapping"""
     key = IKeyReference(requirement)
     if (key in self._btree or
         self.getHistory(requirement)):
         current = self._btree.get(key, None)
         self.appendToHistory(requirement, current)
     self._btree[key] = value
     value, event = containedEvent(value, self)
     zope.event.notify(event)
Exemplo n.º 11
0
    def createTimeSlots(self, timetable, model, day_titles, time_slots):
        if model == 'weekly':
            timetable.time_slots, object_event = containedEvent(
                WeekDayTemplates(), timetable, 'time_slots')
            days = [(unicode(n),
                     translate(day_of_week_names[n],
                               context=self.request), time_slot)
                    for n, time_slot in zip(range(7), time_slots)]
        elif model == 'rotating':
            timetable.time_slots, object_event = containedEvent(
                SchoolDayTemplates(), timetable, 'time_slots')
            # An UI limitations at the time of writing
            time_slots = time_slots[:len(day_titles)]
            day_ids = [unicode(n) for n in range(len(day_titles))]
            days = zip(day_ids, day_titles, time_slots)
        else:
            raise NotImplementedError()

        notify(object_event)
        timetable.time_slots.initTemplates()

        self.addTimeSlotTemplates(timetable.time_slots, days)
Exemplo n.º 12
0
    def createTimeSlots(self, timetable, model, day_titles, time_slots):
        if model == 'weekly':
            timetable.time_slots, object_event = containedEvent(
                WeekDayTemplates(), timetable, 'time_slots')
            days = [
                (unicode(n),
                 translate(day_of_week_names[n], context=self.request),
                 time_slot)
                for n, time_slot in zip(range(7), time_slots)]
        elif model == 'rotating':
            timetable.time_slots, object_event = containedEvent(
                SchoolDayTemplates(), timetable, 'time_slots')
            # An UI limitations at the time of writing
            time_slots = time_slots[:len(day_titles)]
            day_ids = [unicode(n) for n in range(len(day_titles))]
            days = zip(day_ids, day_titles, time_slots)
        else:
            raise NotImplementedError()

        notify(object_event)
        timetable.time_slots.initTemplates()

        self.addTimeSlotTemplates(timetable.time_slots, days)
Exemplo n.º 13
0
 def _contained_setitem(self, setitemf, key, value, check_old):
     # This is based on zope.container.contained.setitem(), but we skip
     # the check if the name is in the container in case the key was just
     # generated.
     #
     # This check generates a SELECT query and causes conflicts in case
     # there are many transactions adding to the container.
     key = contained.checkAndConvertName(key)
     marker = object()
     if check_old:
         old = self.get(key, marker)
         if old is value:
             return
         if old is not marker:
             raise KeyError(key)
     value, event = contained.containedEvent(value, self, key)
     setitemf(key, value)
     if event:
         zope.event.notify(event)
         contained.notifyContainerModified(self)
Exemplo n.º 14
0
 def initTemplates(self):
     self.templates, event = containedEvent(DayTemplateContainer(), self,
                                            'templates')
     notify(event)
Exemplo n.º 15
0
 def initTemplates(self):
     self.templates, event = containedEvent(
         DayTemplateContainer(), self, 'templates')
     notify(event)