Exemplo n.º 1
0
    def testAddObjectMakesDirty(self):
        from euphorie.content.behaviour.dirtytree import isDirty

        self.loginAsPortalOwner()
        survey = self.create()
        survey.invokeFactory("euphorie.module", "module")
        self.assertEqual(isDirty(survey), True)
Exemplo n.º 2
0
    def morph(group, survey):
        published = survey.id == group.published
        info = {
            "id": survey.id,
            "title": survey.title,
            "url": survey.absolute_url(),
            "published": published,
            "publication_date": published and survey.published or None,
            "current": aq_base(survey) is current_version,
            "modified": isDirty(survey),
            "versions": [],
        }
        if not allow_history:
            return info

        history = repository.getHistoryMetadata(survey)
        if history:
            for id in range(history.getLength(countPurged=False) - 1, -1, -1):
                meta = history.retrieve(id, countPurged=False)["metadata"][
                    "sys_metadata"
                ]
                info["versions"].append(
                    {
                        "timestamp": datetime.datetime.fromtimestamp(meta["timestamp"]),
                        "history_id": meta["parent"]["history_id"],
                        "version_id": meta["parent"]["version_id"],
                        "location_id": meta["parent"]["location_id"],
                    }
                )
            info["versions"].sort(key=lambda x: x["timestamp"], reverse=True)
        return info
Exemplo n.º 3
0
    def morph(group, survey):
        info = {
            'id': survey.id,
            'title': survey.title,
            'url': survey.absolute_url(),
            'published': survey.id == group.published,
            'current': aq_base(survey) is current_version,
            'modified': isDirty(survey),
            'versions': []
        }
        if not allow_history:
            return info

        history = repository.getHistoryMetadata(survey)
        if history:
            for id in range(history.getLength(countPurged=False) - 1, -1, -1):
                meta = history.retrieve(
                    id, countPurged=False)["metadata"]["sys_metadata"]
                info["versions"].append({
                    'timestamp':
                    datetime.datetime.fromtimestamp(meta["timestamp"]),
                    'history_id':
                    meta["parent"]["history_id"],
                    'version_id':
                    meta["parent"]["version_id"],
                    'location_id':
                    meta["parent"]["location_id"]
                })
            info["versions"].sort(key=lambda x: x["timestamp"], reverse=True)
        return info
Exemplo n.º 4
0
 def testDeleteObjetMakesDiry(self):
     from euphorie.content.behaviour.dirtytree import isDirty
     from euphorie.content.behaviour.dirtytree import clearDirty
     self.loginAsPortalOwner()
     survey = self.create()
     survey.invokeFactory("euphorie.module", "module")
     clearDirty(survey)
     del survey["module"]
     self.assertEqual(isDirty(survey), True)
Exemplo n.º 5
0
    def testDeleteObjetMakesDiry(self):
        from euphorie.content.behaviour.dirtytree import isDirty
        from euphorie.content.behaviour.dirtytree import clearDirty

        self.loginAsPortalOwner()
        survey = self.create()
        survey.invokeFactory("euphorie.module", "module")
        clearDirty(survey)
        del survey["module"]
        self.assertEqual(isDirty(survey), True)
Exemplo n.º 6
0
 def testModifyObjectMakesDirty(self):
     from euphorie.content.behaviour.dirtytree import isDirty
     from euphorie.content.behaviour.dirtytree import clearDirty
     from zope.event import notify
     from zope.lifecycleevent import ObjectModifiedEvent
     self.loginAsPortalOwner()
     survey = self.create()
     survey.invokeFactory("euphorie.module", "module")
     clearDirty(survey)
     notify(ObjectModifiedEvent(survey["module"]))
     self.assertEqual(isDirty(survey), True)
Exemplo n.º 7
0
    def testModifyObjectMakesDirty(self):
        from euphorie.content.behaviour.dirtytree import isDirty
        from euphorie.content.behaviour.dirtytree import clearDirty
        from zope.event import notify
        from zope.lifecycleevent import ObjectModifiedEvent

        self.loginAsPortalOwner()
        survey = self.create()
        survey.invokeFactory("euphorie.module", "module")
        clearDirty(survey)
        notify(ObjectModifiedEvent(survey["module"]))
        self.assertEqual(isDirty(survey), True)
Exemplo n.º 8
0
    def morph(group, survey):
        info = {'id': survey.id,
                'title': survey.title,
                'url': survey.absolute_url(),
                'published': survey.id == group.published,
                'current': aq_base(survey) is current_version,
                'modified': isDirty(survey),
                'versions': []}
        if not allow_history:
            return info

        history = repository.getHistoryMetadata(survey)
        if history:
            for id in range(history.getLength(countPurged=False) - 1, -1, -1):
                meta = history.retrieve(id,
                        countPurged=False)["metadata"]["sys_metadata"]
                info["versions"].append({
                    'timestamp': datetime.datetime.fromtimestamp(
                        meta["timestamp"]),
                    'history_id': meta["parent"]["history_id"],
                    'version_id': meta["parent"]["version_id"],
                    'location_id': meta["parent"]["location_id"]})
            info["versions"].sort(key=lambda x: x["timestamp"], reverse=True)
        return info
Exemplo n.º 9
0
 def testModifyObjectMakesDirty(self):
     survey = self.create()
     survey.invokeFactory("euphorie.module", "module")
     clearDirty(survey)
     notify(ObjectModifiedEvent(survey["module"]))
     self.assertEqual(isDirty(survey), True)
Exemplo n.º 10
0
 def testDeleteObjetMakesDiry(self):
     survey = self.create()
     survey.invokeFactory("euphorie.module", "module")
     clearDirty(survey)
     del survey["module"]
     self.assertEqual(isDirty(survey), True)
Exemplo n.º 11
0
 def testAddObjectMakesDirty(self):
     survey = self.create()
     survey.invokeFactory("euphorie.module", "module")
     self.assertEqual(isDirty(survey), True)
Exemplo n.º 12
0
 def testStartClean(self):
     survey = self.create()
     self.assertEqual(isDirty(survey), False)
Exemplo n.º 13
0
 def testAddObjectMakesDirty(self):
     from euphorie.content.behaviour.dirtytree import isDirty
     self.loginAsPortalOwner()
     survey = self.create()
     survey.invokeFactory("euphorie.module", "module")
     self.assertEqual(isDirty(survey), True)
Exemplo n.º 14
0
 def testStartClean(self):
     from euphorie.content.behaviour.dirtytree import isDirty
     self.loginAsPortalOwner()
     survey = self.create()
     self.assertEqual(isDirty(survey), False)
Exemplo n.º 15
0
    def testStartClean(self):
        from euphorie.content.behaviour.dirtytree import isDirty

        self.loginAsPortalOwner()
        survey = self.create()
        self.assertEqual(isDirty(survey), False)