• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python seafile_api.get_owned_repo_list函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中seaserv.seafile_api.get_owned_repo_list函数的典型用法代码示例。如果您正苦于以下问题:Python get_owned_repo_list函数的具体用法?Python get_owned_repo_list怎么用?Python get_owned_repo_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_owned_repo_list函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: delete

    def delete(self):
        """
        When delete user, we should also delete group relationships.
        """
        if self.source == "DB":
            source = "DB"
        else:
            source = "LDAP"

        owned_repos = []
        orgs = ccnet_threaded_rpc.get_orgs_by_user(self.username)
        if orgs:
            for org in orgs:
                owned_repos += seafile_api.get_org_owned_repo_list(org.org_id,
                                                                   self.username)
        else:
            owned_repos += seafile_api.get_owned_repo_list(self.username)

        for r in owned_repos:
            seafile_api.remove_repo(r.id)

        clear_token(self.username)
        # remove current user from joined groups
        ccnet_api.remove_group_user(self.username)
        ccnet_api.remove_emailuser(source, self.username)
        Profile.objects.delete_profile_by_user(self.username)
开发者ID:pinguo-liuhongwei,项目名称:seahub,代码行数:26,代码来源:accounts.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: personal_wiki

def personal_wiki(request, page_name="home"):
    username = request.user.username
    wiki_exists = True
    try:
        content, repo, dirent = get_personal_wiki_page(username, page_name)
    except WikiDoesNotExist:
        wiki_exists = False
        owned_repos = seafile_api.get_owned_repo_list(username)
        owned_repos = [r for r in owned_repos if not r.encrypted]
        return render_to_response(
            "wiki/personal_wiki.html",
            {"wiki_exists": wiki_exists, "owned_repos": owned_repos},
            context_instance=RequestContext(request),
        )
    except WikiPageMissing:
        repo = get_personal_wiki_repo(username)
        filename = clean_page_name(page_name) + ".md"
        if not seaserv.post_empty_file(repo.id, "/", filename, username):
            return render_error(request, _("Failed to create wiki page. Please retry later."))
        return HttpResponseRedirect(reverse("personal_wiki", args=[page_name]))
    else:
        url_prefix = reverse("personal_wiki", args=[])
        content = convert_wiki_link(content, url_prefix, repo.id, username)

        # fetch file latest contributor and last modified
        path = "/" + dirent.obj_name
        file_path_hash = hashlib.md5(urllib2.quote(path.encode("utf-8"))).hexdigest()[:12]
        contributors, last_modified, last_commit_id = FileContributors.objects.get_file_contributors(
            repo.id, path.encode("utf-8"), file_path_hash, dirent.obj_id
        )
        latest_contributor = contributors[0] if contributors else None

        wiki_index_exists = True
        index_pagename = "index"
        index_content = None
        try:
            index_content, index_repo, index_dirent = get_personal_wiki_page(username, index_pagename)
        except (WikiDoesNotExist, WikiPageMissing) as e:
            wiki_index_exists = False
        else:
            index_content = convert_wiki_link(index_content, url_prefix, index_repo.id, username)

        return render_to_response(
            "wiki/personal_wiki.html",
            {
                "wiki_exists": wiki_exists,
                "content": content,
                "page": os.path.splitext(dirent.obj_name)[0],
                "last_modified": last_modified,
                "latest_contributor": latest_contributor,
                "path": path,
                "repo_id": repo.id,
                "search_repo_id": repo.id,
                "search_wiki": True,
                "wiki_index_exists": wiki_index_exists,
                "index_content": index_content,
            },
            context_instance=RequestContext(request),
        )
开发者ID:vikingliu,项目名称:seahub,代码行数:59,代码来源:wiki.py


示例4: list_repos_by_name_and_owner

def list_repos_by_name_and_owner(repo_name, owner):
    repos = []
    owned_repos = seafile_api.get_owned_repo_list(owner)
    for repo in owned_repos:
        if repo_name in repo.name:
            repo.owner = owner
            repos.append(repo)
    return repos
开发者ID:Neurones67,项目名称:seahub,代码行数:8,代码来源:sysadmin.py


示例5: personal_wiki

