コード例 #1
0
ファイル: viewlets.py プロジェクト: eea/eea.workflow
    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
コード例 #2
0
ファイル: viewlets.py プロジェクト: razvanch/eea.workflow
    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
コード例 #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
コード例 #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()
コード例 #5
0
ファイル: archive.py プロジェクト: zotya/eea.workflow
    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()
コード例 #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))
コード例 #7
0
ファイル: archive.py プロジェクト: zotya/eea.workflow
 def __call__(self):
     rv = NamedVocabulary('eea.workflow.reasons')    #TODO: rename to eea.workflow.archive_reasons
     reasons = rv.getVocabularyDict(self.context)
     return reasons
コード例 #8
0
 def __call__(self):
     rv = NamedVocabulary('eea.workflow.reasons'
                          )  #TODO: rename to eea.workflow.archive_reasons
     reasons = rv.getVocabularyDict(self.context)
     return reasons
コード例 #9
0
 def __call__(self):
     rv = NamedVocabulary('eea.workflow.reasons')
     reasons = rv.getVocabularyDict(self.context)
     return reasons
コード例 #10
0
 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'})
コード例 #11
0
ファイル: archive.py プロジェクト: razvanch/eea.workflow
    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))