本文整理汇总了Python中seaserv.seafile_api.get_repo_owner函数的典型用法代码示例。如果您正苦于以下问题:Python get_repo_owner函数的具体用法?Python get_repo_owner怎么用?Python get_repo_owner使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_repo_owner函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: sys_repo_admin
def sys_repo_admin(request):
# Make sure page request is an int. If not, deliver first page.
try:
current_page = int(request.GET.get('page', '1'))
per_page = int(request.GET.get('per_page', '25'))
except ValueError:
current_page = 1
per_page = 25
repos_all = seafile_api.get_repo_list(per_page * (current_page -1),
per_page + 1)
repos = repos_all[:per_page]
if len(repos_all) == per_page + 1:
page_next = True
else:
page_next = False
for repo in repos:
try:
repo.owner = seafile_api.get_repo_owner(repo.id)
except:
repo.owner = "failed to get"
return render_to_response(
'sysadmin/sys_repo_admin.html', {
'repos': repos,
'current_page': current_page,
'prev_page': current_page-1,
'next_page': current_page+1,
'per_page': per_page,
'page_next': page_next,
},
context_instance=RequestContext(request))
开发者ID:Neurones67,项目名称:seahub,代码行数:33,代码来源:sysadmin.py
示例2: format_repo_share_msg
def format_repo_share_msg(self, notice):
d = json.loads(notice.detail)
repo_id = d['repo_id']
repo = seafile_api.get_repo(repo_id)
path = d['path']
org_id = d.get('org_id', None)
if path == '/':
shared_type = 'library'
else:
shared_type = 'folder'
if org_id:
owner = seafile_api.get_org_repo_owner(repo_id)
repo = seafile_api.get_org_virtual_repo(
org_id, repo_id, path, owner)
else:
owner = seafile_api.get_repo_owner(repo_id)
repo = seafile_api.get_virtual_repo(repo_id, path, owner)
repo_url = reverse('lib_view', args=[repo_id, repo.name, ''])
notice.repo_url = repo_url
notice.notice_from = escape(email2nickname(d['share_from']))
notice.repo_name = repo.name
notice.avatar_src = self.get_avatar_src(d['share_from'])
notice.shared_type = shared_type
return notice
开发者ID:haiwen,项目名称:seahub,代码行数:26,代码来源:send_notices.py
示例3: repo_online_gc
def repo_online_gc(request, repo_id):
if request.method != 'POST':
raise Http404
repo = get_repo(repo_id)
if not repo:
raise Http404
referer = request.META.get('HTTP_REFERER', None)
next = settings.SITE_ROOT if referer is None else referer
username = request.user.username
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo.id)
else:
repo_owner = seafile_api.get_repo_owner(repo.id)
is_repo_owner = True if repo_owner == username else False
if not is_repo_owner:
messages.error(request, _('Permission denied'))
return HttpResponseRedirect(next)
day = int(request.POST.get('day'))
try:
seafile_api.clean_up_repo_history(repo.id, day)
except SearpcError as e:
logger.error(e)
messages.error(request, _('Internal server error'))
return HttpResponseRedirect(next)
return HttpResponseRedirect(next)
开发者ID:domal,项目名称:seahub,代码行数:30,代码来源:__init__.py
示例4: get_repo_info
def get_repo_info(repo):
repo_owner = seafile_api.get_repo_owner(repo.repo_id)
if not repo_owner:
try:
org_repo_owner = seafile_api.get_org_repo_owner(repo.repo_id)
except Exception:
org_repo_owner = None
owner = repo_owner or org_repo_owner or ''
result = {}
result['id'] = repo.repo_id
result['name'] = repo.repo_name
result['owner'] = owner
result['owner_email'] = owner
result['owner_name'] = email2nickname(owner)
result['owner_contact_email'] = email2contact_email(owner)
result['size'] = repo.size
result['size_formatted'] = filesizeformat(repo.size)
result['encrypted'] = repo.encrypted
result['file_count'] = repo.file_count
if '@seafile_group' in owner:
group_id = get_group_id_by_repo_owner(owner)
result['group_name'] = group_id_to_name(group_id)
return result
开发者ID:haiwen,项目名称:seahub,代码行数:28,代码来源:libraries.py
示例5: 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
示例6: is_repo_admin
def is_repo_admin(username, repo_id):
repo_owner = seafile_api.get_repo_owner(repo_id)
try:
if '@seafile_group' in repo_owner:
# is group owned repo
group_id = int(repo_owner.split('@')[0])
if is_group_admin(group_id, username):
return True
else:
user_share_permission = ExtraSharePermission.objects.\
get_user_permission(repo_id, username)
if user_share_permission == PERMISSION_ADMIN:
return True
# get all groups that repo is shared to with admin permission
group_ids = ExtraGroupsSharePermission.objects.get_admin_groups_by_repo(repo_id)
for group_id in group_ids:
if is_group_admin(group_id, username):
return True
return False
except Exception as e:
logger.error(e)
return False
开发者ID:haiwen,项目名称:seahub,代码行数:25,代码来源:utils.py
示例7: get_group_repos
def get_group_repos(username, org_id, groups):
"""Get repos shared to groups.
"""
group_repos = []
if org_id:
# For each group I joined...
for grp in groups:
# Get group repos, and for each group repos...
for r_id in seafile_api.get_org_group_repoids(org_id, grp.id):
# No need to list my own repo
repo_owner = seafile_api.get_org_repo_owner(r_id)
if repo_owner == username:
continue
group_repos.append(r_id)
else:
# For each group I joined...
for grp in groups:
# Get group repos, and for each group repos...
for r_id in seafile_api.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
group_repos.append(r_id)
return group_repos
开发者ID:GregoireGalland,项目名称:seafdav,代码行数:25,代码来源:seafile_dav_provider.py
示例8: repo_history_view
def repo_history_view(request, repo_id):
"""View repo in history.
"""
repo = get_repo(repo_id)
if not repo:
raise Http404
username = request.user.username
path = get_path_from_request(request)
user_perm = check_folder_permission(request, repo.id, '/')
if user_perm is None:
return render_error(request, _(u'Permission denied'))
try:
server_crypto = UserOptions.objects.is_server_crypto(username)
except CryptoOptionNotSetError:
# Assume server_crypto is ``False`` if this option is not set.
server_crypto = False
if repo.encrypted and \
(repo.enc_version == 1 or (repo.enc_version == 2 and server_crypto)) \
and not is_password_set(repo.id, username):
return render_to_response(
'decrypt_repo_form.html', {
'repo':
repo,
'next':
get_next_url_from_request(request)
or reverse('repo', args=[repo.id]),
'force_server_crypto':
FORCE_SERVER_CRYPTO,
},
context_instance=RequestContext(request))
commit_id = request.GET.get('commit_id', None)
if commit_id is None:
return HttpResponseRedirect(reverse('repo', args=[repo.id]))
current_commit = get_commit(repo.id, repo.version, commit_id)
if not current_commit:
current_commit = get_commit(repo.id, repo.version, repo.head_cmmt_id)
file_list, dir_list, dirent_more = get_repo_dirents(
request, repo, current_commit, path)
zipped = get_nav_path(path, repo.name)
repo_owner = seafile_api.get_repo_owner(repo.id)
is_repo_owner = True if username == repo_owner else False
return render_to_response(
'repo_history_view.html', {
'repo': repo,
"is_repo_owner": is_repo_owner,
'user_perm': user_perm,
'current_commit': current_commit,
'dir_list': dir_list,
'file_list': file_list,
'path': path,
'zipped': zipped,
},
context_instance=RequestContext(request))
开发者ID:soloice,项目名称:seahub,代码行数:60,代码来源:repo.py
示例9: email_repo_owner
def email_repo_owner(self, repo_file):
repo_id, file_path = repo_file.split(':', 1)
owner = seafile_api.get_repo_owner(repo_id)
if not owner:
return
# save current language
cur_language = translation.get_language()
# get and active user language
user_language = self.get_user_language(owner)
translation.activate(user_language)
contact_email = Profile.objects.get_contact_email_by_user(owner)
send_html_email_with_dj_template(
contact_email, dj_template='notifications/notify_virus.html',
context={'owner': owner,
'file_url': reverse('view_lib_file',
args=[repo_id, file_path]),
'file_name': os.path.basename(file_path),
},
subject=_('Virus detected on %s') % get_site_name(),
priority=MAIL_PRIORITY.now
)
# restore current language
translation.activate(cur_language)
开发者ID:haiwen,项目名称:seahub,代码行数:27,代码来源:notify_admins_on_virus.py
示例10: get_related_users_by_repo
def get_related_users_by_repo(repo_id, org_id=None):
""" Return all users who can view this library.
1. repo owner
2. users repo has been shared to
3. members of groups repo has been shared to
"""
users = []
if org_id:
repo_owner = seafile_api.get_org_repo_owner(repo_id)
user_shared_to = seafile_api.list_org_repo_shared_to(org_id,
repo_owner, repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
user_shared_to = seafile_api.list_repo_shared_to(
repo_owner, repo_id)
# 1. repo owner
users.append(repo_owner)
# 2. users repo has been shared to
for user in user_shared_to:
users.append(user.user)
# 3. members of groups repo has been shared to
groups = get_shared_groups_by_repo(repo_id, org_id)
for group in groups:
members = ccnet_api.get_group_members(group.id)
for member in members:
if member.user_name not in users:
users.append(member.user_name)
return users
开发者ID:haiwen,项目名称:seahub,代码行数:35,代码来源:repo.py
示例11: repo_restored_cb
def repo_restored_cb(sender, **kwargs):
repo_id = kwargs['repo_id']
operator = kwargs['operator']
repo = seafile_api.get_repo(repo_id)
org_id = get_org_id_by_repo_id(repo_id)
if org_id > 0:
related_users = seafile_api.org_get_shared_users_by_repo(org_id, repo_id)
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
related_users = seafile_api.get_shared_users_by_repo(repo_id)
repo_owner = seafile_api.get_repo_owner(repo_id)
related_users.append(repo_owner)
record = {
'op_type':'recover',
'obj_type':'repo',
'timestamp': datetime.datetime.utcnow(),
'repo_id': repo_id,
'repo_name': repo.repo_name,
'path': '/',
'op_user': operator,
'related_users': [related_users],
'org_id': org_id,
}
from utils import SeafEventsSession
session = SeafEventsSession()
seafevents.save_user_activity(session, record)
session.close()
开发者ID:haiwen,项目名称:seahub,代码行数:30,代码来源:handlers.py
示例12: check_repo_owner_quota
def check_repo_owner_quota(self, isnewfile=True, contentlength=-1):
"""Check if the upload would cause the user quota be exceeded
`contentlength` is only positive when the client does not use "transfer-encode: chunking"
Return True if the quota would not be exceeded, otherwise return False.
"""
if contentlength <= 0:
# When client use "transfer-encode: chunking", the content length
# is not included in the request headers
if isnewfile:
return check_repo_quota(self.repo.id) >= 0
else:
return True
if not self.owner:
self.owner = seafile_api.get_repo_owner(self.repo.id)
quota = seafile_api.get_user_quota(self.owner)
if quota == INFINITE_QUOTA:
return True
self_usage = seafile_api.get_user_self_usage(self.owner)
share_usage = seafile_api.get_user_share_usage(self.owner) if CALC_SHARE_USAGE else 0
remain = quota - self_usage - share_usage
if not isnewfile:
remain -= self.obj.size
return contentlength <= remain
开发者ID:mar10,项目名称:seafdav,代码行数:28,代码来源:seafile_dav_provider.py
示例13: format_repo_share_to_group_msg
def format_repo_share_to_group_msg(self):
"""
Arguments:
- `self`:
"""
try:
d = json.loads(self.detail)
except Exception as e:
logger.error(e)
return _(u"Internal error")
share_from = email2nickname(d['share_from'])
repo_id = d['repo_id']
group_id = d['group_id']
path = d.get('path', '/')
org_id = d.get('org_id', None)
repo = None
try:
group = ccnet_api.get_group(group_id)
if path == '/':
repo = seafile_api.get_repo(repo_id)
else:
if org_id:
owner = seafile_api.get_org_repo_owner(repo_id)
repo = seafile_api.get_org_virtual_repo(
org_id, repo_id, path, owner)
else:
owner = seafile_api.get_repo_owner(repo_id)
repo = seafile_api.get_virtual_repo(repo_id, path, owner)
except Exception as e:
logger.error(e)
return None
if not repo or not group:
self.delete()
return None
if path == '/':
tmpl = 'notifications/notice_msg/repo_share_to_group_msg.html'
else:
tmpl = 'notifications/notice_msg/folder_share_to_group_msg.html'
lib_url = reverse('lib_view', args=[repo.id, repo.name, ''])
group_url = reverse('group', args=[group.id])
msg = render_to_string(tmpl, {
'user': share_from,
'lib_url': lib_url,
'lib_name': repo.name,
'group_url': group_url,
'group_name': group.group_name,
})
return msg
开发者ID:haiwen,项目名称:seahub,代码行数:55,代码来源:models.py
示例14: unsetinnerpub
def unsetinnerpub(request, repo_id):
"""Unshare repos in organization or in share admin page.
Only system admin, organization admin or repo owner can perform this op.
"""
repo = get_repo(repo_id)
perm = request.GET.get('permission', None)
if perm is None:
return render_error(request, _(u'Argument is not valid'))
if not repo:
messages.error(request, _('Failed to unshare the library, as it does not exist.'))
return HttpResponseRedirect(reverse('share_admin'))
# permission check
username = request.user.username
if is_org_context(request):
org_id = request.user.org.org_id
repo_owner = seafile_api.get_org_repo_owner(repo.id)
is_repo_owner = True if repo_owner == username else False
if not (request.user.org.is_staff or is_repo_owner):
raise Http404
else:
repo_owner = seafile_api.get_repo_owner(repo.id)
is_repo_owner = True if repo_owner == username else False
if not (request.user.is_staff or is_repo_owner):
raise Http404
try:
if is_org_context(request):
org_id = request.user.org.org_id
seaserv.seafserv_threaded_rpc.unset_org_inner_pub_repo(org_id,
repo.id)
else:
seaserv.unset_inner_pub_repo(repo.id)
origin_repo_id, origin_path = get_origin_repo_info(repo.id)
if origin_repo_id is not None:
perm_repo_id = origin_repo_id
perm_path = origin_path
else:
perm_repo_id = repo.id
perm_path = '/'
send_perm_audit_msg('delete-repo-perm', username, 'all',
perm_repo_id, perm_path, perm)
messages.success(request, _('Unshare "%s" successfully.') % repo.name)
except SearpcError:
messages.error(request, _('Failed to unshare "%s".') % repo.name)
referer = request.META.get('HTTP_REFERER', None)
next = settings.SITE_ROOT if referer is None else referer
return HttpResponseRedirect(next)
开发者ID:littlehei,项目名称:seahub,代码行数:54,代码来源:__init__.py
示例15: get_repo_owner
def get_repo_owner(request, repo_id):
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
# for admin panel
# administrator may get org repo's owner
repo_owner = seafile_api.get_repo_owner(repo_id)
if not repo_owner:
repo_owner = seafile_api.get_org_repo_owner(repo_id)
return repo_owner
开发者ID:haiwen,项目名称:seahub,代码行数:11,代码来源:repo.py
示例16: list_repos_by_name
def list_repos_by_name(repo_name):
repos = []
repos_all = seafile_api.get_repo_list(-1, -1)
for repo in repos_all:
if repo_name in repo.name:
try:
repo.owner = seafile_api.get_repo_owner(repo.id)
except SearpcError:
repo.owner = "failed to get"
repos.append(repo)
return repos
开发者ID:Neurones67,项目名称:seahub,代码行数:11,代码来源:sysadmin.py
示例17: get_repo_info
def get_repo_info(repo):
result = {}
result['id'] = repo.repo_id
result['name'] = repo.repo_name
result['owner'] = seafile_api.get_repo_owner(repo.repo_id)
result['size'] = repo.size
result['size_formatted'] = filesizeformat(repo.size)
result['encrypted'] = repo.encrypted
result['file_count'] = repo.file_count
return result
开发者ID:TanLian,项目名称:seahub,代码行数:12,代码来源:libraries.py
示例18: get_group_repos
def get_group_repos(username, org_id, groups):
"""Get repos shared to groups.
"""
group_repos = []
if org_id:
# For each group I joined...
for grp in groups:
# Get group repos, and for each group repos...
for r_id in seafile_api.get_org_group_repoids(org_id, grp.id):
# No need to list my own repo
repo_owner = seafile_api.get_org_repo_owner(r_id)
if repo_owner == username:
continue
# Convert repo properties due to the different collumns in Repo
# and SharedRepo
r = seafile_api.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 = seafile_api.check_repo_access_permission(
r_id, username)
r.group = grp
group_repos.append(r)
else:
# For each group I joined...
for grp in groups:
# Get group repos, and for each group repos...
for r_id in seafile_api.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 = seafile_api.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 = seafile_api.check_repo_access_permission(
r_id, username)
r.group = grp
group_repos.append(r)
return group_repos
开发者ID:ltsmat,项目名称:seafdav,代码行数:53,代码来源:seafile_dav_provider.py
示例19: render_recycle_root
def render_recycle_root(request, repo_id):
repo = get_repo(repo_id)
if not repo:
raise Http404
scan_stat = request.GET.get('scan_stat', None)
try:
deleted_entries = seafile_api.get_deleted(repo_id, 0, '/', scan_stat)
except SearpcError as e:
logger.error(e)
referer = request.META.get('HTTP_REFERER', None)
next = settings.SITE_ROOT if referer is None else referer
return HttpResponseRedirect(next)
if not deleted_entries:
new_scan_stat = None
else:
new_scan_stat = deleted_entries[-1].scan_stat
trash_more = True if new_scan_stat is not None else False
deleted_entries = deleted_entries[0:-1]
for dirent in deleted_entries:
if stat.S_ISDIR(dirent.mode):
dirent.is_dir = True
else:
dirent.is_dir = False
# Entries sort by deletion time in descending order.
deleted_entries.sort(lambda x, y : cmp(y.delete_time,
x.delete_time))
username = request.user.username
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo.id)
else:
repo_owner = seafile_api.get_repo_owner(repo.id)
is_repo_owner = True if repo_owner == username else False
enable_clean = False
if is_repo_owner:
enable_clean = True
return render_to_response('repo_dir_recycle_view.html', {
'show_recycle_root': True,
'repo': repo,
'repo_dir_name': repo.name,
'dir_entries': deleted_entries,
'scan_stat': new_scan_stat,
'trash_more': trash_more,
'enable_clean': enable_clean,
}, context_instance=RequestContext(request))
开发者ID:domal,项目名称:seahub,代码行数:52,代码来源:__init__.py
示例20: my_group_repos
def my_group_repos(request):
"""Return html snippet of group repos.
Arguments:
- `request`:
"""
if not request.is_ajax():
raise Http404
username = request.user.username
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 = {
"group_repos": group_repos,
}
html = render_to_string('my_group_repos.html', ctx,
context_instance=RequestContext(request))
return HttpResponse(html)
开发者ID:youngdev,项目名称:seahub,代码行数:51,代码来源:ajax.py
注:本文中的seaserv.seafile_api.get_repo_owner函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论