Example #1
0
def to_profile_active(ob, info):
    acl = [
        (Allow, ob.creator, MEMBER_PERMS + ('view_only', )),
    ]
    acl.append(
        (Allow, 'group.KarlUserAdmin', ADMINISTRATOR_PERMS + ('view_only', )))
    acl.append(
        (Allow, 'group.KarlAdmin', ADMINISTRATOR_PERMS + ('view_only', )))
    acl.append((Allow, 'group.KarlStaff', GUEST_PERMS + ('view_only', )))
    users = find_users(ob)
    user = users.get_by_id(ob.creator)
    if user is not None:
        groups = user['groups']
        for group, role in get_community_groups(groups):
            c_group = 'group.community:%s:%s' % (group, role)
            acl.append((Allow, c_group, GUEST_PERMS + ('view_only', )))
    acl.append((Allow, 'system.Authenticated', ('view_only', )))
    acl.append(NO_INHERIT)
    msg = None
    added, removed = acl_diff(ob, acl)
    if added or removed:
        ob.__acl__ = acl
        msg = ts('to-active', resource_path(ob), added, removed)
    _reindex(ob, texts=True)
    _reindex_peopledir(ob)
    return msg
Example #2
0
def to_profile_active(ob, info):
    acl  = [
        (Allow, ob.creator, MEMBER_PERMS + ('view_only',)),
    ]
    acl.append((Allow, 'group.KarlUserAdmin',
                ADMINISTRATOR_PERMS + ('view_only',)))
    acl.append((Allow, 'group.KarlAdmin',
                ADMINISTRATOR_PERMS + ('view_only',)))
    acl.append((Allow, 'group.KarlStaff',
                GUEST_PERMS + ('view_only',)))
    users = find_users(ob)
    user = users.get_by_id(ob.creator)
    if user is not None:
        groups = user['groups']
        for group, role in get_community_groups(groups):
            c_group = 'group.community:%s:%s' % (group, role)
            acl.append((Allow, c_group, GUEST_PERMS + ('view_only',)))
    acl.append((Allow, 'system.Authenticated', ('view_only',)))
    acl.append(NO_INHERIT)
    msg = None
    added, removed = acl_diff(ob, acl)
    if added or removed:
        ob.__acl__ = acl
        msg = ts('to-active', resource_path(ob), added, removed)
    _reindex(ob, texts=True)
    _reindex_peopledir(ob)
    return msg
Example #3
0
def content_to_inherits(ob, info):
    msg = None
    added, removed = acl_diff(ob, {})
    if hasattr(ob, '__acl__'):
        del ob.__acl__
        msg =  ts('content-inherited', model_path(ob), added, removed)
    _reindex(ob)
    return msg
Example #4
0
def content_to_inherits(ob, info):
    msg = None
    added, removed = acl_diff(ob, {})
    if hasattr(ob, '__acl__'):
        del ob.__acl__
        msg = ts('content-inherited', resource_path(ob), added, removed)
    _reindex(ob)
    return msg
Example #5
0
def forum_to_inherits(ob, info):
    acl = [(Allow, 'group.KarlStaff', (CREATE,))]
    # Note:  don't add NO_INHERIT, ergo fall back to __parent__
    msg = None
    added, removed = acl_diff(ob, acl)
    if added or removed:
        ob.__acl__ = acl
        msg = ts('forum-inherited', model_path(ob), added, removed)
    _reindex(ob)
    return msg
Example #6
0
def forum_to_inherits(ob, info):
    acl = [(Allow, 'group.KarlStaff', (CREATE, ))]
    # Note:  don't add NO_INHERIT, ergo fall back to __parent__
    msg = None
    added, removed = acl_diff(ob, acl)
    if added or removed:
        ob.__acl__ = acl
        msg = ts('forum-inherited', resource_path(ob), added, removed)
    _reindex(ob)
    return msg
Example #7
0
def intranet_content_to_inherits(ob, info):
    acl = [
        (Allow, 'group.KarlAdmin', ADMINISTRATOR_PERMS),
        (Allow, ob.creator, MEMBER_PERMS),
        (Deny, Everyone, ('edit', 'delete')),
        # Note:  don't add NO_INHERIT, ergo fall back to __parent__
        ]
    msg = None
    added, removed = acl_diff(ob, acl)
    if (added or removed):
        ob.__acl__ = acl
        msg = ts('intranet-content-inherited', model_path(ob), added, removed)
    _reindex(ob)
    return msg
