当前位置: 首页>>代码示例>>Python>>正文


Python seafile_api.get_user_self_usage函数代码示例

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


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

示例1: get_institution_space_usage

def get_institution_space_usage(inst):
    # TODO: need to refactor
    usernames = [x.user for x in Profile.objects.filter(institution=inst.name)]
    total = 0
    for user in usernames:
        total += seafile_api.get_user_self_usage(user)
    return total
开发者ID:haiwen,项目名称:seahub,代码行数:7,代码来源:utils.py

示例2: check_user_share_quota

def check_user_share_quota(username, repo, users=[], groups=[]):
    """Check whether user has enough quota when share repo to users/groups.
    """
    if not users and not groups:
        return True

    if not seaserv.CALC_SHARE_USAGE:
        return True

    check_pass = False
    quota = seafile_api.get_user_quota(username)
    self_usage = seafile_api.get_user_self_usage(username)
    current_share_usage = seafile_api.get_user_share_usage(username)

    share_usage = 0
    if users:
        share_usage += seafile_api.get_repo_size(repo.id) * (len(users))

    if groups:
        grp_members = []
        for group in groups:
            grp_members += [ e.user_name for e in seaserv.get_group_members(group.id)]
        grp_members = set(grp_members)
        share_usage += seafile_api.get_repo_size(repo.id) * (len(grp_members) -1)
    if share_usage + self_usage + current_share_usage < quota:
        check_pass = True

    return check_pass
开发者ID:allo-,项目名称:seahub,代码行数:28,代码来源:views.py

示例3: user_search

def user_search(request):
    """Search a user.
    """
    email = request.GET.get('email', '')
    email_patt = email.replace('*', '%')
    
    users  = ccnet_threaded_rpc.search_emailusers(email_patt, -1, -1)
    last_logins = UserLastLogin.objects.filter(username__in=[x.email for x in users])
    for user in users:
        try:
            user.self_usage = seafile_api.get_user_self_usage(user.email)
            user.share_usage = seafile_api.get_user_share_usage(user.email)
            user.quota = seafile_api.get_user_quota(user.email)
        except:
            user.self_usage = -1
            user.share_usage = -1
            user.quota = -1
        # populate user last login time
        user.last_login = None
        for last_login in last_logins:
            if last_login.username == user.email:
                user.last_login = last_login.last_login

    return render_to_response('sysadmin/user_search.html', {
            'users': users,
            'email': email,
            }, context_instance=RequestContext(request))
开发者ID:Neurones67,项目名称:seahub,代码行数:27,代码来源:sysadmin.py

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

示例5: get_user_info

def get_user_info(email):

    user = User.objects.get(email=email)
    d_profile = DetailedProfile.objects.get_detailed_profile_by_user(email)
    profile = Profile.objects.get_profile_by_user(email)

    info = {}
    info['email'] = email
    info['name'] = email2nickname(email)
    info['contact_email'] = profile.contact_email if profile and profile.contact_email else ''
    info['login_id'] = profile.login_id if profile and profile.login_id else ''

    info['is_staff'] = user.is_staff
    info['is_active'] = user.is_active
    info['create_time'] = user.ctime
    info['reference_id'] = user.reference_id if user.reference_id else ''

    info['department'] = d_profile.department if d_profile else ''

    info['quota_total'] = seafile_api.get_user_quota(email)
    info['quota_usage'] = seafile_api.get_user_self_usage(email)

    info['create_time'] = timestamp_to_isoformat_timestr(user.ctime)

    if is_pro_version():
        info['role'] = user.role

    return info
开发者ID:haiwen,项目名称:seahub,代码行数:28,代码来源:users.py

示例6: _populate_user_quota_usage

def _populate_user_quota_usage(user):
    """Populate space/share quota to user.

    Arguments:
    - `user`:
    """
    orgs = ccnet_threaded_rpc.get_orgs_by_user(user.email)
    try:
        if orgs:
            user.org = orgs[0]
            org_id = user.org.org_id
            user.space_usage = seafserv_threaded_rpc.get_org_user_quota_usage(org_id, user.email)
            user.space_quota = seafserv_threaded_rpc.get_org_user_quota(org_id, user.email)
            user.share_usage = user.share_quota = 0
        else:
            user.space_usage = seafile_api.get_user_self_usage(user.email)
            user.space_quota = seafile_api.get_user_quota(user.email)

            if CALC_SHARE_USAGE:
                user.share_quota = seafile_api.get_user_share_quota(user.email)
                user.share_usage = seafile_api.get_user_share_usage(user.email)
            else:
                user.share_usage = user.share_quota = 0
    except SearpcError as e:
        logger.error(e)
        user.space_usage = user.space_quota = user.share_usage = user.share_quota = -1