def personal_wiki(request, page_name="home"):
    username = request.user.username
    wiki_exists = True
    try:
        content, repo, dirent = get_personal_wiki_page(username, page_name)
    except WikiDoesNotExist:
        wiki_exists = False
        owned_repos = seafile_api.get_owned_repo_list(username)
        owned_repos = [r for r in owned_repos if not r.encrypted]
        return render_to_response("wiki/personal_wiki.html", {
                "wiki_exists": wiki_exists,
                "owned_repos": owned_repos,
                }, context_instance=RequestContext(request))
    except WikiPageMissing:
        repo = get_personal_wiki_repo(username)
        filename = clean_page_name(page_name) + '.md'
        if not seaserv.post_empty_file(repo.id, "/", filename, username):
            return render_error(request, _("Failed to create wiki page. Please retry later."))
        return HttpResponseRedirect(reverse('personal_wiki', args=[page_name]))
    else:
        url_prefix = reverse('personal_wiki', args=[])
        content = convert_wiki_link(content, url_prefix, repo.id, username)
        
        # fetch file modified time and modifier
        path = '/' + dirent.obj_name
        try:
            dirent = seafile_api.get_dirent_by_path(repo.id, path)
            if dirent:
                latest_contributor, last_modified = dirent.modifier, dirent.mtime
            else:
                latest_contributor, last_modified = None, 0
        except SearpcError as e:
            logger.error(e)
            latest_contributor, last_modified = None, 0

        wiki_index_exists = True
        index_pagename = 'index'
        index_content = None
        try:
            index_content, index_repo, index_dirent = get_personal_wiki_page(username, index_pagename)
        except (WikiDoesNotExist, WikiPageMissing) as e:
            wiki_index_exists = False
        else:
            index_content = convert_wiki_link(index_content, url_prefix, index_repo.id, username)

        return render_to_response("wiki/personal_wiki.html", { 
            "wiki_exists": wiki_exists,
            "content": content,
            "page": os.path.splitext(dirent.obj_name)[0],
            "last_modified": last_modified,
            "latest_contributor": latest_contributor or _("Unknown"),
            "path": path,
            "repo_id": repo.id,
            "search_repo_id": repo.id,
            "search_wiki": True,
            "wiki_index_exists": wiki_index_exists,
            "index_content": index_content,
            }, context_instance=RequestContext(request))
开发者ID:hangshisitu,项目名称:seahub,代码行数:58,代码来源:wiki.py


示例6: get_owned_repo_list

def get_owned_repo_list(request):
    """List owned repos.
    """
    username = request.user.username
    if is_org_context(request):
        org_id = request.user.org.org_id
        return seafile_api.get_org_owned_repo_list(org_id, username)
    else:
        return seafile_api.get_owned_repo_list(username)
开发者ID:domal,项目名称:seahub,代码行数:9,代码来源:__init__.py


示例7: edit_profile

def edit_profile(request):
    """
    Show and edit user profile.
    """
    username = request.user.username
    form_class = DetailedProfileForm

    if request.method == 'POST':
        form = form_class(request.POST)
        if form.is_valid():
            form.save(username=username)
            messages.success(request, _(u'Successfully edited profile.'))
            # refresh nickname cache
            refresh_cache(request.user.username)
            
            return HttpResponseRedirect(reverse('edit_profile'))
        else:
            messages.error(request, _(u'Failed to edit profile'))
    else:
        profile = Profile.objects.get_profile_by_user(username)
        d_profile = DetailedProfile.objects.get_detailed_profile_by_user(
            username)

        init_dict = {}
        if profile:
            init_dict['nickname'] = profile.nickname
            init_dict['intro'] = profile.intro
        if d_profile:
            init_dict['department'] = d_profile.department
            init_dict['telephone'] = d_profile.telephone
        form = form_class(init_dict)
        
    # common logic
    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   

    sub_lib_enabled = UserOptions.objects.is_sub_lib_enabled(username)

    default_repo_id = UserOptions.objects.get_default_repo(username)
    if default_repo_id:
        default_repo = seafile_api.get_repo(default_repo_id)
    else:
        default_repo = None
    owned_repos = seafile_api.get_owned_repo_list(username)

    return render_to_response('profile/set_profile.html', {
            'form': form,
            'server_crypto': server_crypto,
            "sub_lib_enabled": sub_lib_enabled,
            'force_server_crypto': settings.FORCE_SERVER_CRYPTO,
            'default_repo': default_repo,
            'owned_repos': owned_repos,
            }, context_instance=RequestContext(request))
开发者ID:Pablohn26,项目名称:seahub,代码行数:56,代码来源:views.py


示例8: get_keeper_default_library

def get_keeper_default_library():
    try:
        from_repos = seafile_api.get_owned_repo_list(SERVER_EMAIL)
        from_repos = [r for r in from_repos if r.name == KEEPER_DEFAULT_LIBRARY]
        if from_repos:
            from_repo_id = from_repos[0].id
            return { 'repo_id': from_repo_id, 'dirents': seafile_api.list_dir_by_path(from_repo_id, '/') }
        else:
            raise Exception("Cannot find KEEPER_DEFAULT_LIBRARY repo in admin libraries, please install!")
    except Exception as err:
        logging.error("Cannot find KEEPER_DEFAULT_LIBRARY dirents, err: " + str(err))
        return None
