Ejemplo n.º 1
0
    def test_uiaction_category(self):
        class Content(object):
            __name__ = ''

        ptah.uiaction(Content, 'action1', 'Action 1',
                      category='test')

        self.init_ptah()

        actions = ptah.list_uiactions(Content(), self.request)
        self.assertEqual(len(actions), 0)

        actions = ptah.list_uiactions(Content(), self.request, category='test')

        self.assertEqual(len(actions), 1)
        self.assertEqual(actions[0]['id'], 'action1')
Ejemplo n.º 2
0
    def test_uiaction_category(self):
        class Content(object):
            __name__ = ''

        ptah.uiaction(Content, 'action1', 'Action 1',
                      category='test')

        self.init_ptah()

        actions = ptah.list_uiactions(Content(), self.request)
        self.assertEqual(len(actions), 0)

        actions = ptah.list_uiactions(Content(), self.request, category='test')

        self.assertEqual(len(actions), 1)
        self.assertEqual(actions[0]['id'], 'action1')
Ejemplo n.º 3
0
 def update(self):
     self.actions = [ac for ac in 
                     ptah.list_uiactions(self.context, self.request)
                     if ac['id'] != 'view']
     
     self.files = list(self.context.values())
     self.files.sort(key = lambda f: f.created)
     self.files.reverse()
Ejemplo n.º 4
0
    def test_uiaction_url(self):
        class Content(object):
            __name__ = ''

        ptah.uiaction(Content, 'action1', 'Action 1', action='test.html')
        self.init_ptah()

        actions = ptah.list_uiactions(Content(), self.request)
        self.assertEqual(actions[0]['url'], 'http://example.com/test.html')
Ejemplo n.º 5
0
    def update(self):
        self.actions = [
            ac for ac in ptah.list_uiactions(self.context, self.request)
            if ac['id'] != 'view'
        ]

        self.files = list(self.context.values())
        self.files.sort(key=lambda f: f.created)
        self.files.reverse()
Ejemplo n.º 6
0
    def update(self):
        self.actions = [ac for ac in
                        ptah.list_uiactions(self.context, self.request)
                        if ac['id'] != 'view']

        size = self.getCount()
        self.current = current = self.getCurrent()

        self.pages, self.prev, self.next = self.page(size, current)
        self.themes = self.listThemes(*self.page.offset(current))
Ejemplo n.º 7
0
    def test_uiaction_url(self):

        class Content(object):
            __name__ = ''

        ptah.uiaction(Content, 'action1', 'Action 1', action='test.html')
        self.init_ptah()

        actions = ptah.list_uiactions(Content(), self.request)
        self.assertEqual(actions[0]['url'], 'http://example.com/test.html')
Ejemplo n.º 8
0
    def test_uiaction_url_no_request(self):

        class Content(object):
            __name__ = ''

        ptah.uiaction(Content, 'action1', 'Action 1', action='test.html')
        self.init_ptah()

        actions = ptah.list_uiactions(Content(), registry=self.registry)
        self.assertEqual(actions[0]['url'], '')
Ejemplo n.º 9
0
    def test_uiaction_url_no_request(self):

        class Content(object):
            __name__ = ''

        ptah.uiaction(Content, 'action1', 'Action 1', action='test.html')
        self.init_ptah()

        actions = ptah.list_uiactions(Content(), registry=self.registry)
        self.assertEqual(actions[0]['url'], '')
Ejemplo n.º 10
0
    def test_uiaction_userdata(self):
        class Content(object):
            __name__ = ''

        ptah.uiaction(Content, 'view', 'View', testinfo='test')

        self.init_ptah()

        actions = ptah.list_uiactions(Content(), self.request)

        self.assertEqual(actions[0]['data'], {'testinfo': 'test'})
Ejemplo n.º 11
0
    def update(self):
        self.actions = [
            ac for ac in ptah.list_uiactions(self.context, self.request)
            if ac['id'] != 'view'
        ]

        size = self.getCount()
        self.current = current = self.getCurrent()

        self.pages, self.prev, self.next = self.page(size, current)
        self.themes = self.listThemes(*self.page.offset(current))
Ejemplo n.º 12
0
    def test_uiaction_condition(self):

        class Content(object):
            __name__ = ''

        allow = False
        def condition(content, request):
            return allow

        ptah.uiaction(
            Content, 'action1', 'Action 1',
            action='test.html', condition=condition)

        self.init_ptah()

        actions = ptah.list_uiactions(Content(), self.request)
        self.assertEqual(len(actions), 0)

        allow = True
        actions = ptah.list_uiactions(Content(), self.request)
        self.assertEqual(len(actions), 1)
Ejemplo n.º 13
0
    def test_uiaction_condition(self):

        class Content(object):
            __name__ = ''

        allow = False
        def condition(content, request):
            return allow

        ptah.uiaction(
            Content, 'action1', 'Action 1',
            action='test.html', condition=condition)

        self.init_ptah()

        actions = ptah.list_uiactions(Content(), self.request)
        self.assertEqual(len(actions), 0)

        allow = True
        actions = ptah.list_uiactions(Content(), self.request)
        self.assertEqual(len(actions), 1)