开发者ID:ggkitsas,项目名称:seahub,代码行数:26,代码来源:sysadmin.py

示例7: get_quota_usage

def get_quota_usage(username):
    # https://github.com/haiwen/seahub/blob/master/seahub/api2/views.py#L310
    used = seafile_api.get_user_self_usage(username) + seafile_api.get_user_share_usage(username)
    total = seafile_api.get_user_quota(username)
    if used > 0:
        used = float(used)
    if total == -2:
        total = float(2)
    elif total > 0:
        total = float(total)
    return used, total
开发者ID:goaxe,项目名称:lab,代码行数:11,代码来源:server_info.py

示例8: sys_user_admin

def sys_user_admin(request):
    """List all users from database.
    """
    # 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
    users_plus_one = get_emailusers('DB', per_page * (current_page - 1), per_page + 1)
    if len(users_plus_one) == per_page + 1:
        page_next = True
    else:
        page_next = False

    users = users_plus_one[:per_page]
    last_logins = UserLastLogin.objects.filter(username__in=[x.email for x in users])
    for user in users:
        if user.props.id == request.user.id:
            user.is_self = True
        try:
            user.self_usage = seafile_api.get_user_self_usage(user.email)
            user.share_usage = seafile_api.get_user_share_usage(user.email)
            user.quota = seafile_api.get_user_quota(user.email)
        except:
            user.self_usage = -1
            user.share_usage = -1
            user.quota = -1
        # populate user last login time
        user.last_login = None
        for last_login in last_logins:
            if last_login.username == user.email:
                user.last_login = last_login.last_login

    have_ldap = True if len(get_emailusers('LDAP', 0, 1)) > 0 else False

    platform = get_platform_name()
    server_id = get_server_id()

    return render_to_response(
        'sysadmin/sys_useradmin.html', {
            'users': users,
            'current_page': current_page,
            'prev_page': current_page-1,
            'next_page': current_page+1,
            'per_page': per_page,
            'page_next': page_next,
            'CALC_SHARE_USAGE': CALC_SHARE_USAGE,
            'have_ldap': have_ldap,
            'platform': platform,
            'server_id': server_id[:8],
        },
        context_instance=RequestContext(request))
开发者ID:Neurones67,项目名称:seahub,代码行数:54,代码来源:sysadmin.py

示例9: sys_user_admin_admins

def sys_user_admin_admins(request):
    """List all admins from database.
    """
    users = get_emailusers('DB', -1, -1)

    admin_users = []
    not_admin_users = []
    for user in users:
        if user.is_staff is True:
            admin_users.append(user)
        else:
            not_admin_users.append(user)

    last_logins = UserLastLogin.objects.filter(username__in=[x.email for x in admin_users])

    for user in admin_users:
        if user.props.id == request.user.id:
            user.is_self = True
        try:
            user.self_usage = seafile_api.get_user_self_usage(user.email)
            user.share_usage = seafile_api.get_user_share_usage(user.email)
            user.quota = seafile_api.get_user_quota(user.email)
        except:
            user.self_usage = -1
            user.share_usage = -1
            user.quota = -1
        # check user's role
        if user.role == GUEST_USER:
            user.is_guest = True
        else:
            user.is_guest = False
        # populate user last login time
        user.last_login = None
        for last_login in last_logins:
            if last_login.username == user.email:
                user.last_login = last_login.last_login

    have_ldap = True if len(get_emailusers('LDAP', 0, 1)) > 0 else False

    return render_to_response(
        'sysadmin/sys_useradmin_admins.html', {
            'admin_users': admin_users,
            'not_admin_users': not_admin_users,
            'CALC_SHARE_USAGE': CALC_SHARE_USAGE,
            'have_ldap': have_ldap,
            'default_user': DEFAULT_USER,
            'guest_user': GUEST_USER,
            }, context_instance=RequestContext(request))
开发者ID:bits4beats,项目名称:seahub,代码行数:48,代码来源:sysadmin.py

示例10: get_quota_usage

def get_quota_usage(username):
    # https://github.com/haiwen/seahub/blob/master/seahub/api2/views.py#L310
    used = seafile_api.get_user_self_usage(username) + seafile_api.get_user_share_usage(username)
    total = seafile_api.get_user_quota(username)
    if used > 0:
        used = float(used)
    else:
        used = 0
    if total > 0:
        total = float(total)
    else:
        total = float(2)
    return used, total

