Exemplo n.º 1
0
 def test_faicons(self):
   icon = FAIcon('check')
   self.assertEquals(
     icon.__html__(),
     u'<i class="fa fa-check"></i>')
Exemplo n.º 2
0
# those buttons are made to have valid edit actions, but will not be shown in
# edit forms: they must be availabe only during POST
ADD_USER_BUTTON = ButtonAction(
    'form',
    'add_user',
    condition=lambda v: request.method == 'POST',
    title=_l('Add'),
    btn_class='primary',
)

REMOVE_USER_BUTTON = ButtonAction(
    'form',
    'remove_user',
    condition=lambda v: request.method == 'POST',
    btn_class='danger',
    icon=FAIcon('times'),
    title="",
)


class GroupView(GroupBase, views.ObjectView):
    template = 'admin/group_view.html'

    def breadcrumb(self):
        label = render_template_string('<em>{{ g }}</em>', g=self.obj.name)
        return BreadcrumbItem(label=label, url='', description=self.obj.name)

    @property
    def template_kwargs(self):
        security = get_service('security')
        kw = super(GroupView, self).template_kwargs
Exemplo n.º 3
0
     url=lambda ctx: url_for(".folder_view", folder_id=ctx["object"].id),
 ),
 # view
 FolderAction(
     "documents:content",
     "view",
     _l("List content"),
     icon="list",
     url=lambda ctx: url_for(".folder_view", folder_id=ctx["object"].id),
 ),
 # Descendants
 FolderAction(
     "documents:content",
     "descendants",
     _l("View descendants"),
     icon=FAIcon("code-fork fa-rotate-90"),
     url=lambda ctx: url_for(".descendants_view", folder_id=ctx["object"].id),
 ),
 # upload
 FolderModalAction(
     "documents:content",
     "upload_files",
     _l("Upload file(s)"),
     icon="upload",
     url="#modal-upload-files",
     permission=WRITE,
 ),
 # edit
 FolderModalAction(
     "documents:content",
     "edit",
Exemplo n.º 4
0
     url=lambda ctx: url_for(".folder_view", folder_id=ctx['object'].id),
 ),
 # view
 FolderAction(
     'documents:content',
     'view',
     _l(u'List content'),
     icon='list',
     url=lambda ctx: url_for(".folder_view", folder_id=ctx['object'].id),
 ),
 # Descendants
 FolderAction(
     'documents:content',
     'descendants',
     _l(u'View descendants'),
     icon=FAIcon('code-fork fa-rotate-90'),
     url=lambda ctx: url_for(".descendants_view",
                             folder_id=ctx['object'].id),
 ),
 # upload
 FolderModalAction('documents:content',
                   'upload_files',
                   _l('Upload file(s)'),
                   icon='upload',
                   url='#modal-upload-files',
                   permission=WRITE),
 # edit
 FolderModalAction('documents:content',
                   'edit',
                   _l('Edit properties'),
                   icon='pencil',
Exemplo n.º 5
0
def is_admin(context):
    security = get_service("security")
    return security.has_role(current_user, Admin, object=context.get("object"))


_actions = [
    CalendarAction("calendar:global",
                   "new_event",
                   _l("Create a new event"),
                   icon="plus"),
    CalendarAction("calendar:global",
                   "index",
                   _l("Upcoming events"),
                   icon="list"),
    EventAction("calendar:event",
                "event",
                _l("View event"),
                icon=FAIcon("eye")),
    EventAction("calendar:event",
                "event_edit",
                _l("Edit event"),
                icon=FAIcon("pencil")),
]


def register_actions(state):
    if not actions.installed(state.app):
        return
    with state.app.app_context():
        actions.register(*_actions)
Exemplo n.º 6
0
     "forum:thread",
     "delete",
     _l("Delete"),
     condition=lambda ctx: is_admin(ctx) and not_closed(ctx),
     url="#modal-delete",
     icon="trash",
 ),
 #
 ThreadAction(
     "forum:thread",
     "close",
     _l("Close thread"),
     url="close",
     template_string=_close_template_action,
     condition=lambda ctx: is_admin(ctx) and not_closed(ctx),
     icon=FAIcon("lock"),
 ),
 ThreadAction(
     "forum:thread",
     "reopen",
     _l("Re-open thread"),
     url="close",
     template_string=_close_template_action,
     condition=lambda ctx: is_admin(ctx) and is_closed(ctx),
     icon=FAIcon("unlock"),
 ),
 ThreadAction("forum:thread",
              "attachments",
              _l("Attachments"),
              url="attachments",
              icon="file"),
Exemplo n.º 7
0
def test_faicons() -> None:
    icon = FAIcon("check")
    assert icon.__html__() == '<i class="fa fa-check"></i>'
