Exemplo n.º 1
0
Arquivo: chatter.py Projeto: zagy/karl
def discover_community_members_json(context, request):
    """ Return users who share a community with the given user.

    Query string may include:

    - 'userid':  the user whose communities we enumerate (defaults to the
                 current user).
    """
    users = find_users(context)
    userid = request.GET.get('userid', None)
    if userid is None:
        userid = authenticated_userid(request)
        principals = effective_principals(request)
        communities = [x[0] for x in get_community_groups(principals)]
    else:
        info = users.get(userid)
        communities = [x[0] for x in get_community_groups(info['groups'])]
    c_groups = [(x,
                 _quippers_from_users(
                     context, request,
                     users.users_in_group('group.community:%s:members' % x)))
                for x in communities]
    return {
        'userid': userid,
        'members': dict(c_groups),
    }
Exemplo n.º 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
Exemplo n.º 3
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
Exemplo n.º 4
0
Arquivo: chatter.py Projeto: hj91/karl
def discover_community_members_json(context, request):
    """ Return users who share a community with the given user.

    Query string may include:

    - 'userid':  the user whose communities we enumerate (defaults to the
                 current user).
    """
    users = find_users(context)
    userid = request.GET.get('userid', None)
    if userid is None:
        userid = authenticated_userid(request)
        principals = effective_principals(request)
        communities = [x[0] for x in get_community_groups(principals)]
    else:
        info = users.get(userid)
        communities = [x[0] for x in get_community_groups(info['groups'])]
    c_groups = [(x, _quippers_from_users(context, request,
         users.users_in_group('group.community:%s:members' % x)))
         for x in communities]
    return {'userid': userid,
            'members': dict(c_groups),
           }
Exemplo n.º 5
0
Arquivo: chatter.py Projeto: hj91/karl
def my_communities_chatter_json(context, request):
    """ Return recent chatter mentioning current user's communities.

    Query string may include:

    - 'start':  the item index at which to begin including items.
    - 'count':  the maximun number of items to return.
    - 'before':  a string timestamp (in timeago format);  include items
                 which are older than the indicated time.
    - 'since':  a string timestamp (in timeago format);  include items
                which are newer than the indicated time.  Note that we
                return the *last* 'count' items newer than the supplied
                value.
    """
    principals = effective_principals(request)
    communities = [x[0] for x in get_community_groups(principals)]
    chatter = find_chatter(context)
    return {'communities': communities,
            'recent': _do_slice(
                      chatter.recentWithCommunities(*communities), request),
           }
Exemplo n.º 6
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
Exemplo n.º 7
0
Arquivo: chatter.py Projeto: zagy/karl
def my_communities_chatter_json(context, request):
    """ Return recent chatter mentioning current user's communities.

    Query string may include:

    - 'start':  the item index at which to begin including items.
    - 'count':  the maximun number of items to return.
    - 'before':  a string timestamp (in timeago format);  include items
                 which are older than the indicated time.
    - 'since':  a string timestamp (in timeago format);  include items
                which are newer than the indicated time.  Note that we
                return the *last* 'count' items newer than the supplied
                value.
    """
    principals = effective_principals(request)
    communities = [x[0] for x in get_community_groups(principals)]
    chatter = find_chatter(context)
    return {
        'communities': communities,
        'recent': _do_slice(chatter.recentWithCommunities(*communities),
                            request),
    }
 def _callFUT(self, principals):
     from karl.views.communities import get_community_groups
     return get_community_groups(principals)
Exemplo n.º 9
0
 def _callFUT(self, principals):
     from karl.views.communities import get_community_groups
     return get_community_groups(principals)