Exemple #1
0
    def test_uiaction_category_reg_fail(self):
        class Content(object):
            __name__ = ''

        ptah.uiaction(Content, 'action1', 'Action 10', category='test')
        ptah.uiaction(Content, 'action1', 'Action 11', category='test')
        self.assertRaises(ConfigurationConflictError, self.init_ptah)
Exemple #2
0
    def test_uiaction_conflicts(self):
        class Content(object):
            __name__ = ''

        ptah.uiaction(Content, 'action1', 'Action 1')
        ptah.uiaction(Content, 'action1', 'Action 1')
        self.assertRaises(ConfigurationConflictError, self.init_ptah)
Exemple #3
0
    def test_uiaction_category_reg_fail(self):
        class Content(object):
            __name__ = ''

        ptah.uiaction(Content, 'action1', 'Action 10', category='test')
        ptah.uiaction(Content, 'action1', 'Action 11', category='test')
        self.assertRaises(ConfigurationConflictError, self.init_ptah)
Exemple #4
0
    def test_uiaction_conflicts(self):
        class Content(object):
            __name__ = ''

        ptah.uiaction(Content, 'action1', 'Action 1')
        ptah.uiaction(Content, 'action1', 'Action 1')
        self.assertRaises(ConfigurationConflictError, self.init_ptah)
Exemple #5
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')
Exemple #6
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')
Exemple #7
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'], '')
Exemple #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'], '')
Exemple #9
0
    def test_uiaction(self):
        class Content(object):
            __name__ = ''

        ptah.uiaction(Content, 'action1', 'Action 1')
        self.init_ptah()

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

        self.assertEqual(len(actions), 1)
        self.assertEqual(actions[0]['id'], 'action1')
Exemple #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'})
Exemple #11
0
    def test_uiaction(self):
        class Content(object):
            __name__ = ''

        ptah.uiaction(Content, 'action1', 'Action 1')
        self.init_ptah()

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

        self.assertEqual(len(actions), 1)
        self.assertEqual(actions[0]['id'], 'action1')
Exemple #12
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'})
Exemple #13
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')
Exemple #14
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')
Exemple #15
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')
Exemple #16
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')
Exemple #17
0
    def test_uiaction_category_reg(self):
        class Content(object):
            __name__ = ''

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

        self.init_ptah()

        actions = ptah.list_uiactions(Content(), self.request)
        self.assertEqual(len(actions), 1)
        self.assertEqual(actions[0]['title'], 'Action 10')

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

        self.assertEqual(len(actions), 1)
        self.assertEqual(actions[0]['title'], 'Action 11')
Exemple #18
0
    def test_uiaction_category_reg(self):
        class Content(object):
            __name__ = ''

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

        self.init_ptah()

        actions = ptah.list_uiactions(Content(), self.request)
        self.assertEqual(len(actions), 1)
        self.assertEqual(actions[0]['title'], 'Action 10')

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

        self.assertEqual(len(actions), 1)
        self.assertEqual(actions[0]['title'], 'Action 11')
Exemple #19
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)
Exemple #20
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)
Exemple #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
Exemple #22
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
Exemple #23
0
    @form.button('Search', actype=form.AC_PRIMARY)
    def search(self):
        data, error = self.extract()

        if not data['term']:
            self.message('Please specify search term', 'warning')
            return

        self.request.session['apps-sharing-term'] = data['term']
        return HTTPFound(location=self.request.url)


ptah.uiaction(
    ptah.ILocalRolesAware, **{
        'id': 'view',
        'title': 'View',
        'action': '',
        'category': MANAGE_APP_CATEGORY,
        'sort_weight': 1.0
    })

ptah.uiaction(
    ptah.ILocalRolesAware, **{
        'id': 'sharing',
        'title': 'Sharing',
        'action': 'sharing.html',
        'category': MANAGE_APP_CATEGORY,
        'sort_weight': 10.0
    })
Exemple #24
0
""" default actions """
import ptah
import ptahcms

CATEGORY = 'cms'

ptah.uiaction(
    ptahcms.Content,
    **{'id': 'view',
       'title': 'View',
       'action': '',
       'permission': ptahcms.View,
       'sort_weight': 0.5,
       'category': CATEGORY})

ptah.uiaction(
    ptahcms.Content,
    **{'id': 'edit',
       'title': 'Edit',
       'action': 'edit.html',
       'permission': ptahcms.ModifyContent,
       'sort_weight': 0.6,
       'category': CATEGORY})