Example #8
0
def forum_topic_to_inherits(ob, info):
    acl = [
        (Allow, 'group.KarlAdmin', ADMINISTRATOR_PERMS),
        (Allow, ob.creator, MEMBER_PERMS),
        (Deny, Everyone, ('edit', 'delete')),
        # Note:  don't add NO_INHERIT, ergo fall back to __parent__
    ]
    msg = None
    added, removed = acl_diff(ob, acl)
    if added or removed:
        ob.__acl__ = acl
        msg = ts('forum-topic-inherited', resource_path(ob), added, removed)
    _reindex(ob)
    return msg
Example #9
0
def forum_topic_to_inherits(ob, info):
    acl = [
        (Allow, 'group.KarlAdmin', ADMINISTRATOR_PERMS),
        (Allow, ob.creator, MEMBER_PERMS),
        (Deny, Everyone, ('edit', 'delete')),
        # Note:  don't add NO_INHERIT, ergo fall back to __parent__
        ]
    msg = None
    added, removed = acl_diff(ob, acl)
    if added or removed:
        ob.__acl__ = acl
        msg = ts('forum-topic-inherited', resource_path(ob), added, removed)
    _reindex(ob)
    return msg
Example #10
0
def to_profile_inactive(ob, info):
    acl = [
        (Allow, 'system.Authenticated', (VIEW, )),
        (Allow, 'group.KarlUserAdmin', ADMINISTRATOR_PERMS),
        (Allow, 'group.KarlAdmin', ADMINISTRATOR_PERMS),
        NO_INHERIT,
    ]
    msg = None
    added, removed = acl_diff(ob, acl)
    if added or removed:
        ob.__acl__ = acl
        msg = ts('to-inactive', resource_path(ob), added, removed)
    _reindex(ob, texts=True)
    _reindex_peopledir(ob)
    return msg
Example #11
0
def to_profile_inactive(ob, info):
    acl  = [
        (Allow, 'system.Authenticated', ('view_only',)),
        (Allow, 'group.KarlUserAdmin', ADMINISTRATOR_PERMS + ('view_only',)),
        (Allow, 'group.KarlAdmin', ADMINISTRATOR_PERMS + ('view_only',)),
        NO_INHERIT,
    ]
    msg = None
    added, removed = acl_diff(ob, acl)
    if added or removed:
        ob.__acl__ = acl
        msg = ts('to-inactive', resource_path(ob), added, removed)
    _reindex(ob, texts=True)
    _reindex_peopledir(ob)
    return msg
Example #12
0
def blogentry_to_private(ob, info):
    community = find_community(ob)
    acl = [(Allow, 'group.KarlAdmin', ADMINISTRATOR_PERMS)]
    acl.append((Allow, ob.creator, MEMBER_PERMS))
    moderators_group_name = community.moderators_group_name
    members_group_name = community.members_group_name
    acl.append((Allow, moderators_group_name, MODERATOR_PERMS))
    acl.append((Allow, members_group_name, GUEST_PERMS))
    acl.append(NO_INHERIT)
    msg = None
    added, removed = acl_diff(ob, acl)
    if added or removed:
        ob.__acl__ = acl
        msg = ts('blogentry-private', model_path(ob), added, removed)
    _reindex(ob)
    return msg
Example #13
0
def community_to_private(ob, info):
    community = find_community(ob)
    acl = []
    moderators_group_name = community.moderators_group_name
    members_group_name = community.members_group_name
    acl.append((Allow, 'group.KarlAdmin', ADMINISTRATOR_PERMS))
    acl.append((Allow, moderators_group_name, MODERATOR_PERMS))
    acl.append((Allow, members_group_name, MEMBER_PERMS))
    acl.append(NO_INHERIT)
    msg = None
    added, removed = acl_diff(community, acl)
    if added or removed:
        community.__acl__ = acl
        msg = ts('community-private', model_path(community), added, removed)
    _reindex(community)
    return msg
