Ejemplo n.º 1
0
def index():
    """
    Show the user the organizations he/she can access
    """
    query = (db.organization.id > 0)
    query &= (
        auth.accessible_query('read', db.organization) |
        auth.accessible_query('update', db.organization))

    orgs = db(query).select(db.organization.ALL)

    return locals()


@auth.requires(
    auth.has_permission('read', db.organization, request.args(0)) or
    auth.has_permission('update', db.organization, request.args(0))
)
def view():
    """
    Show the list of desks in this org
    """
    org = db.organization(request.args(0))
    session.org_id = org.id
    return locals()


@auth.requires(auth.has_permission('update', db.organization, request.args(0)))
def edit():
    org = db.organization(request.args(0))
    tbl = db.organization
Ejemplo n.º 2
0
def isOwner(dash_id=None):
    dash_id = dash_id or request.args(0)
    return auth.has_permission(
        'owner', db.dashboard, record_id=dash_id)
Ejemplo n.º 3
0
@auth.requires_login()
def index():
    """
    Show the user the organizations he/she can access
    """
    query = (db.organization.id > 0)
    query &= (auth.accessible_query('read', db.organization)
              | auth.accessible_query('update', db.organization))

    orgs = db(query).select(db.organization.ALL)

    return locals()


@auth.requires(
    auth.has_permission('read', db.organization, request.args(0))
    or auth.has_permission('update', db.organization, request.args(0)))
def view():
    """
    Show the list of desks in this org
    """
    org = db.organization(request.args(0))
    session.org_id = org.id
    return locals()


@auth.requires(auth.has_permission('update', db.organization, request.args(0)))
def edit():
    org = db.organization(request.args(0))
    tbl = db.organization
    tbl.users.readable = False
Ejemplo n.º 4
0
def users():
    desk = db.desk(request.args(0))
    session.desk_id = desk.id

    org = db.organization(session.org_id)

    if request.args(1):
        my_user = db.auth_user(request.args(1))

        fld_read_desk = Field('read_desk', 'boolean')
        fld_read_desk.label = T("Read '%s' content", (desk.name, ))
        fld_read_desk.comment = T(
            "Allow the user read only access to the desk item list.")
        fld_read_desk.default = auth.has_permission('read', db.desk, desk.id,
                                                    my_user.id)

        fld_update_items = Field('update_items', 'boolean')
        fld_update_items.label = T("Read/Update items in '%s'", (desk.name, ))
        fld_update_items.comment = T(
            "Allow the user make modifications to the items in the desk.")
        fld_update_items.default = auth.has_permission('update_items', db.desk,
                                                       desk.id, my_user.id)

        fld_push_items = Field('push_items', 'boolean')
        fld_push_items.label = T("Push items into '%s'", (desk.name, ))
        fld_push_items.comment = T(
            """Allow the user move items into the desk.""")
        fld_push_items.default = auth.has_permission('push_items', db.desk,
                                                     desk.id, my_user.id)

        fld_update_desk = Field('update_desk', 'boolean')
        fld_update_desk.label = T("Update/Manage '%s'", (desk.name, ))
        fld_update_desk.comment = T("""
            Allow the user to manage/administrate this desk. Use with caution.
            """)
        fld_update_desk.default = auth.has_permission('update', db.desk,
                                                      desk.id, my_user.id)

        form = SQLFORM.factory(fld_read_desk,
                               fld_update_items,
                               fld_push_items,
                               fld_update_desk,
                               table_name='desk_perms')

        if form.process().accepted:
            if form.vars.read_desk:
                # give perm
                auth.add_permission(auth.user_group(my_user.id), 'read',
                                    db.desk, desk.id)
            else:
                auth.del_permission(auth.user_group(my_user.id), 'read',
                                    db.desk, desk.id)

            if form.vars.update_items:
                # give perm
                auth.add_permission(auth.user_group(my_user.id),
                                    'update_items', db.desk, desk.id)
            else:
                auth.del_permission(auth.user_group(my_user.id),
                                    'update_items', db.desk, desk.id)

            if form.vars.push_items:
                # give perm
                auth.add_permission(auth.user_group(my_user.id), 'push_items',
                                    db.desk, desk.id)
            else:
                auth.del_permission(auth.user_group(my_user.id), 'push_items',
                                    db.desk, desk.id)

            if form.vars.update_desk:
                # give perm
                auth.add_permission(auth.user_group(my_user.id), 'update_desk',
                                    db.desk, desk.id)
            else:
                auth.del_permission(auth.user_group(my_user.id), 'update_desk',
                                    db.desk, desk.id)

            redirect(URL('desk', 'users', args=[desk.id]))

        response.view = "desk/user_perms.html"
    else:
        # select user view
        query = (db.auth_user.id > 0)
        query &= (db.auth_user.id.belongs(org.users))

        my_users = db(query).select()

    return locals()