ptah.uiaction(
    ptahcms.Container,
    **{'id': 'adding',
       'title': 'Add content',
       'action': '+/',
       'permission': ptahcms.AddContent,
       'sort_weight': 5.0,
Exemple #25
0
class ThemeGalleryPolicy(ptah.cms.ApplicationPolicy):

    __acl__ = permissions.GALLERY_ACL


class ThemeGallery(ptah.cms.ApplicationRoot):

    __type__ = ptah.cms.Type('ploud-themegallery',
                             'Theme gallery',
                             filter_content_types=True,
                             allowed_content_types=('diazo-theme', ))


ptah.uiaction(ThemeGallery,
              'submited',
              'Submited themes',
              action='submitted.html',
              permission=permissions.ManageGallery)

ptah.uiaction(ThemeGallery,
              'private',
              'Private themes',
              action='private.html',
              permission=permissions.ManageGallery)

ptah.uiaction(ThemeGallery,
              'mythemes',
              'My themes',
              action='mythemes.html',
              permission=permissions.AddTheme)
Exemple #26
0
""" default actions """
import ptah
import ptahcms

ptah.uiaction(
    ptahcms.IContent, **{'id': 'view',
                          'title': 'View',
                          'action': '',
                          'permission': ptahcms.View,
                          'sort_weight': 0.5})

ptah.uiaction(
    ptahcms.IContent, **{'id': 'edit',
                          'title': 'Edit',
                          'action': 'edit.html',
                          'permission': ptahcms.ModifyContent,
                          'sort_weight': 0.6})


ptah.uiaction(
    ptahcms.IContainer, **{'id': 'adding',
                            'title': 'Add content',
                            'action': '+/',
                            'permission': ptahcms.AddContent,
                            'sort_weight': 5.0})


ptah.uiaction(
    ptah.ILocalRolesAware, **{'id': 'sharing',
                              'title': 'Sharing',
                              'action': 'sharing.html',
Exemple #27
0
import ptah
from ptah import form
from pyramid.view import view_config
from pyramid.httpexceptions import HTTPFound

import events
import permissions
from gallery import ThemeGallery
from theme import Theme, ThemeSchema
from themefile import ThemeFile
from themefile import ThemeFileSchema

ptah.uiaction(Theme,
              'submit',
              'Submit',
              action='submit.html',
              permission=ptah.cms.ModifyContent)

ptah.uiaction(Theme,
              'publish',
              'Publish',
              action='publish.html',
              permission=permissions.ManageGallery,
              condition=lambda content, request: content.status != 'public')

ptah.uiaction(Theme,
              'retract',
              'Retract',
              action='retract.html',
              permission=permissions.RetractTheme)
Exemple #28
0
class ThemeGalleryPolicy(ptah.cms.ApplicationPolicy):

    __acl__ = permissions.GALLERY_ACL


class ThemeGallery(ptah.cms.ApplicationRoot):

    __type__ = ptah.cms.Type(
        'ploud-themegallery',
        'Theme gallery',
        filter_content_types = True,
        allowed_content_types = ('diazo-theme',))


ptah.uiaction(
    ThemeGallery, 'submited', 'Submited themes',
    action='submitted.html', permission = permissions.ManageGallery)

ptah.uiaction(
    ThemeGallery, 'private', 'Private themes',
    action='private.html', permission = permissions.ManageGallery)

ptah.uiaction(
    ThemeGallery, 'mythemes', 'My themes',
    action='mythemes.html', permission = permissions.AddTheme)

ptah.uiaction(
    ThemeGallery, 'upload-theme', 'Upload new',
    action='newtheme.html', permission = permissions.AddTheme)

Exemple #29
0
            context.__local_roles__ = local_roles

        return res

    @form.button('Search', actype=form.AC_PRIMARY)
    def search(self):
        data, error = self.extract()

        if not data['term']:
            self.message('Please specify search term', 'warning')
            return

        self.request.session['apps-sharing-term'] = data['term']
        return HTTPFound(location = self.request.url)


ptah.uiaction(
    ptah.ILocalRolesAware, **{'id': 'view',
                              'title': 'View',
                              'action': '',
                              'category': MANAGE_APP_CATEGORY,
                              'sort_weight': 1.0})

ptah.uiaction(
    ptah.ILocalRolesAware, **{'id': 'sharing',
                              'title': 'Sharing',
                              'action': 'sharing.html',
                              'category': MANAGE_APP_CATEGORY,
                              'sort_weight': 10.0})
Exemple #30
0
            if key.startswith('grp'):
                user = ptahcrowd.CrowdGroup.get_byid(key[3:])
            else:
                user = ptahcrowd.CrowdUser.get_byid(key)
            if user is not None:
                user.__parent__ = self
                user.__resource_url__ = None

                request = self.request
                request.request_iface = request.registry.getUtility(
                    IRouteRequest, name=ptahcrowd.CROWD_APP_ID)

                return user

        raise KeyError(key)


ptah.uiaction(
    CrowdModule, **{'id': 'users',
                    'title': 'Users',
                    'action': '',
                    'sort_weight': 0.5,
                    'category': ptah.manage.MANAGE_ACTIONS})

ptah.uiaction(
    CrowdModule, **{'id': 'groups',
                    'title': 'Groups',
                    'action': 'groups.html',
                    'sort_weight': 0.6,
                    'category': ptah.manage.MANAGE_ACTIONS})
import ptah
from ptah import form
from pyramid.view import view_config
from pyramid.httpexceptions import HTTPFound

import events
import permissions
from gallery import ThemeGallery
from theme import Theme, ThemeSchema
from themefile import ThemeFile
from themefile import ThemeFileSchema


ptah.uiaction(
    Theme, 'submit', 'Submit',
    action='submit.html', permission=ptah.cms.ModifyContent)

ptah.uiaction(
    Theme, 'publish', 'Publish',
    action='publish.html', permission=permissions.ManageGallery,
    condition=lambda content, request: content.status!='public')

ptah.uiaction(
    Theme, 'retract', 'Retract',
    action='retract.html', permission = permissions.RetractTheme)

ptah.uiaction(
    Theme, 'upload', 'Upload file',
    action='uploadfile.html', permission = permissions.AddThemeFile)