Example #14
0
def content_to_private(ob, info):
    community = find_community(ob)
    acl = []
    moderators_group_name = community.moderators_group_name
    members_group_name = community.members_group_name
    acl.append((Allow, 'group.KarlAdmin', ADMINISTRATOR_PERMS))
    acl.append((Allow, moderators_group_name, MODERATOR_PERMS))
    acl.append((Allow, members_group_name, MEMBER_PERMS))
    acl.append(NO_INHERIT)
    msg = None
    added, removed = acl_diff(ob, acl)
    if added or removed:
        ob.__acl__ = acl
        msg = ts('content-private', resource_path(ob), added, removed)
    _reindex(ob)
    return msg
Example #15
0
def community_to_intranet(ob, info):
    community = find_community(ob)
    acl = []
    moderators_group_name = community.moderators_group_name
    members_group_name = community.members_group_name
    acl.append((Allow, 'group.KarlAdmin', ADMINISTRATOR_PERMS))
    acl.append((Allow, moderators_group_name, MODERATOR_PERMS))
    acl.append((Allow, members_group_name, MEMBER_PERMS))
    # inherit from /offices
    #acl.append(NO_INHERIT)
    msg = None
    added, removed = acl_diff(community, acl)
    if added or removed:
        community.__acl__ = acl
        msg = ts('community-intranet', resource_path(community), added, removed)
    _reindex(community)
    return msg
Example #16
0
def community_to_public(ob, info):
    community = find_community(ob)
    acl = []
    moderators_group_name = community.moderators_group_name
    members_group_name = community.members_group_name
    acl.append((Allow, 'group.KarlAdmin', ADMINISTRATOR_PERMS))
    acl.append((Allow, moderators_group_name, MODERATOR_PERMS))
    acl.append((Allow, members_group_name, MEMBER_PERMS))
    acl.append((Allow, Authenticated, MEMBER_PERMS))
    acl.append(NO_INHERIT)
    msg = None
    added, removed = acl_diff(community, acl)
    if added or removed:
        community.__acl__ = acl
        msg = ts('community-public', resource_path(community), added, removed)
    _reindex(community)
    return msg
Example #17
0
def community_to_restricted(ob, info):
    community = find_community(ob)
    acl = []
    moderators_group_name = community.moderators_group_name
    members_group_name = community.members_group_name
    acl.append((Allow, 'group.KarlAdmin', ADMINISTRATOR_PERMS))
    acl.append((Allow, moderators_group_name, MODERATOR_PERMS))
    acl.append((Allow, members_group_name, MEMBER_PERMS))
    acl.append((Allow, 'group.KarlStaff', MEMBER_PERMS))
    acl.append((Allow, Authenticated, GUEST_PERMS))
    acl.append(NO_INHERIT)
    msg = None
    added, removed = acl_diff(community, acl)
    if added or removed:
        community.__acl__ = acl
        msg = ts('community-public', resource_path(community), added, removed)
    _reindex(community)
    return msg
Example #18
0
def to_profile(ob, info):
    acl  = [
        (Allow, ob.creator, MEMBER_PERMS),
    ]
    acl.append((Allow, 'group.KarlUserAdmin', ADMINISTRATOR_PERMS))
    acl.append((Allow, 'group.KarlAdmin', ADMINISTRATOR_PERMS))
    acl.append((Allow, 'group.KarlStaff', GUEST_PERMS))
    users = find_users(ob)
    user = users.get_by_id(ob.creator)
    if user is not None:
        groups = user['groups']
        for group, role in get_community_groups(groups):
            c_group = 'group.community:%s:%s' % (group, role)
            acl.append((Allow, c_group, GUEST_PERMS))
    acl.append(NO_INHERIT)
    msg = None
    added, removed = acl_diff(ob, acl)
    if added or removed:
        ob.__acl__ = acl
        msg = ts('to-profile', model_path(ob), added, removed)
    _reindex(ob)
    return msg
Example #19
0
 def _callFUT(self, ob, acl):
     from karl.security.workflow import acl_diff
     return acl_diff(ob, acl)
Example #20
0
File: tests.py Project: lslaz1/karl
 def _callFUT(self, ob, acl):
     from karl.security.workflow import acl_diff
     return acl_diff(ob, acl)