本文整理汇总了Python中seaserv.get_personal_groups_by_user函数的典型用法代码示例。如果您正苦于以下问题:Python get_personal_groups_by_user函数的具体用法?Python get_personal_groups_by_user怎么用?Python get_personal_groups_by_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_personal_groups_by_user函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_user_repos
def get_user_repos(user):
"""
Get all repos that user can access, including owns, shared, public, and
repo in groups.
NOTE: collumn names in shared_repo struct are not same as owned or group
repos.
"""
email = user.username
shared_repos = list_share_repos(email, 'to_email', -1, -1)
if CLOUD_MODE:
if user.org:
org_id = user.org['org_id']
owned_repos = list_org_repos_by_owner(org_id, email)
groups_repos = []
for group in get_org_groups_by_user(org_id, email):
groups_repos += get_org_group_repos(org_id, group.id, email)
public_repos = list_org_inner_pub_repos(org_id, email, -1, -1)
else:
owned_repos = list_personal_repos_by_owner(email)
groups_repos = []
for group in get_personal_groups_by_user(email):
groups_repos += get_group_repos(group.id, email)
public_repos = []
else:
owned_repos = list_personal_repos_by_owner(email)
groups_repos = []
for group in get_personal_groups_by_user(email):
groups_repos += get_group_repos(group.id, email)
public_repos = list_inner_pub_repos(email)
return (owned_repos, shared_repos, groups_repos, public_repos)
开发者ID:bearstech,项目名称:seahub,代码行数:33,代码来源:__init__.py
示例2: post
def post(self, request, email, format=None):
# migrate an account's repos and groups to an exist account
if not is_valid_username(email):
return api_error(status.HTTP_400_BAD_REQUEST, 'Email %s invalid.' % email)
op = request.data.get('op', '').lower()
if op == 'migrate':
from_user = email
to_user = request.data.get('to_user', '')
if not is_valid_username(to_user):
return api_error(status.HTTP_400_BAD_REQUEST, 'Email %s invalid.' % to_user)
try:
user2 = User.objects.get(email=to_user)
except User.DoesNotExist:
return api_error(status.HTTP_404_NOT_FOUND, 'User %s not found.' % to_user)
# transfer owned repos to new user
for r in seafile_api.get_owned_repo_list(from_user):
seafile_api.set_repo_owner(r.id, user2.username)
# transfer joined groups to new user
for g in seaserv.get_personal_groups_by_user(from_user):
if not seaserv.is_group_user(g.id, user2.username):
# add new user to the group on behalf of the group creator
ccnet_threaded_rpc.group_add_member(g.id, g.creator_name,
to_user)
if from_user == g.creator_name:
ccnet_threaded_rpc.set_group_creator(g.id, to_user)
return Response("success")
else:
return api_error(status.HTTP_400_BAD_REQUEST, 'op can only be migrate.')
开发者ID:RaphaelWimmer,项目名称:seahub,代码行数:34,代码来源:account.py
示例3: get_user_repos
def get_user_repos(user):
"""
Get all repos that user can access, including owns, shared, and repo in
groups.
NOTE: collumn names in shared_repo struct are not same as owned or group
repos.
"""
email = user.username
if user.org:
# org context
org_id = user.org['org_id']
owned_repos = list_org_repos_by_owner(org_id, email)
shared_repos = list_personal_shared_repos(email, 'to_email', -1, -1)
groups_repos = []
for group in get_org_groups_by_user(org_id, email):
groups_repos += get_org_group_repos(org_id, group.id, email)
else:
# personal context
owned_repos = list_personal_repos_by_owner(email)
shared_repos = list_personal_shared_repos(email, 'to_email', -1, -1)
groups_repos = []
for group in get_personal_groups_by_user(email):
groups_repos += get_group_repos(group.id, email)
return (owned_repos, shared_repos, groups_repos)
开发者ID:chuyskywalker,项目名称:seahub,代码行数:25,代码来源:__init__.py
示例4: get
def get(self, request, format=None):
username = request.user.username
shared_repos = []
shared_repos += seafile_api.get_share_in_repo_list(username, -1, -1)
joined_groups = get_personal_groups_by_user(username)
for grp in joined_groups:
# Get group repos, and for each group repos...
for r_id in get_group_repoids(grp.id):
# No need to list my own repo
if seafile_api.is_repo_owner(username, r_id):
continue
# Convert repo properties due to the different collumns in Repo
# and SharedRepo
r = get_repo(r_id)
if not r:
continue
r.repo_id = r.id
r.repo_name = r.name
r.repo_desc = r.desc
cmmts = get_commits(r_id, 0, 1)
last_commit = cmmts[0] if cmmts else None
r.last_modified = last_commit.ctime if last_commit else 0
r.share_type = 'group'
r.user = seafile_api.get_repo_owner(r_id)
r.user_perm = check_permission(r_id, username)
shared_repos.append(r)
if not CLOUD_MODE:
shared_repos += list_inner_pub_repos(username)
return HttpResponse(json.dumps(shared_repos, cls=SearpcObjEncoder),
status=200, content_type=json_content_type)
开发者ID:viktorlindgren,项目名称:seahub,代码行数:33,代码来源:views.py
示例5: group_list
def group_list(request):
username = request.user.username
if request.method == "POST":
"""
Add a new group.
"""
result = {}
content_type = "application/json; charset=utf-8"
form = GroupAddForm(request.POST)
if form.is_valid():
group_name = form.cleaned_data["group_name"]
# Check whether group name is duplicated.
if request.cloud_mode:
checked_groups = get_personal_groups_by_user(username)
else:
checked_groups = get_personal_groups(-1, -1)
for g in checked_groups:
if g.group_name == group_name:
result["error"] = _(u"There is already a group with that name.")
return HttpResponse(json.dumps(result), status=400, content_type=content_type)
# Group name is valid, create that group.
try:
ccnet_threaded_rpc.create_group(group_name.encode("utf-8"), username)
return HttpResponse(json.dumps({"success": True}), content_type=content_type)
except SearpcError, e:
result["error"] = _(e.msg)
return HttpResponse(json.dumps(result), status=500, content_type=content_type)
else:
return HttpResponseBadRequest(json.dumps(form.errors), content_type=content_type)
开发者ID:hilerchyn,项目名称:seahub,代码行数:33,代码来源:views.py
示例6: rename_group_with_new_name
def rename_group_with_new_name(request, group_id, new_group_name):
"""Rename a group with new name.
Arguments:
- `request`:
- `group_id`:
- `new_group_name`:
Raises:
BadGroupNameError: New group name format is not valid.
ConflictGroupNameError: New group name confilicts with existing name.
"""
if not validate_group_name(new_group_name):
raise BadGroupNameError
# Check whether group name is duplicated.
username = request.user.username
org_id = -1
if is_org_context(request):
org_id = request.user.org.org_id
checked_groups = seaserv.get_org_groups_by_user(org_id, username)
else:
if request.cloud_mode:
checked_groups = seaserv.get_personal_groups_by_user(username)
else:
checked_groups = get_all_groups(-1, -1)
for g in checked_groups:
if g.group_name == new_group_name:
raise ConflictGroupNameError
ccnet_threaded_rpc.set_group_name(group_id, new_group_name)
开发者ID:octomike,项目名称:seahub,代码行数:32,代码来源:views.py
示例7: get_groups_by_user
def get_groups_by_user(username, org_id):
"""List user groups.
"""
if org_id:
return seaserv.get_org_groups_by_user(org_id, username)
else:
return seaserv.get_personal_groups_by_user(username)
开发者ID:GregoireGalland,项目名称:seafdav,代码行数:7,代码来源:seafile_dav_provider.py
示例8: get
def get(self, request):
""" List all groups.
"""
org_id = None
username = request.user.username
if is_org_context(request):
org_id = request.user.org.org_id
user_groups = seaserv.get_org_groups_by_user(org_id, username)
else:
user_groups = seaserv.get_personal_groups_by_user(username)
try:
size = int(request.GET.get('avatar_size', GROUP_AVATAR_DEFAULT_SIZE))
except ValueError:
size = GROUP_AVATAR_DEFAULT_SIZE
try:
with_repos = int(request.GET.get('with_repos', 0))
except ValueError:
with_repos = 0
if with_repos not in (0, 1):
error_msg = _(u'Argument can only be 0 or 1')
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
groups = []
for g in user_groups:
group_info = get_group_info(request, g.id , size)
if with_repos:
if org_id:
group_repos = seafile_api.get_org_group_repos(org_id, g.id)
else:
group_repos = seafile_api.get_repos_by_group(g.id)
repos = []
for r in group_repos:
repo = {
"id": r.id,
"name": r.name,
"desc": r.desc,
"size": r.size,
"size_formatted": filesizeformat(r.size),
"mtime": r.last_modified,
"mtime_relative": translate_seahub_time(r.last_modified),
"encrypted": r.encrypted,
"permission": r.permission,
"owner": r.user,
"owner_nickname": email2nickname(r.user),
"share_from_me": True if username == r.user else False,
}
repos.append(repo)
group_info['repos'] = repos
groups.append(group_info)
return Response(groups)
开发者ID:ERamseth,项目名称:seahub,代码行数:59,代码来源:groups.py
示例9: group_add
def group_add(request):
"""Add a new group"""
if request.method != 'POST':
raise Http404
username = request.user.username
result = {}
content_type = 'application/json; charset=utf-8'
user_can_add_group = request.user.permissions.can_add_group()
if not user_can_add_group:
result['error'] = _(u'You do not have permission to create group.')
return HttpResponse(json.dumps(result), status=403,
content_type=content_type)
# check plan
num_of_groups = getattr(request.user, 'num_of_groups', -1)
if num_of_groups > 0:
current_groups = len(request.user.joined_groups)
if current_groups > num_of_groups:
result['error'] = _(u'You can only create %d groups.<a href="http://seafile.com/">Upgrade account.</a>') % num_of_groups
return HttpResponse(json.dumps(result), status=403,
content_type=content_type)
form = GroupAddForm(request.POST)
if form.is_valid():
group_name = form.cleaned_data['group_name']
# Check whether group name is duplicated.
org_id = -1
if is_org_context(request):
org_id = request.user.org.org_id
checked_groups = seaserv.get_org_groups_by_user(org_id, username)
else:
if request.cloud_mode:
checked_groups = seaserv.get_personal_groups_by_user(username)
else:
checked_groups = get_all_groups(-1, -1)
for g in checked_groups:
if g.group_name == group_name:
result['error'] = _(u'There is already a group with that name.')
return HttpResponse(json.dumps(result), status=400,
content_type=content_type)
# Group name is valid, create that group.
try:
if org_id > 0:
create_org_group(org_id, group_name, username)
else:
create_group(group_name, username)
return HttpResponse(json.dumps({'success': True}),
content_type=content_type)
except SearpcError, e:
result['error'] = _(e.msg)
return HttpResponse(json.dumps(result), status=500,
content_type=content_type)
开发者ID:TanLian,项目名称:seahub,代码行数:57,代码来源:views.py
示例10: remove_user
def remove_user(self, email=None):
if not email:
email = self.user.username
try:
User.objects.get(email).delete()
except User.DoesNotExist:
pass
for g in seaserv.get_personal_groups_by_user(email):
ccnet_threaded_rpc.remove_group(g.id, email)
开发者ID:pombredanne,项目名称:seahub,代码行数:9,代码来源:test_utils.py
示例11: process_request
def process_request(self, request):
if CLOUD_MODE:
request.cloud_mode = True
# Get all orgs user created.
# orgs = get_orgs_by_user(request.user.username)
# request.user.orgs = orgs
else:
request.cloud_mode = False
request.user.org = None
request.user.orgs = None
username = request.user.username
request.user.joined_groups = seaserv.get_personal_groups_by_user(username)
return None
开发者ID:tostadora,项目名称:seahub,代码行数:17,代码来源:middleware.py
示例12: get_contacts_and_groups
def get_contacts_and_groups(request):
if not request.is_ajax():
raise Http404
content_type = 'application/json; charset=utf-8'
username = request.user.username
contacts = Contact.objects.get_contacts_by_user(username)
contact_list = []
from seahub.avatar.templatetags.avatar_tags import avatar
for c in contacts:
contact_list.append({"email": c.contact_email, "avatar": avatar(c.contact_email, 16)})
joined_groups = get_personal_groups_by_user(username)
group_list = []
from seahub.avatar.templatetags.group_avatar_tags import grp_avatar
for g in joined_groups:
group_list.append({"id": g.id, "name": g.group_name, "avatar": grp_avatar(g.id, 16)})
return HttpResponse(json.dumps({"contacts":contact_list, "groups":group_list}), content_type=content_type)
开发者ID:youngdev,项目名称:seahub,代码行数:19,代码来源:ajax.py
示例13: get_user_repos
def get_user_repos(username, org_id=None):
"""
Get all repos that user can access, including owns, shared, public, and
repo in groups.
If ``org_id`` is not None, get org repos that user can access.
"""
if org_id is None:
owned_repos = seaserv.list_personal_repos_by_owner(username)
shared_repos = seafile_api.get_share_in_repo_list(username, -1, -1)
groups_repos = []
for group in seaserv.get_personal_groups_by_user(username):
# TODO: use seafile_api.get_group_repos
groups_repos += seaserv.get_group_repos(group.id, username)
if CLOUD_MODE:
public_repos = []
else:
public_repos = seaserv.list_inner_pub_repos(username)
for r in shared_repos + public_repos:
# collumn names in shared_repo struct are not same as owned or group
# repos.
r.id = r.repo_id
r.name = r.repo_name
r.desc = r.repo_desc
r.last_modify = r.last_modified
else:
owned_repos = seafile_api.get_org_owned_repo_list(org_id, username)
shared_repos = seafile_api.get_org_share_in_repo_list(org_id, username,
-1, -1)
groups_repos = []
for group in seaserv.get_org_groups_by_user(org_id, username):
groups_repos += seafile_api.get_org_group_repos(org_id, group.id)
public_repos = seaserv.seafserv_threaded_rpc.list_org_inner_pub_repos(org_id)
for r in shared_repos + groups_repos + public_repos:
# collumn names in shared_repo struct are not same as owned
# repos.
r.id = r.repo_id
r.name = r.repo_name
r.desc = r.repo_desc
r.last_modify = r.last_modified
return (owned_repos, shared_repos, groups_repos, public_repos)
开发者ID:cherish24,项目名称:seahub,代码行数:43,代码来源:__init__.py
示例14: message_list
def message_list(request):
"""List and group messages related to the user, including he/she send to
others and others send to he/she.
"""
username = request.user.username
related_user_msgs = UserMessage.objects.get_messages_related_to_user(username)
user_msgs = user_msg_info_list(related_user_msgs, username)
total_unread = 0
for msg in user_msgs.items():
total_unread += msg[1]['not_read']
joined_groups = get_personal_groups_by_user(username)
group_msgs = group_msg_info_list(joined_groups, username)
msgs = sorted(user_msgs.items() + group_msgs.items(), key=lambda x: x[1]['last_time'], reverse=True)
return render_to_response('message/all_msg_list.html', {
'msgs': msgs,
'total_unread': total_unread,
}, context_instance=RequestContext(request))
开发者ID:youngdev,项目名称:seahub,代码行数:20,代码来源:views.py
示例15: get
def get(self, request, format=None):
""" Search group.
Permission checking:
1. default(NOT guest) user;
"""
# argument check
q = request.GET.get('q', None)
if not q:
error_msg = 'q invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# permission check
if not self._can_use_global_address_book(request):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
if CLOUD_MODE:
if is_org_context(request):
org_id = request.user.org.org_id
groups = ccnet_api.get_org_groups(org_id, -1, -1)
elif settings.ENABLE_GLOBAL_ADDRESSBOOK:
groups = ccnet_api.get_all_groups(-1, -1)
else:
username = request.user.username
groups = seaserv.get_personal_groups_by_user(username)
else:
groups = ccnet_api.get_all_groups(-1, -1)
result = []
for group in groups:
group_name = group.group_name
if not group_name:
continue
if q.lower() in group_name.lower():
group_info = get_group_info(group.id)
result.append(group_info)
return Response(result)
开发者ID:haiwen,项目名称:seahub,代码行数:41,代码来源:search_group.py
示例16: process_request
def process_request(self, request):
username = request.user.username
request.user.org = None
if CLOUD_MODE:
request.cloud_mode = True
if MULTI_TENANCY:
orgs = seaserv.get_orgs_by_user(username)
if orgs:
request.user.org = orgs[0]
else:
request.cloud_mode = False
if CLOUD_MODE and request.user.org is not None:
org_id = request.user.org.org_id
request.user.joined_groups = seaserv.get_org_groups_by_user(org_id, username)
else:
request.user.joined_groups = seaserv.get_personal_groups_by_user(username)
return None
开发者ID:ERamseth,项目名称:seahub,代码行数:21,代码来源:middleware.py
示例17: get_user_repos
def get_user_repos(username):
"""
Get all repos that user can access, including owns, shared, public, and
repo in groups.
NOTE: collumn names in shared_repo struct are not same as owned or group
repos.
"""
email = username
shared_repos = seafile_api.get_share_in_repo_list(email, -1, -1)
owned_repos = list_personal_repos_by_owner(email)
groups_repos = []
for group in get_personal_groups_by_user(email):
groups_repos += get_group_repos(group.id, email)
if CLOUD_MODE:
public_repos = []
else:
public_repos = list_inner_pub_repos(email)
return (owned_repos, shared_repos, groups_repos, public_repos)
开发者ID:jamjr,项目名称:seahub,代码行数:21,代码来源:__init__.py
示例18: check_group_name_conflict
def check_group_name_conflict(request, new_group_name):
"""Check if new group name conflict with existed group.
return "True" if conflicted else "False"
"""
org_id = -1
username = request.user.username
if is_org_context(request):
org_id = request.user.org.org_id
checked_groups = seaserv.get_org_groups_by_user(org_id, username)
else:
if request.cloud_mode:
checked_groups = seaserv.get_personal_groups_by_user(username)
else:
checked_groups = seaserv.ccnet_threaded_rpc.get_all_groups(-1, -1)
for g in checked_groups:
if g.group_name == new_group_name:
return True
return False
开发者ID:AviorAlong,项目名称:haiwen-5.1.3,代码行数:21,代码来源:utils.py
示例19: get_groups
def get_groups(email):
group_json = []
joined_groups = get_personal_groups_by_user(email)
grpmsgs = {}
for g in joined_groups:
grpmsgs[g.id] = 0
notes = UserNotification.objects.get_user_notifications(email, seen=False)
replynum = 0
for n in notes:
if n.is_group_msg():
try:
gid = n.group_message_detail_to_dict().get('group_id')
except UserNotification.InvalidDetailError:
continue
if gid not in grpmsgs:
continue
grpmsgs[gid] = grpmsgs[gid] + 1
elif n.is_grpmsg_reply():
replynum = replynum + 1
for g in joined_groups:
msg = GroupMessage.objects.filter(group_id=g.id).order_by('-timestamp')[:1]
mtime = 0
if len(msg) >= 1:
mtime = get_timestamp(msg[0].timestamp)
group = {
"id":g.id,
"name":g.group_name,
"creator":g.creator_name,
"ctime":g.timestamp,
"mtime":mtime,
"msgnum":grpmsgs[g.id],
}
group_json.append(group)
return group_json, replynum
开发者ID:jamjr,项目名称:seahub,代码行数:38,代码来源:utils.py
示例20: get
def get(self, request):
email = request.user.username
owned_repos = seafserv_threaded_rpc.list_owned_repos(email)
calculate_repo_info (owned_repos, email)
owned_repos.sort(lambda x, y: cmp(y.latest_modify, x.latest_modify))
n_repos = seafserv_threaded_rpc.list_share_repos(email,
'to_email', -1, -1)
calculate_repo_info (n_repos, email)
owned_repos.sort(lambda x, y: cmp(y.latest_modify, x.latest_modify))
repos_json = []
for r in owned_repos:
repo = {
"type":"repo",
"id":r.id,
"owner":email,
"name":r.name,
"desc":r.desc,
"mtime":r.latest_modify,
"root":r.root,
"size":r.size,
"encrypted":r.encrypted,
"password_need":r.password_need,
}
repos_json.append(repo)
for r in n_repos:
repo = {
"type":"srepo",
"id":r.id,
"owner":r.shared_email,
"name":r.name,
"desc":r.desc,
"mtime":r.latest_modify,
"root":r.root,
"size":r.size,
"encrypted":r.encrypted,
"password_need":r.password_need,
}
repos_json.append(repo)
groups = get_personal_groups_by_user(email)
for group in groups:
g_repos = get_group_repos(group.id, email)
calculate_repo_info (g_repos, email)
owned_repos.sort(lambda x, y: cmp(y.latest_modify, x.latest_modify))
for r in g_repos:
repo = {
"type":"grepo",
"id":r.id,
"owner":group.group_name,
"name":r.name,
"desc":r.desc,
"mtime":r.latest_modify,
"root":r.root,
"size":r.size,
"encrypted":r.encrypted,
"password_need":r.password_need,
}
repos_json.append(repo)
response = Response(200, repos_json)
return self.render(response)
开发者ID:hilerchyn,项目名称:seahub,代码行数:65,代码来源:views.py
注:本文中的seaserv.get_personal_groups_by_user函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论