# print get_quota_usage('[email protected]')
# print get_quota_usage('[email protected]')
开发者ID:goaxe,项目名称:lab,代码行数:16,代码来源:server_info.bak.py

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

示例12: user_search

def user_search(request):
    """Search a user.
    """
    email = request.GET.get('email', '')

    users = ccnet_threaded_rpc.search_emailusers(email, -1, -1)
    last_logins = UserLastLogin.objects.filter(username__in=[x.email for x in users])
    for user in users:
        org = ccnet_threaded_rpc.get_orgs_by_user(user.email)
        try:
            if not org:
                user.self_usage = seafile_api.get_user_self_usage(user.email)
                user.share_usage = seafile_api.get_user_share_usage(user.email)
                user.quota = seafile_api.get_user_quota(user.email)
            else:
                user.org = org[0]
                org_id = user.org.org_id
                user.self_usage = seafserv_threaded_rpc.get_org_user_quota_usage(org_id, user.email)
                user.share_usage = 0
                user.quota = seafserv_threaded_rpc.get_org_user_quota(org_id, user.email)
        except SearpcError as e:
            logger.error(e)
            user.self_usage = -1
            user.share_usage = -1
            user.quota = -1

        # check user's role
        if user.role == GUEST_USER:
            user.is_guest = True
        else:
            user.is_guest = False

        # populate user last login time
        user.last_login = None
        for last_login in last_logins:
            if last_login.username == user.email:
                user.last_login = last_login.last_login

    return render_to_response('sysadmin/user_search.html', {
            'users': users,
            'email': email,
            'default_user': DEFAULT_USER,
            'guest_user': GUEST_USER,
            'enable_guest': ENABLE_GUEST,
            }, context_instance=RequestContext(request))
开发者ID:3c7,项目名称:seahub,代码行数:45,代码来源:sysadmin.py

示例13: get

    def get(self, request, email, format=None):
        if not is_valid_username(email):
            return api_error(status.HTTP_404_NOT_FOUND, "User not found.")

        # query account info
        try:
            user = User.objects.get(email=email)
        except User.DoesNotExist:
            return api_error(status.HTTP_404_NOT_FOUND, "User not found.")

        info = {}
        info["email"] = user.email
        info["id"] = user.id
        info["is_staff"] = user.is_staff
        info["is_active"] = user.is_active
        info["create_time"] = user.ctime
        info["total"] = seafile_api.get_user_quota(email)
        info["usage"] = seafile_api.get_user_self_usage(email)

        return Response(info)
开发者ID:pombredanne,项目名称:seahub,代码行数:20,代码来源:account.py

示例14: get

    def get(self, request, email, format=None):
        if not is_valid_username(email):
            return api_error(status.HTTP_400_BAD_REQUEST, 'Email %s invalid.' % email)

        # query account info
        try:
            user = User.objects.get(email=email)
        except User.DoesNotExist:
            return api_error(status.HTTP_404_NOT_FOUND, 'User %s not found.' % email)

        info = {}
        info['email'] = user.email
        info['id'] = user.id
        info['is_staff'] = user.is_staff
        info['is_active'] = user.is_active
        info['create_time'] = user.ctime
        info['total'] = seafile_api.get_user_quota(email)
        info['usage'] = seafile_api.get_user_self_usage(email)

        return Response(info)
开发者ID:RaphaelWimmer,项目名称:seahub,代码行数:20,代码来源:account.py

示例15: get_account_info

def get_account_info(user):
    email = user.username
    d_profile = DetailedProfile.objects.get_detailed_profile_by_user(email)
    profile = Profile.objects.get_profile_by_user(email)

    info = {}
    info['email'] = email
    info['name'] = email2nickname(email)
    info['department'] = d_profile.department if d_profile else ''
    info['institution'] = profile.institution if profile else ''
    info['id'] = user.id
    info['is_staff'] = user.is_staff
    info['is_active'] = user.is_active
    info['create_time'] = user.ctime
    info['login_id'] = profile.login_id if profile else ''
    info['list_in_address_book'] = profile.list_in_address_book if profile else False
    info['total'] = seafile_api.get_user_quota(email)
    info['usage'] = seafile_api.get_user_self_usage(email)

    return info
开发者ID:haiwen,项目名称:seahub,代码行数:20,代码来源:account.py


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