本文整理汇总了Python中seaserv.seafile_api.get_share_in_repo_list函数的典型用法代码示例。如果您正苦于以下问题:Python get_share_in_repo_list函数的具体用法?Python get_share_in_repo_list怎么用?Python get_share_in_repo_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_share_in_repo_list函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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)
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:jjjasont,项目名称:seahub,代码行数:33,代码来源:__init__.py
示例2: 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
示例3: user_share_list
def user_share_list(request, id_or_email):
"""List sharing repos with ``to_email``.
"""
try:
uid = int(id_or_email)
try:
user = User.objects.get(id=uid)
except User.DoesNotExist:
user = None
if not user:
return render_to_response("user_404.html",{},
context_instance=RequestContext(request))
to_email = user.email
except ValueError:
to_email = id_or_email
share_list = []
username = request.user.username
share_in = seafile_api.get_share_in_repo_list(username, -1, -1)
share_out = seafile_api.get_share_out_repo_list(username, -1, -1)
for e in (share_in+share_out):
if e.share_type == 'personal' and e.user == to_email:
share_list.append(e)
c = Contact.objects.get_contact_by_user(username, to_email)
add_to_contacts = True if c is None else False
return render_to_response('repo/user_share_list.html', {
'to_email': to_email,
'share_list': share_list,
'add_to_contacts': add_to_contacts,
}, context_instance=RequestContext(request))
开发者ID:sebheitzmann,项目名称:seahub,代码行数:32,代码来源:views.py
示例4: get_share_in_repo_list
def get_share_in_repo_list(username, org_id):
"""List share in repos.
"""
if org_id:
repo_list = seafile_api.get_org_share_in_repo_list(org_id, username,
-1, -1)
else:
repo_list = seafile_api.get_share_in_repo_list(username, -1, -1)
# for repo in repo_list:
# repo.user_perm = seafile_api.check_repo_access_permission(repo.repo_id,
# username)
return repo_list
开发者ID:GregoireGalland,项目名称:seafdav,代码行数:13,代码来源:seafile_dav_provider.py
示例5: test_not_reshare_to_user_after_transfer_repo
def test_not_reshare_to_user_after_transfer_repo(self):
# Remove share if repo already shared to new owner
# share user's repo to admin with 'rw' permission
seafile_api.share_repo(self.user_repo_id, self.user.username,
self.admin.username, 'rw')
# repo in admin's be shared repo list
shared_repos = seafile_api.get_share_in_repo_list(self.admin.username, -1, -1)
assert shared_repos[0].repo_name == self.repo.repo_name
self.login_as(self.user)
url = reverse("api2-repo-owner", args=[self.user_repo_id])
data = 'owner=%s' % self.admin.email
resp = self.client.put(url, data, 'application/x-www-form-urlencoded')
self.assertEqual(200, resp.status_code)
# repo NOT in admin's be shared repo list
shared_repos = seafile_api.get_share_in_repo_list(self.admin.username, -1, -1)
assert len(shared_repos) == 0
开发者ID:RaphaelWimmer,项目名称:seahub,代码行数:22,代码来源:test_repo_owner.py
示例6: 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
示例7: my_shared_repos
def my_shared_repos(request):
"""Return html snippet of repos that shared to user.
Arguments:
- `request`:
"""
if not request.is_ajax():
raise Http404
username = request.user.username
shared_repos = seafile_api.get_share_in_repo_list(username, -1, -1)
shared_repos.sort(lambda x, y: cmp(y.last_modified, x.last_modified))
ctx = {
"shared_repos": shared_repos,
}
html = render_to_string('my_shared_repos.html', ctx,
context_instance=RequestContext(request))
return HttpResponse(html)
开发者ID:youngdev,项目名称:seahub,代码行数:21,代码来源:ajax.py
示例8: render_to_response
quota_usage = 0
share_usage = 0
my_usage = 0
my_usage = seafile_api.get_user_self_usage(email)
if CALC_SHARE_USAGE:
try:
share_usage = seafile_api.get_user_share_usage(email)
except SearpcError, e:
logger.error(e)
share_usage = 0
quota_usage = my_usage + share_usage
else:
quota_usage = my_usage
# Repos that are share to user
in_repos = seafile_api.get_share_in_repo_list(email, -1, -1)
# get user profile
profile = Profile.objects.get_profile_by_user(email)
d_profile = DetailedProfile.objects.get_detailed_profile_by_user(email)
return render_to_response(
'sysadmin/userinfo.html', {
'owned_repos': owned_repos,
'quota': quota,
'quota_usage': quota_usage,
'CALC_SHARE_USAGE': CALC_SHARE_USAGE,
'share_usage': share_usage,
'my_usage': my_usage,
'in_repos': in_repos,
'email': email,
开发者ID:Neurones67,项目名称:seahub,代码行数:31,代码来源:sysadmin.py
示例9: addRepo
repo = seafile_api.get_repo(repo_id)
if repo:
all_repos[repo_id] = repo
except SearpcError, e:
util.warn("Failed to get repo %.8s: %s" % (repo_id, e.msg))
try:
owned_repos = seafile_api.get_owned_repo_list(username)
except SearpcError, e:
util.warn("Failed to list owned repos: %s" % e.msg)
for orepo in owned_repos:
addRepo(orepo.id)
try:
shared_repos = seafile_api.get_share_in_repo_list(username, -1, -1)
except SearpcError, e:
util.warn("Failed to list shared repos: %s" % e.msg)
for srepo in shared_repos:
addRepo(srepo.repo_id)
try:
joined_groups = seaserv.get_personal_groups_by_user(username)
except SearpcError, e:
util.warn("Failed to get groups for %s" % username)
for g in joined_groups:
try:
group_repos = seafile_api.get_group_repo_list(g.id)
for repo in group_repos:
if all_repos.has_key(repo.id):
开发者ID:mar10,项目名称:seafdav,代码行数:31,代码来源:seafile_dav_provider.py
示例10: user_info
def user_info(request, email):
owned_repos = seafile_api.get_owned_repo_list(email)
org = ccnet_threaded_rpc.get_orgs_by_user(email)
org_name = None
if not org:
space_usage = seafile_api.get_user_self_usage(email)
space_quota = seafile_api.get_user_quota(email)
if CALC_SHARE_USAGE:
share_usage = seafile_api.get_user_share_usage(email)
share_quota = seafile_api.get_user_share_quota(email)
else:
share_quota = share_usage = 0
else:
org_id = org[0].org_id
org_name = org[0].org_name
space_usage = seafserv_threaded_rpc.get_org_user_quota_usage(org_id,
email)
space_quota = seafserv_threaded_rpc.get_org_user_quota(org_id, email)
share_usage = share_quota = 0
# Repos that are share to user
in_repos = seafile_api.get_share_in_repo_list(email, -1, -1)
# get user profile
profile = Profile.objects.get_profile_by_user(email)
d_profile = DetailedProfile.objects.get_detailed_profile_by_user(email)
user_shared_links = []
# download links
p_fileshares = []
fileshares = list(FileShare.objects.filter(username=email))
for fs in fileshares:
r = seafile_api.get_repo(fs.repo_id)
if not r:
fs.delete()
continue
if fs.is_file_share_link():
if seafile_api.get_file_id_by_path(r.id, fs.path) is None:
fs.delete()
continue
fs.filename = os.path.basename(fs.path)
path = fs.path.rstrip('/') # Normalize file path
obj_id = seafile_api.get_file_id_by_path(r.id, path)
fs.file_size = seafile_api.get_file_size(r.store_id, r.version,
obj_id)
else:
if seafile_api.get_dir_id_by_path(r.id, fs.path) is None:
fs.delete()
continue
fs.filename = os.path.basename(fs.path.rstrip('/'))
path = fs.path
if path[-1] != '/': # Normalize dir path
path += '/'
# get dir size
dir_id = seafserv_threaded_rpc.get_dirid_by_path(r.id,
r.head_cmmt_id,
path)
fs.dir_size = seafserv_threaded_rpc.get_dir_size(r.store_id,
r.version,
dir_id)
fs.is_download = True
p_fileshares.append(fs)
p_fileshares.sort(key=lambda x: x.view_cnt, reverse=True)
user_shared_links += p_fileshares
# upload links
uploadlinks = list(UploadLinkShare.objects.filter(username=email))
p_uploadlinks = []
for link in uploadlinks:
r = seafile_api.get_repo(link.repo_id)
if not r:
link.delete()
continue
if seafile_api.get_dir_id_by_path(r.id, link.path) is None:
link.delete()
continue
link.dir_name = os.path.basename(link.path.rstrip('/'))
link.is_upload = True
p_uploadlinks.append(link)
p_uploadlinks.sort(key=lambda x: x.view_cnt, reverse=True)
user_shared_links += p_uploadlinks
return render_to_response(
'sysadmin/userinfo.html', {
'owned_repos': owned_repos,
'space_quota': space_quota,
'space_usage': space_usage,
'share_quota': share_quota,
'share_usage': share_usage,
'CALC_SHARE_USAGE': CALC_SHARE_USAGE,
'in_repos': in_repos,
'email': email,
'profile': profile,
'd_profile': d_profile,
'org_name': org_name,
'user_shared_links': user_shared_links,
}, context_instance=RequestContext(request))
开发者ID:ggkitsas,项目名称:seahub,代码行数:100,代码来源:sysadmin.py
示例11: get
def get(self, request):
""" Return repos user can access.
Permission checking:
1. all authenticated user can perform this action.
"""
filter_by = {
'mine': False,
'shared': False,
'group': False,
'public': False,
}
request_type_list = request.GET.getlist('type', "")
if not request_type_list:
# set all to True, no filter applied
filter_by = filter_by.fromkeys(filter_by.iterkeys(), True)
for request_type in request_type_list:
request_type = request_type.strip()
filter_by[request_type] = True
email = request.user.username
# Use dict to reduce memcache fetch cost in large for-loop.
contact_email_dict = {}
nickname_dict = {}
org_id = None
if is_org_context(request):
org_id = request.user.org.org_id
try:
starred_repos = UserStarredFiles.objects.get_starred_repos_by_user(email)
starred_repo_id_list = [item.repo_id for item in starred_repos]
except Exception as e:
logger.error(e)
starred_repo_id_list = []
repo_info_list = []
if filter_by['mine']:
if org_id:
owned_repos = seafile_api.get_org_owned_repo_list(org_id,
email, ret_corrupted=True)
else:
owned_repos = seafile_api.get_owned_repo_list(email,
ret_corrupted=True)
# Reduce memcache fetch ops.
modifiers_set = set([x.last_modifier for x in owned_repos])
for e in modifiers_set:
if e not in contact_email_dict:
contact_email_dict[e] = email2contact_email(e)
if e not in nickname_dict:
nickname_dict[e] = email2nickname(e)
owned_repos.sort(lambda x, y: cmp(y.last_modify, x.last_modify))
for r in owned_repos:
# do not return virtual repos
if r.is_virtual:
continue
repo_info = {
"type": "mine",
"repo_id": r.id,
"repo_name": r.name,
"owner_email": email,
"owner_name": email2nickname(email),
"owner_contact_email": email2contact_email(email),
"last_modified": timestamp_to_isoformat_timestr(r.last_modify),
"modifier_email": r.last_modifier,
"modifier_name": nickname_dict.get(r.last_modifier, ''),
"modifier_contact_email": contact_email_dict.get(r.last_modifier, ''),
"size": r.size,
"encrypted": r.encrypted,
"permission": 'rw', # Always have read-write permission to owned repo
"starred": r.repo_id in starred_repo_id_list,
}
if is_pro_version() and ENABLE_STORAGE_CLASSES:
repo_info['storage_name'] = r.storage_name
repo_info['storage_id'] = r.storage_id
repo_info_list.append(repo_info)
if filter_by['shared']:
if org_id:
shared_repos = seafile_api.get_org_share_in_repo_list(org_id,
email, -1, -1)
else:
shared_repos = seafile_api.get_share_in_repo_list(
email, -1, -1)
repos_with_admin_share_to = ExtraSharePermission.objects.\
get_repos_with_admin_permission(email)
#.........这里部分代码省略.........
开发者ID:haiwen,项目名称:seahub,代码行数:101,代码来源:repos.py
示例12: my_shared_and_group_repos
def my_shared_and_group_repos(request):
"""Return html snippet of repos that shared to user and group repos.
Arguments:
- `request`:
"""
if not request.is_ajax():
raise Http404
content_type = 'application/json; charset=utf-8'
username = request.user.username
shared_repos = seafile_api.get_share_in_repo_list(username, -1, -1)
for repo in shared_repos:
repo.user_perm = seafile_api.check_repo_access_permission(repo.repo_id, username)
shared_repos.sort(lambda x, y: cmp(y.last_modified, x.last_modified))
group_repos = []
# Get all personal groups I joined.
joined_groups = request.user.joined_groups
# For each group I joined...
for grp in joined_groups:
# Get group repos, and for each group repos...
for r_id in seaserv.get_group_repoids(grp.id):
# No need to list my own repo
repo_owner = seafile_api.get_repo_owner(r_id)
if repo_owner == username:
continue
# Convert repo properties due to the different collumns in Repo
# and SharedRepo
r = seaserv.get_repo(r_id)
if not r:
continue
r.repo_id = r.id
r.repo_name = r.name
r.repo_desc = r.desc
r.last_modified = get_repo_last_modify(r)
r.share_type = 'group'
r.user = repo_owner
r.user_perm = seaserv.check_permission(r_id, username)
r.group = grp
group_repos.append(r)
group_repos.sort(key=lambda x: x.group.group_name)
for i, repo in enumerate(group_repos):
if i == 0:
repo.show_group_name = True
else:
if repo.group.group_name != group_repos[i-1].group.group_name:
repo.show_group_name = True
ctx_shared = {
"shared_repos": shared_repos,
}
ctx_group = {
"group_repos": group_repos,
}
shared_repos_html = render_to_string('snippets/my_shared_repos.html', ctx_shared,
context_instance=RequestContext(request))
group_repos_html = render_to_string('snippets/my_group_repos.html', ctx_group,
context_instance=RequestContext(request))
return HttpResponse(json.dumps({"shared": shared_repos_html, "group": group_repos_html}),
content_type=content_type)
开发者ID:zhouad,项目名称:seahub,代码行数:65,代码来源:ajax.py
注:本文中的seaserv.seafile_api.get_share_in_repo_list函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论