Exemple #1
0
def _get_auditable_ancestor(obj):
    parent = obj.__parent__
    while parent:
        if IFeatureAudit.providedBy(parent):
            return parent
        else:
            parent = getattr(parent, "__parent__", None)
Exemple #2
0
def _get_auditable_ancestor(obj):
    parent = obj.__parent__
    while parent:
        if IFeatureAudit.providedBy(parent):
            return parent
        else:
            parent = getattr(parent, "__parent__", None)
Exemple #3
0
 def update(self, transition_id=None):
     if IWorkspaceContainer.providedBy(self.context.__parent__):
         self._old_url = WorkspaceAbsoluteURLView(
             self.context, self.request)()
     workflow = interfaces.IWorkflow(self.context)
     if transition_id:
         transition = workflow.get_transition(transition_id)
         title = translate(_(transition.title), context=self.request)
         self.status = translate(
             _(u"Confirmation required for workflow transition: '${title}'",
                 mapping={"title": title}
             ), 
             context=self.request)
     self.setupActions(transition_id)
     
     if (IBungeniParliamentaryContent.providedBy(self.context) and
             get_mask(self.context) == "manual" and 
             not self.context.registry_number
         ):
         self.form_fields = self.form_fields.omit("note", "date_active")
     else:
         self.form_fields = self.form_fields.omit("registry_number")
     
     if not self.actions: 
         self.form_fields = self.form_fields.omit("note", "date_active")
     elif not IFeatureAudit.providedBy(self.context):
         self.form_fields = self.form_fields.omit("note", "date_active")
     # !+SUPERFLUOUS_ObejctModifiedEvent(mr, nov-2011) the following update()
     # is causing a ModifiedEvent to be fired, causing a modify change to be 
     # logged (while this workflow change should be just that).
     super(WorkflowActionViewlet, self).update()
Exemple #4
0
 def update(self, transition_id=None):
     # set up viewlets; the view is rendered from viewlets for
     # historic reasons; this may be refactored anytime.
     if IFeatureAudit.providedBy(self.context):
         self.history_viewlet = WorkflowHistoryViewlet(
             self.context, self.request, self, None)
         self.history_viewlet.update()
     self.action_viewlet = WorkflowActionViewlet(
         self.context, self.request, self, None)
     self.action_viewlet.update(transition_id=transition_id)
Exemple #5
0
    def get_min_date_active(self):
        """Determine the min_date_active to validate against.
        """
        def is_workflowed_and_draft(instance):
            """is item workflowed, and if so is it in a logical draft state?
            """
            if interfaces.IWorkflowed.providedBy(instance):
                wf = interfaces.IWorkflow(instance)
                return instance.status in wf.get_state_ids(tagged=["draft"],
                                                           restrict=False)
            return False

        instance = removeSecurityProxy(self.context)
        min_date_active = None

        if IFeatureAudit.providedBy(self.context):
            # !+PASTDATAENTRY(mr, jun-2011) offers a way to enter past data
            # for workflowed items via the UI -- note, ideally we should be
            # able to also control the item's creation active_date.
            #
            # If a workflowed item is in draft state, we do NOT take the
            # date_active of its last change as the min_date_active, but
            # let that min fallback to parliament's creation date...
            if not is_workflowed_and_draft(instance):
                changes = get_changes(instance, "workflow")
                if changes:
                    # then use the "date_active" of the most recent entry
                    min_date_active = changes[-1].date_active

        if not min_date_active:
            # ok, try determine a min_date_active in another way, namely via the
            # start_date of the "parliament" the instance "lives" in...
            parliament = models.utils.get_parliament(
                common.getattr_ancestry(
                    instance, "parliament_id"))  #!+parent_ref="head"?
            min_date_active = datetime.datetime.combine(
                parliament.start_date, datetime.time())

        # As the precision of the UI-submitted datetime is only to the minute,
        # we adjust min_date_active by a margin of 59 secs earlier to avoid
        # issues of doing 2 transitions in quick succession (within same minute)
        # the 2nd of which could be taken to be too old...
        return min_date_active - datetime.timedelta(seconds=59)