开发者ID:MPDL,项目名称:KEEPER,代码行数:12,代码来源:default_library_manager.py


示例9: user_info

def user_info(request, email):

    owned_repos = seafile_api.get_owned_repo_list(email)

    quota = seafile_api.get_user_quota(email)
    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
开发者ID:Neurones67,项目名称:seahub,代码行数:16,代码来源:sysadmin.py


示例10: get_my_unenc_repos

def get_my_unenc_repos(request):
    """Get my owned and unencrypted repos.
    """
    if not request.is_ajax():
        raise Http404
    
    content_type = 'application/json; charset=utf-8'

    repos = seafile_api.get_owned_repo_list(request.user.username)
    repo_list = []
    for repo in repos:
        if repo.encrypted:
            continue
        repo_list.append({"name": repo.name, "id": repo.id})
    
    return HttpResponse(json.dumps(repo_list), content_type=content_type)
开发者ID:mhltlyc,项目名称:seahub,代码行数:16,代码来源:ajax.py


示例11: 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)
    if not org:
        my_usage = seafile_api.get_user_self_usage(email)
        quota = seafile_api.get_user_quota(email)
    else:
        org_id = org[0].org_id
        my_usage =seafserv_threaded_rpc. \
                get_org_user_quota_usage(org_id, email)
        quota = seafserv_threaded_rpc. \
                get_org_user_quota(org_id, 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
开发者ID:frankcash,项目名称:seahub,代码行数:21,代码来源:sysadmin.py


示例12: user_info

def user_info(request, email):
    if request.method == 'POST':
        result = {}
        content_type = 'application/json; charset=utf-8'

        f = SetUserQuotaForm(request.POST)
        if f.is_valid():
            email = f.cleaned_data['email']
            quota_mb = f.cleaned_data['quota']
            quota = quota_mb * (1 << 20)

            try:
                seafile_api.set_user_quota(email, quota)
            except:
                result['error'] = _(u'Failed to set quota: internal error')
                return HttpResponse(json.dumps(result), content_type=content_type)

            result['success'] = True
            return HttpResponse(json.dumps(result), content_type=content_type)
        else:
            result['error'] = str(f.errors.values()[0])
            return HttpResponse(json.dumps(result), content_type=content_type)

    owned_repos = []

    owned_repos = seafile_api.get_owned_repo_list(email)

    quota = seafile_api.get_user_quota(email)
    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
开发者ID:twlkyao,项目名称:seahub,代码行数:39,代码来源:sysadmin.py


示例13: list_repos_by_owner

def list_repos_by_owner(owner):
    repos = seafile_api.get_owned_repo_list(owner)
    for e in repos:
        e.owner = owner
    return repos
开发者ID:Neurones67,项目名称:seahub,代码行数:5,代码来源:sysadmin.py


示例14: test_migrate

    def test_migrate(self):
        self.login_as(self.admin)

        # user1 created a repo
        user1_repo = self.create_repo(name='user1-repo', desc='',
                                      username=self.user1.username,
                                      passwd=None)
        user1_repos = seafile_api.get_owned_repo_list(self.user1.username)
        self.assertEqual(len(user1_repos), 1)
        self.assertEqual(user1_repos[0].id, user1_repo)

        # user1 created a group and joined a group created by the other
        user1_group = self.create_group(group_name='test_group',
                                        username=self.user1.username)
        other_group = self.create_group(group_name='other_group',
                                        username=self.user.username)
        seaserv.ccnet_threaded_rpc.group_add_member(other_group.id,
                                                    self.user.username,
                                                    self.user1.username)

        user1_groups = seaserv.get_personal_groups_by_user(self.user1.username)
        self.assertEqual(len(user1_groups), 2)
        self.assertEqual(user1_groups[0].id, user1_group.id)
        self.assertEqual(user1_groups[0].creator_name, self.user1.username)
        self.assertEqual(user1_groups[1].id, other_group.id)
        self.assertEqual(user1_groups[1].creator_name, self.user.username)

        # user2 had no repos
        user2_repos = seafile_api.get_owned_repo_list(self.user2.username)
        self.assertEqual(len(user2_repos), 0)
        # user2 had no groups
        user2_groups = seaserv.get_personal_groups_by_user(self.user2.username)
        self.assertEqual(len(user2_groups), 0)

        # admin migrate account user1 to account user2
        resp = self._do_migrate()
        self.assertEqual(200, resp.status_code)

        ### Verify ###
        # user1 should have no repos
        new_user1_repos = seafile_api.get_owned_repo_list(self.user1.username)
        self.assertEqual(len(new_user1_repos), 0)
        # user1 should still in two groups, except not the creator anymore in
        # the first group, but second group should remain the same
        user1_groups = seaserv.get_personal_groups_by_user(self.user1.username)
        self.assertEqual(len(user1_groups), 2)
        self.assertEqual(user1_groups[0].id, user1_group.id)
        self.assertNotEqual(user1_groups[0].creator_name, self.user1.username)
        self.assertEqual(user1_groups[1].id, other_group.id)
        self.assertEqual(user1_groups[1].creator_name, self.user.username)

        # user2 should have the repo used to be user1's
        new_user2_repos = seafile_api.get_owned_repo_list(self.user2.username)
        self.assertEqual(len(new_user2_repos), 1)
        self.assertEqual(new_user2_repos[0].id, user1_repo)
        # user2 should be in two groups, and is the creator of first group,
        # but second group should remain the same
        user2_groups = seaserv.get_personal_groups_by_user(self.user2.username)
        self.assertEqual(len(user2_groups), 2)
        self.assertEqual(user2_groups[0].id, user1_group.id)
        self.assertEqual(user2_groups[0].creator_name, self.user2.username)
        self.assertEqual(user2_groups[1].id, other_group.id)
        self.assertEqual(user2_groups[1].creator_name, self.user.username)
开发者ID:AviorAlong,项目名称:haiwen-5.1.3,代码行数:63,代码来源:test_account.py


示例15: 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


示例16: getAccessibleRepos

def getAccessibleRepos(username):
    all_repos = {}

    def addRepo(repo_id):
        try:
            if all_repos.has_key(repo_id):
                return
            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:
开发者ID:mar10,项目名称:seafdav,代码行数:30,代码来源:seafile_dav_provider.py


示例17: get

    def get(self, request, format=None):
        """ List 'all' libraries (by name/owner/page)

        Permission checking:
        1. only admin can perform this action.
        """

        # search libraries (by name/owner)
        repo_name = request.GET.get('name', '')
        owner = request.GET.get('owner', '')
        repos = []
        if repo_name and owner:
            # search by name and owner
            owned_repos = seafile_api.get_owned_repo_list(owner)
            for repo in owned_repos:
                if not repo.name or repo.is_virtual:
                    continue

                if repo_name in repo.name:
                    repo_info = get_repo_info(repo)
                    repos.append(repo_info)

            return Response({"name": repo_name, "owner": owner, "repos": repos})

        elif repo_name:
            # search by name(keyword in name)
            repos_all = seafile_api.get_repo_list(-1, -1)
            for repo in repos_all:
                if not repo.name or repo.is_virtual:
                    continue

                if repo_name in repo.name:
                    repo_info = get_repo_info(repo)
                    repos.append(repo_info)

            return Response({"name": repo_name, "owner": '', "repos": repos})

        elif owner:
            # search by owner
            owned_repos = seafile_api.get_owned_repo_list(owner)
            for repo in owned_repos:
                if repo.is_virtual:
                    continue

                repo_info = get_repo_info(repo)
                repos.append(repo_info)

            return Response({"name": '', "owner": owner, "repos": repos})

        # get libraries by page
        try:
            current_page = int(request.GET.get('page', '1'))
            per_page = int(request.GET.get('per_page', '100'))
        except ValueError:
            current_page = 1
            per_page = 100

        start = (current_page - 1) * per_page
        limit = per_page + 1

        repos_all = seafile_api.get_repo_list(start, limit)

        if len(repos_all) > per_page:
            repos_all = repos_all[:per_page]
            has_next_page = True
        else:
            has_next_page = False

        default_repo_id = get_system_default_repo_id()
        repos_all = filter(lambda r: not r.is_virtual, repos_all)
        repos_all = filter(lambda r: r.repo_id != default_repo_id, repos_all)

        return_results = []

        for repo in repos_all:
            repo_info = get_repo_info(repo)
            return_results.append(repo_info)

        page_info = {
            'has_next_page': has_next_page,
            'current_page': current_page
        }

        return Response({"page_info": page_info, "repos": return_results})
开发者ID:haiwen,项目名称:seahub,代码行数:84,代码来源:libraries.py


示例18: 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


示例19: get_owned_repos

def get_owned_repos(username, org_id):
    if org_id:
        return seafile_api.get_org_owned_repo_list(org_id, username)
    else:
        return seafile_api.get_owned_repo_list(username)
开发者ID:GregoireGalland,项目名称:seafdav,代码行数:5,代码来源:seafile_dav_provider.py



注:本文中的seaserv.seafile_api.get_owned_repo_list函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python seafile_api.get_repo函数代码示例发布时间:2022-05-27
下一篇:
Python seafile_api.get_org_repo_owner函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap