def item_history_info(self, item):
     obj = item.getObject()
     chv = ContentHistoryView(obj, obj.REQUEST)
     history = chv.fullHistory()
     if history is not None:
         return history[0]
     else:
         obj_history = {'time': obj.modified,
                        'actor': obj.Creator}
         return obj_history
Exemple #2
0
def get_revision_history(brain_or_object):
    """Get the revision history for the given brain or context.

    :param brain_or_object: A single catalog brain or content object
    :type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
    :returns: Workflow history
    :rtype: obj
    """
    obj = get_object(brain_or_object)
    chv = ContentHistoryView(obj, safe_getattr(obj, "REQUEST", None))
    return chv.fullHistory()
Exemple #3
0
def get_revision_history(brain_or_object):
    """Get the revision history for the given brain or context.

    :param brain_or_object: A single catalog brain or content object
    :type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
    :returns: Workflow history
    :rtype: obj
    """
    obj = get_object(brain_or_object)
    chv = ContentHistoryView(obj, safe_getattr(obj, "REQUEST", None))
    return chv.fullHistory()
Exemple #4
0
 def history_info(self):
     context = aq_inner(self.context)
     recent = self.recent_items()
     if len(recent) > 0:
         obj = recent[0].getObject()
         if (IItemRepository.providedBy(context) or
                 IOrderableItem.providedBy(context) or
                 IOrderableItem.providedBy(obj)):
             history = {'time': obj.modified}
         else:
             chv = ContentHistoryView(obj, obj.REQUEST)
             history_list = chv.fullHistory()
             history = history_list[0]
         return history
Exemple #5
0
    def gethistory(self):
        context = self.context
        HistoryView = ContentHistoryView(context, context.REQUEST)

        content_history = HistoryView.fullHistory() or []
        L = []
        for history in content_history:
            tipo = history.get('type','')
            if tipo == 'workflow':
                date = history.get('time','').strftime('%d/%m/%Y')
            else:
                date = datetime.fromtimestamp(history.get('time','')).strftime('%d/%m/%Y')

            actor = history.get('actor',{})
            if actor:
                actor = actor.get('username','')
            if actor:
                actor = self.get_prefs_user(actor)
            if actor:
                L.append({'actor': actor.get('name',''),
                          # 'action':  history.get('transition_title',''),
                          # 'type': tipo,
                          'date':date,})
        return L
 def gethistory(self):
     context = self.context
     HistoryView = ContentHistoryView(context, context.REQUEST)
     return HistoryView.fullHistory()
Exemple #7
0
    def update(self):
        D = {}
        portal_workflow = getToolByName(self.context, "portal_workflow")
        reference_catalog = getToolByName(self.context, "reference_catalog")
        portal_membership = getToolByName(self.context, "portal_membership")

        uid = self.request.form.get('uid','')

        user_admin = portal_membership.getMemberById('admin')

        # stash the existing security manager so we can restore it
        old_security_manager = getSecurityManager()

        #usuario temporario para o tipo de conteudo ATFILE, que não tem History
        username_logged = "XXusertmpXX"

        # create a new context, as the owner of the folder
        newSecurityManager(self.request,user_admin)

        context = reference_catalog.lookupObject(uid)
        if context:
            HistoryView = ContentHistoryView(context, context.REQUEST)
            try:context_owner = context.getOwner().getUserName()
            except:context_owner = 'administrador'
            image_content = ''
            if hasattr(context, 'getImageIcone'):
                img = context.getImageIcone()
                image_content = img.replace(self.context.absolute_url(),'')

            try:
                status = portal_workflow.getInfoFor(context, 'review_state')
            except WorkflowException:
                status = 'no workflow'

            content_history = HistoryView.fullHistory() or []
            L = []
            for history in content_history:
                tipo = history.get('type','')
                if tipo == 'workflow':
                    date = history.get('time','').strftime('%Y-%m-%d %H:%M:%S')
                else:
                    date = datetime.fromtimestamp(history.get('time','')).strftime('%Y-%m-%d %H:%M:%S')

                actor = history.get('actor',{})
                if not actor:
                    actor = ''

                L.append({'actor': actor,
                          'action':  history.get('transition_title',''),
                          'type': tipo,
                          'date':date,})

            if context.portal_type == 'File':
                D['history'] = [{'actor': username_logged,
                                 'action':  'Edited',
                                 'type': context.portal_type,
                                 'date':context.bobobase_modification_time().strftime('%Y-%m-%d %H:%M:%S'),}]
            else:
                D['history'] = L

            D['details'] = {'uid': context.UID(),
                            'type': context.portal_type,
                            'title': context.Title(),
                            'description':context.Description(),
                            'owner': context_owner,
                            'date_created':context.creation_date.strftime('%Y-%m-%d %H:%M:%S'),
                            'date_modified':context.bobobase_modification_time().strftime('%Y-%m-%d %H:%M:%S'),
                            'workflow': status,
                            'url': '/'+'/'.join(context.getPhysicalPath()[2:]),
                            'image': image_content}

            excludeField = ['title','description','blogger_bio','blogger_name','blog_entry', 'location', 'language']
            typesField = ['string','text','lines','boolean','datetime','reference']

            extra_details = {}

            for field in context.Schema().fields():
                if not field.getName() in excludeField and\
                   field.type in typesField and\
                   field.accessor:

                    accessor = getattr(context, field.accessor)

                    if accessor:
                        accessor = accessor()

                        if isinstance(accessor, (tuple, list)):
                            accessor = str(list(accessor))
                        elif isinstance(accessor, bool):
                            accessor = str(accessor)
                        elif isinstance(accessor, (datetime, DateTime)):
                            accessor = accessor.strftime('%d/%m/%Y %H:%M:%S')
                        elif field.type == 'reference':
                            if accessor:
                                accessor = accessor.UID()

                        if isinstance(accessor, str) or isinstance(accessor, unicode):
                            extra_details[field.getName()] = accessor


            D['extra_details'] = extra_details
        else:
            D['deleted'] = True

        # restore the original context
        setSecurityManager(old_security_manager)

        self.retorno = D