Exemple #6
0
 def get_min_date_active(self):
     """Determine the min_date_active to validate against.
     """
     
     def is_workflowed_and_draft(instance):
         """is item workflowed, and if so is it in a logical draft state?
         """
         if interfaces.IWorkflowed.providedBy(instance):
             wf = interfaces.IWorkflow(instance)
             return instance.status in wf.get_state_ids(tagged=["draft"],
                 restrict=False)
         return False
     
     instance = removeSecurityProxy(self.context)
     min_date_active = None
     
     if IFeatureAudit.providedBy(self.context):
         # !+PASTDATAENTRY(mr, jun-2011) offers a way to enter past data 
         # for workflowed items via the UI -- note, ideally we should be 
         # able to also control the item's creation active_date.
         #
         # If a workflowed item is in draft state, we do NOT take the 
         # date_active of its last change as the min_date_active, but
         # let that min fallback to parliament's creation date...
         if not is_workflowed_and_draft(instance):
             changes = get_changes(instance, "workflow")
             if changes:
  	            # then use the "date_active" of the most recent entry
                 min_date_active = changes[-1].date_active
     
     if not min_date_active:
         # ok, try determine a min_date_active in another way, namely via the
         # start_date of the "parliament" the instance "lives" in...
         parliament = models.utils.get_parliament(
             common.getattr_ancestry(instance, "parliament_id")) #!+parent_ref="head"?
         min_date_active = datetime.datetime.combine(
             parliament.start_date, datetime.time())
     
     # As the precision of the UI-submitted datetime is only to the minute, 
     # we adjust min_date_active by a margin of 59 secs earlier to avoid 
     # issues of doing 2 transitions in quick succession (within same minute) 
     # the 2nd of which could be taken to be too old...
     return min_date_active - datetime.timedelta(seconds=59)
Exemple #7
0
    def getMenuItems(self, context, request):
        results = []
        _url = url.absoluteURL(context, request)
        if IFeatureDownload.providedBy(context):
            doc_templates = self.documentTemplates(request.locale)
            for doc_type in document_types:
                if doc_templates:
                    for template in doc_templates:
                        i18n_title = translate_i18n(globals()["i18n_%s" %
                                                              doc_type])
                        results.append(
                            dict(title="%s [%s]" %
                                 (i18n_title, template.get("title")),
                                 description="",
                                 action="%s/%s?template=%s" %
                                 (_url, doc_type, template.get("location")),
                                 selected=False,
                                 extra={
                                     "id":
                                     "download-%s-%s" %
                                     (doc_type,
                                      misc.slugify(template.get("location"))),
                                     "class":
                                     "download-document"
                                 },
                                 icon=None,
                                 submenu=None))

                else:
                    results.append(
                        dict(title=doc_type,
                             description=doc_type,
                             action="%s/%s" % (_url, doc_type),
                             selected=False,
                             icon=None,
                             extra={},
                             submenu=None))
        if interfaces.IRSSRepresentationLayer.providedBy(request):
            for doc_type in xml_types:
                if doc_type == TYPE_AKOMANTOSO:
                    if IAlchemistContainer.providedBy(context):
                        if not IFeatureDownload.implementedBy(
                                context.domain_model):
                            continue
                elif doc_type == TYPE_RSS:
                    # rss for content types only availble for auditables
                    if (IFeatureDownload.providedBy(context)
                            and not IFeatureAudit.providedBy(context)):
                        continue
                    elif (IAlchemistContainer.providedBy(context)
                          and not IFeatureAudit.implementedBy(
                              context.domain_model)):
                        continue
                results.append(
                    dict(title=globals()["i18n_%s" % doc_type],
                         description="",
                         action="%s/feed.%s" % (_url, doc_type),
                         selected=False,
                         icon=None,
                         extra={"id": "download-%s" % doc_type},
                         submenu=None))
        return results
Exemple #8
0
 def getMenuItems(self, context, request):
     results = []
     _url = url.absoluteURL(context, request)
     if IFeatureDownload.providedBy(context):
         doc_templates = self.documentTemplates(request.locale)
         for doc_type in document_types:
             if doc_templates:
                 for template in doc_templates:
                     i18n_title = translate_i18n(globals()["i18n_%s" % doc_type])
                     results.append(dict(
                         title="%s [%s]" % (i18n_title,template.get("title")),
                         description="",
                         action="%s/%s?template=%s" % (_url, doc_type, 
                             template.get("location")),
                         selected=False,
                         extra = {
                             "id": "download-%s-%s" %(doc_type,
                                 misc.slugify(template.get("location"))
                             ),
                             "class": "download-document"
                         },
                         icon=None,
                         submenu=None
                     ))
                 
             else:
                 results.append(dict(
                     title = doc_type,
                     description=doc_type,
                     action = "%s/%s" %(_url, doc_type),
                     selected=False,
                     icon=None,
                     extra={},
                     submenu=None
                 ))
     if interfaces.IRSSRepresentationLayer.providedBy(request):
         for doc_type in xml_types:
             if doc_type == TYPE_AKOMANTOSO:
                 if IAlchemistContainer.providedBy(context):
                     if not IFeatureDownload.implementedBy(
                             context.domain_model
                         ):
                         continue
             elif doc_type == TYPE_RSS:
                 # rss for content types only availble for auditables
                 if (IFeatureDownload.providedBy(context) and not
                         IFeatureAudit.providedBy(context)
                     ):
                     continue
                 elif (IAlchemistContainer.providedBy(context) and not 
                         IFeatureAudit.implementedBy(context.domain_model)
                     ):
                     continue
             results.append(dict(
                     title = globals()["i18n_%s" % doc_type],
                     description="",
                     action = "%s/feed.%s" %(_url, doc_type),
                     selected=False,
                     icon=None,
                     extra={
                         "id": "download-%s" % doc_type
                     },
                     submenu=None
             ))
     return results