Ejemplo n.º 5
0
# -*- coding: utf-8 -*-
if False:
    from gluon import current, URL, SQLFORM, redirect
    from gluon import IS_NOT_EMPTY, Field
    request = current.request
    response = current.response
    session = current.session
    cache = current.cache
    T = current.T
    from db import db, auth
    from dc import application


@auth.requires(
    lambda: auth.has_permission('owner', db.desk, request.args(0)) or
    (auth.has_permission('read', db.desk, request.args(0)) or auth.
     has_permission('update', db.desk, request.args(0)) or auth.has_permission(
         'update_items', db.desk, request.args(0))))
def index():
    """Show the list of items in this desk"""
    desk = db.desk(request.args(0))

    if desk.id == application.getUserDesk().id:
        session.org_id = None
    session.desk_id = desk.id
    # used to mark items for package creation
    session.marked_items = []

    return locals()

Ejemplo n.º 6
0
def users():
    desk = db.desk(request.args(0))
    session.desk_id = desk.id

    org = db.organization(session.org_id)

    if request.args(1):
        my_user = db.auth_user(request.args(1))

        fld_read_desk = Field('read_desk', 'boolean')
        fld_read_desk.label = T("Read '%s' content", (desk.name,))
        fld_read_desk.comment = T(
            "Allow the user read only access to the desk item list.")
        fld_read_desk.default = auth.has_permission(
            'read', db.desk, desk.id, my_user.id)

        fld_update_items = Field('update_items', 'boolean')
        fld_update_items.label = T("Read/Update items in '%s'", (desk.name,))
        fld_update_items.comment = T(
            "Allow the user make modifications to the items in the desk.")
        fld_update_items.default = auth.has_permission(
            'update_items', db.desk, desk.id, my_user.id)

        fld_push_items = Field('push_items', 'boolean')
        fld_push_items.label = T("Push items into '%s'", (desk.name,))
        fld_push_items.comment = T(
            """Allow the user move items into the desk."""
        )
        fld_push_items.default = auth.has_permission(
            'push_items', db.desk, desk.id, my_user.id)

        fld_update_desk = Field('update_desk', 'boolean')
        fld_update_desk.label = T("Update/Manage '%s'", (desk.name,))
        fld_update_desk.comment = T(
            """
            Allow the user to manage/administrate this desk. Use with caution.
            """
        )
        fld_update_desk.default = auth.has_permission(
            'update', db.desk, desk.id, my_user.id)

        form = SQLFORM.factory(
            fld_read_desk,
            fld_update_items,
            fld_push_items,
            fld_update_desk,
            table_name='desk_perms'
        )

        if form.process().accepted:
            if form.vars.read_desk:
                # give perm
                auth.add_permission(
                    auth.user_group(my_user.id), 'read', db.desk, desk.id)
            else:
                auth.del_permission(
                    auth.user_group(my_user.id), 'read', db.desk, desk.id)

            if form.vars.update_items:
                # give perm
                auth.add_permission(
                    auth.user_group(my_user.id), 'update_items', db.desk,
                    desk.id)
            else:
                auth.del_permission(
                    auth.user_group(my_user.id), 'update_items', db.desk,
                    desk.id)

            if form.vars.push_items:
                # give perm
                auth.add_permission(
                    auth.user_group(my_user.id), 'push_items', db.desk,
                    desk.id)
            else:
                auth.del_permission(
                    auth.user_group(my_user.id), 'push_items', db.desk,
                    desk.id)

            if form.vars.update_desk:
                # give perm
                auth.add_permission(
                    auth.user_group(my_user.id), 'update_desk', db.desk,
                    desk.id)
            else:
                auth.del_permission(
                    auth.user_group(my_user.id), 'update_desk', db.desk,
                    desk.id)

            redirect(URL('desk', 'users', args=[desk.id]))

        response.view = "desk/user_perms.html"
    else:
        # select user view
        query = (db.auth_user.id > 0)
        query &= (db.auth_user.id.belongs(org.users))

        my_users = db(query).select()

    return locals()
Ejemplo n.º 7
0
# -*- coding: utf-8 -*-
if False:
    from gluon import current, URL, SQLFORM, redirect
    from gluon import IS_NOT_EMPTY, Field
    request = current.request
    response = current.response
    session = current.session
    cache = current.cache
    T = current.T
    from db import db, auth
    from dc import application


@auth.requires(
    lambda: auth.has_permission('owner', db.desk, request.args(0)) or
    (auth.has_permission('read', db.desk, request.args(0)) or
     auth.has_permission('update', db.desk, request.args(0)) or
     auth.has_permission('update_items', db.desk, request.args(0)))
)
def index():
    """Show the list of items in this desk"""
    desk = db.desk(request.args(0))

    if desk.id == application.getUserDesk().id:
        session.org_id = None
    session.desk_id = desk.id
    if session.marked_items is None:
        session.marked_items = []

    return locals()