Ejemplo n.º 14
0
    def test_uiaction_userdata(self):

        class Content(object):
            __name__ = ''

        ptah.uiaction(Content, 'view', 'View', testinfo='test')

        self.init_ptah()

        actions = ptah.list_uiactions(Content(), self.request)

        self.assertEqual(actions[0]['data'], {'testinfo': 'test'})
Ejemplo n.º 15
0
    def update(self):
        self.user = ptah.resolve(self.context.userid)
        self.manage_url = get_manage_url(self.request)

        mod = self.request.context
        while not isinstance(mod, PtahModule):
            mod = getattr(mod, '__parent__', None)
            if mod is None: # pragma: no cover
                break

        self.module = mod
        self.actions = ptah.list_uiactions(mod, self.request, MANAGE_ACTIONS)
Ejemplo n.º 16
0
    def test_uiaction_sort_weight(self):
        class Content(object):
            __name__ = ''

        ptah.uiaction(Content, 'view', 'View', sort_weight=1.0)
        ptah.uiaction(Content, 'action', 'Action', sort_weight=2.0)

        self.init_ptah()

        actions = ptah.list_uiactions(Content(), self.request)

        self.assertEqual(actions[0]['id'], 'view')
        self.assertEqual(actions[1]['id'], 'action')
Ejemplo n.º 17
0
    def test_uiaction_custom_url(self):
        class Content(object):
            __name__ = ''

        def customAction(content, request):
            return 'http://github.com/ptahproject'

        ptah.uiaction(Content, 'action1', 'Action 1', action=customAction)

        self.init_ptah()

        actions = ptah.list_uiactions(Content(), self.request)
        self.assertEqual(actions[0]['url'], 'http://github.com/ptahproject')
Ejemplo n.º 18
0
    def test_uiaction_custom_url(self):

        class Content(object):
            __name__ = ''

        def customAction(content, request):
            return 'http://github.com/ptahproject'

        ptah.uiaction(Content, 'action1', 'Action 1', action=customAction)

        self.init_ptah()

        actions = ptah.list_uiactions(Content(), self.request)
        self.assertEqual(actions[0]['url'], 'http://github.com/ptahproject')
Ejemplo n.º 19
0
    def test_uiaction_sort_weight(self):

        class Content(object):
            __name__ = ''

        ptah.uiaction(Content, 'view', 'View', sort_weight=1.0)
        ptah.uiaction(Content, 'action', 'Action', sort_weight=2.0)

        self.init_ptah()

        actions = ptah.list_uiactions(Content(), self.request)

        self.assertEqual(actions[0]['id'], 'view')
        self.assertEqual(actions[1]['id'], 'action')
Ejemplo n.º 20
0
    def test_uiaction_permission(self):

        class Content(object):
            __name__ = ''

        allow = False
        def check_permission(permission, content, request=None, throw=False):
            return allow

        ptah.uiaction(Content, 'action1', 'Action 1', permission='View')

        self.init_ptah()

        orig_cp = ptah.check_permission
        ptah.check_permission = check_permission

        actions = ptah.list_uiactions(Content(), self.request)
        self.assertEqual(len(actions), 0)

        allow = True
        actions = ptah.list_uiactions(Content(), self.request)
        self.assertEqual(len(actions), 1)

        ptah.check_permission = orig_cp
Ejemplo n.º 21
0
    def test_uiaction_permission(self):
        class Content(object):
            __name__ = ''

        allow = False

        def check_permission(permission, content, request=None, throw=False):
            return allow

        ptah.uiaction(Content, 'action1', 'Action 1', permission='View')

        self.init_ptah()

        orig_cp = ptah.check_permission
        ptah.check_permission = check_permission

        actions = ptah.list_uiactions(Content(), self.request)
        self.assertEqual(len(actions), 0)

        allow = True
        actions = ptah.list_uiactions(Content(), self.request)
        self.assertEqual(len(actions), 1)

        ptah.check_permission = orig_cp
Ejemplo n.º 22
0
 def update(self):
     self.actions = [
         ac for ac in ptah.list_uiactions(self.context, self.request)
         if ac['id'] != 'view'
     ]
Ejemplo n.º 23
0
 def update(self):
     self.actions = ptah.list_uiactions(self.context, self.request,
                                        CATEGORY)
Ejemplo n.º 24
0
 def update(self):
     self.actions = [ac for ac in 
                     ptah.list_uiactions(self.context, self.request)
                     if ac['id'] != 'view']
Ejemplo n.º 25
0
 def update(self):
     self.actions = ptah.list_uiactions(self.context, self.request)
Ejemplo n.º 26
0
Archivo: apps.py Proyecto: runyaga/ptah
 def update(self):
     self.actions = ptah.list_uiactions(
         self.context, self.request, MANAGE_APP_CATEGORY)