Exemplo n.º 1
0
    def initializeArchetype(self, **kwargs):
        OrderedBaseFolder.initializeArchetype(self, **kwargs)

        if self.isTemporary():
            log('initializeArchetype> Not yet.')
            return

        rt = getToolByName(self, 'portal_rotatool')

        self.setReportersForSitting(self.REQUEST.form['ReportersForSitting'])
        reporters = self.getReportersForSitting()

        # Get the lead/extra times as a fraction of a day (1440 minutes)
        lead_time_fraction = rt.getReportingLeadTime() / 1440.00
        extra_time_fraction = (
                (rt.getExtraTakes() * rt.getTakeLength()) / 1440.00)

        start_time = self.getRotaFrom() - lead_time_fraction
        end_time = self.getRotaTo() + extra_time_fraction
        duration_in_minutes = (end_time - start_time) * 1440.00
        iterations = duration_in_minutes / rt.getTakeLength()
        reporter_index = 0

        # Generate the rota
        for n in range(iterations):
            if reporter_index == len(reporters):
                reporter_index = 0
            r = reporters[reporter_index]
            reporter_index += 1
            ri_id = self.generateUniqueId('RotaItem')
            self.invokeFactory('RotaItem', ri_id, Reporter=r.UID())
Exemplo n.º 2
0
    def initializeArchetype(self, **kwargs):
        OrderedBaseFolder.initializeArchetype(self, **kwargs)

        if self.isTemporary():
            log('initializeArchetype> Not yet.')
            return

        rt = getToolByName(self, 'portal_rotatool')

        self.setReportersForSitting(self.REQUEST.form['ReportersForSitting'])
        reporters = self.getReportersForSitting()

        # Get the lead/extra times as a fraction of a day (1440 minutes)
        lead_time_fraction = rt.getReportingLeadTime() / 1440.00
        extra_time_fraction = ((rt.getExtraTakes() * rt.getTakeLength()) /
                               1440.00)

        start_time = self.getRotaFrom() - lead_time_fraction
        end_time = self.getRotaTo() + extra_time_fraction
        duration_in_minutes = (end_time - start_time) * 1440.00
        iterations = duration_in_minutes / rt.getTakeLength()
        reporter_index = 0

        # Generate the rota
        for n in range(iterations):
            if reporter_index == len(reporters):
                reporter_index = 0
            r = reporters[reporter_index]
            reporter_index += 1
            ri_id = self.generateUniqueId('RotaItem')
            self.invokeFactory('RotaItem', ri_id, Reporter=r.UID())
Exemplo n.º 3
0
 def publishRota(self, state_change, kw):
     """ Do everything that needs to be done when the Rota is
     published.
     """
     # Finalize RotaItems (make them non-editable).
     items = self.contentValues(
                 filter={'portal_type': 'RotaItem'})
     workflow_tool = getToolByName(self, 'portal_workflow')
     for item in items:
         try:
             workflow_tool.doActionFor(item, 'finalize',
                     comment='Finalize as part of Rota publication')
         except WorkflowException, e:
             log('publishRota> %s: %s'%(self.getId(), e))
Exemplo n.º 4
0
 def publishRota(self, state_change, kw):
     """ Do everything that needs to be done when the Rota is
     published.
     """
     # Finalize RotaItems (make them non-editable).
     items = self.contentValues(filter={'portal_type': 'RotaItem'})
     workflow_tool = getToolByName(self, 'portal_workflow')
     for item in items:
         try:
             workflow_tool.doActionFor(
                 item,
                 'finalize',
                 comment='Finalize as part of Rota publication')
         except WorkflowException, e:
             log('publishRota> %s: %s' % (self.getId(), e))
Exemplo n.º 5
0
 def reindexOnReorder(self, parent):
     """ Catalog ordering support """
     # Copied from PloneTool.reindexOnReorder
     # We're just indexing some more.
     mtool = getToolByName(self, 'portal_membership')
     if not mtool.checkPermission(permissions.ModifyPortalContent, parent):
         return
     cat = getToolByName(self, 'portal_catalog')
     cataloged_objs = cat(path = {'query':'/'.join(parent.getPhysicalPath()),
                                  'depth': 1})
     for brain in cataloged_objs:
         obj = brain.getObject()
         # Don't crash when the catalog has contains a stale entry
         if obj is not None:
             cat.reindexObject(obj,['getObjPositionInParent', 'Title'],)
         else:
             # Perhaps we should remove the bad entry as well?
             log('Object in catalog no longer exists, cannot reindex: %s.'% brain.getPath())
Exemplo n.º 6
0
 def _notifySubscribers(self):
     """ Send the summary rota document to all the subscribers
     """
     # TODO Consider making this more sophisticated: allow teams as
     # subscribers (mail to all team members); maybe use one of the
     # newsletter products to do the sending more reliably, with more
     # features ..
     rota_tool = getToolByName(self, 'portal_rotatool')
     properties_tool = getToolByName(self, 'portal_properties')
     subscribers = rota_tool.getRotaSubscribers()
     rota_document = getattr(self, 'rota-document')
     if not rota_document:
         return
     for s in subscribers:
         email = s.getEmail()
         if email:
             self.MailHost.send(rota_document.getRawText(), email,
                     properties_tool.email_from_address,
                     subject=rota_document.Title())
         else:
             log('notifySubscribers> %s has no email address'%s.Title())
Exemplo n.º 7
0
 def _notifySubscribers(self):
     """ Send the summary rota document to all the subscribers
     """
     # TODO Consider making this more sophisticated: allow teams as
     # subscribers (mail to all team members); maybe use one of the
     # newsletter products to do the sending more reliably, with more
     # features ..
     rota_tool = getToolByName(self, 'portal_rotatool')
     properties_tool = getToolByName(self, 'portal_properties')
     subscribers = rota_tool.getRotaSubscribers()
     rota_document = getattr(self, 'rota-document')
     if not rota_document:
         return
     for s in subscribers:
         email = s.getEmail()
         if email:
             self.MailHost.send(rota_document.getRawText(),
                                email,
                                properties_tool.email_from_address,
                                subject=rota_document.Title())
         else:
             log('notifySubscribers> %s has no email address' % s.Title())
Exemplo n.º 8
0
 def reindexOnReorder(self, parent):
     """ Catalog ordering support """
     # Copied from PloneTool.reindexOnReorder
     # We're just indexing some more.
     mtool = getToolByName(self, 'portal_membership')
     if not mtool.checkPermission(permissions.ModifyPortalContent, parent):
         return
     cat = getToolByName(self, 'portal_catalog')
     cataloged_objs = cat(path={
         'query': '/'.join(parent.getPhysicalPath()),
         'depth': 1
     })
     for brain in cataloged_objs:
         obj = brain.getObject()
         # Don't crash when the catalog has contains a stale entry
         if obj is not None:
             cat.reindexObject(
                 obj,
                 ['getObjPositionInParent', 'Title'],
             )
         else:
             # Perhaps we should remove the bad entry as well?
             log('Object in catalog no longer exists, cannot reindex: %s.' %
                 brain.getPath())