Example #1
0
    def dayEvents(self, date):
        """Return a list of events that should be shown.

        All-day events are placed in front.
        """
        allday_events = []
        events = []
        tz = self.getTimezone()
        start = tz.localize(datetime.datetime.combine(date, datetime.time(0)))
        end = start + datetime.timedelta(days=1)

        for calendar in self.getCalendars():
            for event in calendar.expand(start, end):
                if (same(event.__parent__, self.context)
                      and not same(calendar, self.context)):
                    # We may have overlaid resource booking events appearing
                    # twice (once for self.context and another time for the
                    # other calendar).  We can recognize such dupes by
                    # checking that their __parent__ does not match the
                    # calendar they are coming from.
                    continue
                if event.allday:
                    allday_events.append(event)
                else:
                    events.append(event)

        allday_events.sort()
        events.sort()
        return allday_events + events
Example #2
0
    def dayEvents(self, date):
        """Return a list of events that should be shown.

        All-day events are placed in front.
        """
        allday_events = []
        events = []
        tz = self.getTimezone()
        start = tz.localize(datetime.datetime.combine(date, datetime.time(0)))
        end = start + datetime.timedelta(days=1)

        for calendar in self.getCalendars():
            for event in calendar.expand(start, end):
                if (same(event.__parent__, self.context)
                        and not same(calendar, self.context)):
                    # We may have overlaid resource booking events appearing
                    # twice (once for self.context and another time for the
                    # other calendar).  We can recognize such dupes by
                    # checking that their __parent__ does not match the
                    # calendar they are coming from.
                    continue
                if event.allday:
                    allday_events.append(event)
                else:
                    events.append(event)

        allday_events.sort()
        events.sort()
        return allday_events + events
Example #3
0
 def contains(self, principal):
     from schooltool.app.browser import same  # XXX
     from schooltool.app.interfaces import ISchoolToolApplication
     from schooltool.person.interfaces import IPerson
     app = ISchoolToolApplication(None)
     persons = app['persons']
     person = IPerson(principal, None)
     return person is not None and same(person, persons.super_user)
Example #4
0
 def contains(self, principal):
     from schooltool.app.browser import same # XXX
     from schooltool.app.interfaces import ISchoolToolApplication
     from schooltool.person.interfaces import IPerson
     app = ISchoolToolApplication(None)
     persons = app['persons']
     person = IPerson(principal, None)
     return person is not None and same(person, persons.super_user)
Example #5
0
 def contains(self, principal):
     from schooltool.app.browser import same  # XXX
     app = ISchoolToolApplication(None)
     super_user = app['persons'].super_user
     if self.context.person is super_user:
         person = IPerson(principal, None)
         return same(person, super_user)
     if (ManagersCrowd(self.context.person).contains(principal)
             or ClerksCrowd(self.context.person).contains(principal)):
         return True
     return (ConfigurableCrowd.contains(self, principal)
             and OwnerCrowd(self.context.person).contains(principal))
Example #6
0
 def contains(self, principal):
     from schooltool.app.browser import same # XXX
     app = ISchoolToolApplication(None)
     super_user = app['persons'].super_user
     if self.context.person is super_user:
         person = IPerson(principal, None)
         return same(person, super_user)
     if (ManagersCrowd(self.context.person).contains(principal) or
         ClerksCrowd(self.context.person).contains(principal)):
         return True
     return (ConfigurableCrowd.contains(self, principal) and
             OwnerCrowd(self.context.person).contains(principal))
Example #7
0
 def eventTags(self, event):
     tags = []
     if event.recurrence:
         tags.append(translate(_("recurrent"), context=self.request))
     if (not same(event.__parent__, self.context)
             and event.__parent__ is not None):
         # We have an event from an overlaid calendar.
         tag = translate(_(
             'from the calendar of ${calendar_owner}',
             mapping={'calendar_owner': event.__parent__.__parent__.title}),
                         context=self.request)
         # We assume that event.__parent__ is a Calendar which belongs to
         # an object with a title.
         tags.append(tag)
     return tags
Example #8
0
 def eventTags(self, event):
     tags = []
     if event.recurrence:
         tags.append(translate(_("recurrent"), context=self.request))
     if (not same(event.__parent__, self.context)
         and event.__parent__ is not None):
         # We have an event from an overlaid calendar.
         tag = translate(_('from the calendar of ${calendar_owner}',
                           mapping={'calendar_owner':
                                    event.__parent__.__parent__.title}),
                         context=self.request)
         # We assume that event.__parent__ is a Calendar which belongs to
         # an object with a title.
         tags.append(tag)
     return tags
Example #9
0
 def contains(self, principal):
     from schooltool.person.interfaces import IPerson
     from schooltool.app.browser import same  # XXX
     person = IPerson(principal, None)
     owner = IPerson(self.context, None)
     return person is not None and same(person, owner)
Example #10
0
 def contains(self, principal):
     from schooltool.person.interfaces import IPerson
     from schooltool.app.browser import same # XXX
     person = IPerson(principal, None)
     owner = IPerson(self.context, None)
     return person is not None and same(person, owner)