Exemple #1
0
    def update(self):
        """ Update viewlet
        """
        info = IObjectArchivator(self.context)

        rv = NamedVocabulary('eea.workflow.reasons')
        vocab = rv.getVocabularyDict(self.context)

        archive_info = dict(initiator=info.initiator,
                            archive_date=info.archive_date,
                            reason=vocab.get(info.reason, "Other"),
                            custom_message=info.custom_message)

        self.info = archive_info
Exemple #2
0
    def update(self):
        """ Update viewlet
        """
        info = IObjectArchivator(self.context)

        rv = NamedVocabulary('eea.workflow.reasons')
        vocab = rv.getVocabularyDict(self.context)

        archive_info = dict(initiator=info.initiator,
                            archive_date=info.archive_date,
                            reason=vocab.get(info.reason, "Other"),
                            custom_message=info.custom_message)

        self.info = archive_info
Exemple #3
0
    def info(self):
        """ Info used in view
        """
        info = IObjectArchivator(self.context)

        rv = NamedVocabulary('eea.workflow.reasons')
        vocab = rv.getVocabularyDict(self.context)

        archive_info = dict(initiator=info.initiator,
                            archive_date=info.archive_date,
                            reason=vocab.get(info.reason, "Other"),
                            custom_message=info.custom_message)

        return archive_info
Exemple #4
0
    def archive(self,
                context,
                initiator=None,
                reason=None,
                custom_message=None):
        """Archive the object"""

        now = DateTime()
        alsoProvides(context, IObjectArchived)
        context.setExpirationDate(now)

        self.archive_date = now
        self.initiator = initiator
        self.custom_message = custom_message
        self.reason = reason

        wftool = getToolByName(context, 'portal_workflow')
        mtool = getToolByName(context, 'portal_membership')

        state = wftool.getInfoFor(context, 'review_state')
        actor = mtool.getAuthenticatedMember().getId()

        rv = NamedVocabulary('eea.workflow.reasons')
        vocab = rv.getVocabularyDict(context)
        reason = vocab.get('reason', "Other")

        if custom_message:
            reason += u" (%s)" % custom_message

        comments = (u"Archived by %(actor)s on %(date)s by request "
                    u"from %(initiator)s with reason: %(reason)s" % {
                        'actor': actor,
                        'initiator': initiator,
                        'reason': reason,
                        'date': now.ISO8601(),
                    })

        for wfname in context.workflow_history.keys():
            history = context.workflow_history[wfname]
            history += ({
                'action': 'Archive',
                'review_state': state,
                'actor': actor,
                'comments': comments,
                'time': now,
            }, )
            context.workflow_history[wfname] = history

        context.workflow_history._p_changed = True
        context.reindexObject()
Exemple #5
0
    def archive(self, context, initiator=None, reason=None, custom_message=None):
        """Archive the object"""

        now = DateTime()
        alsoProvides(context, IObjectArchived)
        context.setExpirationDate(now)

        self.archive_date   = now
        self.initiator      = initiator
        self.custom_message = custom_message
        self.reason         = reason

        wftool = getToolByName(context, 'portal_workflow')
        mtool = getToolByName(context, 'portal_membership')

        state = wftool.getInfoFor(context, 'review_state')
        actor = mtool.getAuthenticatedMember().getId()

        rv = NamedVocabulary('eea.workflow.reasons')
        vocab = rv.getVocabularyDict(context)
        reason = vocab.get('reason', "Other")

        if custom_message:
            reason += u" (%s)" % custom_message

        comments = (u"Archived by %(actor)s on %(date)s by request "
                    u"from %(initiator)s with reason: %(reason)s" % {
                        'actor':actor,
                        'initiator':initiator,
                        'reason':reason,
                        'date':now.ISO8601(),
                    })

        for wfname in context.workflow_history.keys():
            history = context.workflow_history[wfname]
            history += ({
                'action':'Archive',
                'review_state':state,
                'actor':actor,
                'comments':comments,
                'time':now,
                },)
            context.workflow_history[wfname] = history

        context.workflow_history._p_changed = True
        context.reindexObject()