Exemplo n.º 8
0
def is_admin(context):
    svc = current_app.services['security']
    return svc.has_role(current_user, Admin, object=context.get('object'))


_actions = [
    CalendarAction('calendar:global',
                   'new_event',
                   _l('Create a new event'),
                   icon='plus'),
    CalendarAction('calendar:global',
                   'index',
                   _l('Upcoming events'),
                   icon='list'),
    EventAction('calendar:event',
                'event',
                _l('View event'),
                icon=FAIcon('eye')),
    EventAction('calendar:event',
                'event_edit',
                _l('Edit event'),
                icon=FAIcon('pencil')),
]


def register_actions(state):
    if not actions.installed(state.app):
        return
    with state.app.app_context():
        actions.register(*_actions)
Exemplo n.º 9
0
 def test_faicons(self):
     icon = FAIcon('check')
     self.assertEqual(icon.__html__(), u'<i class="fa fa-check"></i>')
Exemplo n.º 10
0
# those buttons are made to have valid edit actions, but will not be shown in
# edit forms: they must be availabe only during POST
ADD_USER_BUTTON = ButtonAction(
    "form",
    "add_user",
    condition=lambda v: request.method == "POST",
    title=_l("Add"),
    btn_class="primary",
)

REMOVE_USER_BUTTON = ButtonAction(
    "form",
    "remove_user",
    condition=lambda v: request.method == "POST",
    btn_class="danger",
    icon=FAIcon("times"),
    title="",
)


class GroupView(GroupBase, views.ObjectView):
    template = "admin/group_view.html"

    def breadcrumb(self):
        label = render_template_string("<em>{{ g }}</em>", g=self.obj.name)
        return BreadcrumbItem(label=label, url="", description=self.obj.name)

    @property
    def template_kwargs(self):
        security = get_service("security")
        kw = super().template_kwargs
Exemplo n.º 11
0
                _l("Edit"),
                endpoint=".page_edit",
                icon="pencil"),
 WikiPageModalAction(
     "wiki:page",
     "upload_attachment",
     _l("Upload an attachment"),
     url="#upload-files",
     icon="plus",
 ),
 WikiPageAction(
     "wiki:page",
     "source",
     _l("Source"),
     endpoint=".page_source",
     icon=FAIcon("code"),
 ),
 WikiPageAction("wiki:page",
                "changes",
                _l("Changes"),
                endpoint=".page_changes",
                icon="time"),
 WikiPageModalAction("wiki:page",
                     "delete",
                     _l("Delete"),
                     url="#modal-delete",
                     icon="trash"),
 WikiAction("wiki:global",
            "new",
            _l("New page"),
            endpoint=".page_new",
Exemplo n.º 12
0
def test_faicons():
    icon = FAIcon("check")
    assert icon.__html__() == '<i class="fa fa-check"></i>'
Exemplo n.º 13
0
                icon='eye-open'),
 WikiPageAction('wiki:page',
                'edit',
                _l(u'Edit'),
                endpoint='.page_edit',
                icon='pencil'),
 WikiPageModalAction('wiki:page',
                     'upload_attachment',
                     _l(u'Upload an attachment'),
                     url='#upload-files',
                     icon='plus'),
 WikiPageAction('wiki:page',
                'source',
                _l(u'Source'),
                endpoint='.page_source',
                icon=FAIcon('code')),
 WikiPageAction('wiki:page',
                'changes',
                _l(u'Changes'),
                endpoint='.page_changes',
                icon='time'),
 WikiPageModalAction('wiki:page',
                     'delete',
                     _l(u'Delete'),
                     url='#modal-delete',
                     icon='trash'),
 WikiAction('wiki:global',
            'new',
            _l(u'New page'),
            endpoint='.page_new',
            icon='plus'),
Exemplo n.º 14
0
    ForumModalAction(
        'forum:thread',
        'delete',
        _l(u'Delete'),
        condition=lambda ctx: is_admin(ctx) and not_closed(ctx),
        url='#modal-delete',
        icon='trash'),
    #
    ThreadAction(
        'forum:thread',
        'close',
        _l('Close thread'),
        url='close',
        template_string=_close_template_action,
        condition=lambda ctx: is_admin(ctx) and not_closed(ctx),
        icon=FAIcon('lock')),
    ThreadAction(
        'forum:thread',
        'reopen',
        _l('Re-open thread'),
        url='close',
        template_string=_close_template_action,
        condition=lambda ctx: is_admin(ctx) and is_closed(ctx),
        icon=FAIcon('unlock')),
    ThreadAction(
        'forum:thread',
        'attachments',
        _l(u'Attachments'),
        url='attachments',
        icon='file'),)