Exemple #6
0
    def archive(self,
                context,
                initiator=None,
                reason=None,
                custom_message=None,
                archive_date=None):
        """Archive the object
        :param context: given object that should be archived
        :param initiator: the user id or name which commissioned the archival
        :param reason: reason id for which the object was archived
        :param custom_message: Custom message explaining why the object was
               archived
        :param archive_date: DateTime object which sets the expiration date of
               the object
        """
        initiator = safe_unicode(initiator)
        reason = safe_unicode(reason)
        custom_message = safe_unicode(custom_message)
        wftool = getToolByName(context, 'portal_workflow')
        has_workflow = wftool.getChainFor(context)
        if not has_workflow:
            # NOP
            return
        date = archive_date and archive_date or DateTime()
        alsoProvides(context, IObjectArchived)
        context.setExpirationDate(date)

        # refactor this setting from here, without these assignments to self
        # the test for is_archived fails
        self.archive_date = date
        self.initiator = initiator
        self.custom_message = custom_message
        self.reason = reason

        state = wftool.getInfoFor(context, 'review_state')
        mtool = getToolByName(context, 'portal_membership')
        actor = mtool.getAuthenticatedMember().getId()

        rv = NamedVocabulary('eea.workflow.reasons')
        vocab = rv.getVocabularyDict(context)
        reason = vocab.get(reason, "Other")

        if custom_message:
            reason += u" (%s)" % custom_message
        comments = (u"Archived by %(actor)s on %(date)s by request "
                    u"from %(initiator)s with reason: %(reason)s" % {
                        'actor': actor,
                        'initiator': initiator,
                        'reason': reason,
                        'date': date.ISO8601()
                    })

        for wfname in context.workflow_history.keys():
            history = context.workflow_history[wfname]
            history += ({
                'action': 'Archive',
                'review_state': state,
                'actor': actor,
                'comments': comments,
                'time': date,
            }, )
            context.workflow_history[wfname] = history

        context.workflow_history._p_changed = True
        context.reindexObject()
        notify(Purge(context))
Exemple #7
0
 def __call__(self):
     rv = NamedVocabulary('eea.workflow.reasons')    #TODO: rename to eea.workflow.archive_reasons
     reasons = rv.getVocabularyDict(self.context)
     return reasons
Exemple #8
0
 def __call__(self):
     rv = NamedVocabulary('eea.workflow.reasons'
                          )  #TODO: rename to eea.workflow.archive_reasons
     reasons = rv.getVocabularyDict(self.context)
     return reasons
Exemple #9
0
 def __call__(self):
     rv = NamedVocabulary('eea.workflow.reasons')
     reasons = rv.getVocabularyDict(self.context)
     return reasons
 def test_namedvocab(self):
     from Products.ATVocabularyManager.namedvocabulary import NamedVocabulary
     nv = NamedVocabulary('name-accuracy')
     d = nv.getVocabularyDict(self.portal)
     self.assertEquals(d, {'accurate': 'accurate', 'false': 'false', 'inaccurate': 'inaccurate'})
Exemple #11
0
    def archive(self, context, initiator=None, reason=None, custom_message=None,
                archive_date=None):
        """Archive the object
        :param context: given object that should be archived
        :param initiator: the user id or name which commissioned the archival
        :param reason: reason id for which the object was archived
        :param custom_message: Custom message explaining why the object was
               archived
        :param archive_date: DateTime object which sets the expiration date of
               the object
        """
        initiator = safe_unicode(initiator)
        reason = safe_unicode(reason)
        custom_message = safe_unicode(custom_message)
        wftool = getToolByName(context, 'portal_workflow')
        has_workflow = wftool.getChainFor(context)
        if not has_workflow:
            # NOP
            return
        date = archive_date and archive_date or DateTime()
        alsoProvides(context, IObjectArchived)
        context.setExpirationDate(date)

        # refactor this setting from here, without these assignments to self
        # the test for is_archived fails
        self.archive_date = date
        self.initiator = initiator
        self.custom_message = custom_message
        self.reason = reason

        state = wftool.getInfoFor(context, 'review_state')
        mtool = getToolByName(context, 'portal_membership')
        actor = mtool.getAuthenticatedMember().getId()

        rv = NamedVocabulary('eea.workflow.reasons')
        vocab = rv.getVocabularyDict(context)
        reason = vocab.get(reason, "Other")

        if custom_message:
            reason += u" (%s)" % custom_message
        comments = (u"Archived by %(actor)s on %(date)s by request "
                    u"from %(initiator)s with reason: %(reason)s" % {
                        'actor': actor,
                        'initiator': initiator,
                        'reason': reason,
                        'date': date.ISO8601()
                    })

        for wfname in context.workflow_history.keys():
            history = context.workflow_history[wfname]
            history += ({
                            'action': 'Archive',
                            'review_state': state,
                            'actor': actor,
                            'comments': comments,
                            'time': date,
                        },)
            context.workflow_history[wfname] = history

        context.workflow_history._p_changed = True
        context.reindexObject()
        notify(Purge(context))