def user_info(request, email): """Show user info, libraries and groups. """ owned_repos = mute_seafile_api.get_owned_repo_list(email, ret_corrupted=True) owned_repos = filter(lambda r: not r.is_virtual, owned_repos) in_repos = mute_seafile_api.get_share_in_repo_list(email, -1, -1) space_usage = mute_seafile_api.get_user_self_usage(email) space_quota = mute_seafile_api.get_user_quota(email) # get user profile profile = Profile.objects.get_profile_by_user(email) d_profile = DetailedProfile.objects.get_detailed_profile_by_user(email) try: personal_groups = seaserv.get_personal_groups_by_user(email) except SearpcError as e: logger.error(e) personal_groups = [] for g in personal_groups: try: is_group_staff = seaserv.check_group_staff(g.id, email) except SearpcError as e: logger.error(e) is_group_staff = False if email == g.creator_name: g.role = _('Owner') elif is_group_staff: g.role = _('Admin') else: g.role = _('Member') available_quota = get_institution_available_quota(request.user.institution) return render_to_response('institutions/user_info.html', { 'owned_repos': owned_repos, 'space_quota': space_quota, 'space_usage': space_usage, 'in_repos': in_repos, 'email': email, 'profile': profile, 'd_profile': d_profile, 'personal_groups': personal_groups, 'available_quota': available_quota, }, context_instance=RequestContext(request))
def user_info(request, email): """Show user info, libraries and groups. """ owned_repos = mute_seafile_api.get_owned_repo_list(email, ret_corrupted=True) owned_repos = filter(lambda r: not r.is_virtual, owned_repos) in_repos = mute_seafile_api.get_share_in_repo_list(email, -1, -1) space_usage = mute_seafile_api.get_user_self_usage(email) space_quota = mute_seafile_api.get_user_quota(email) # get user profile profile = Profile.objects.get_profile_by_user(email) d_profile = DetailedProfile.objects.get_detailed_profile_by_user(email) try: personal_groups = seaserv.get_personal_groups_by_user(email) except SearpcError as e: logger.error(e) personal_groups = [] for g in personal_groups: try: is_group_staff = seaserv.check_group_staff(g.id, email) except SearpcError as e: logger.error(e) is_group_staff = False if email == g.creator_name: g.role = _('Owner') elif is_group_staff: g.role = _('Admin') else: g.role = _('Member') return render_to_response( 'institutions/user_info.html', { 'owned_repos': owned_repos, 'space_quota': space_quota, 'space_usage': space_usage, 'in_repos': in_repos, 'email': email, 'profile': profile, 'd_profile': d_profile, 'personal_groups': personal_groups, }, context_instance=RequestContext(request))
def user_info(request, email): owned_repos = mute_seafile_api.get_owned_repo_list(email) org_name = None space_quota = space_usage = 0 share_quota = share_usage = 0 org = ccnet_threaded_rpc.get_orgs_by_user(email) if not org: space_usage = mute_seafile_api.get_user_self_usage(email) space_quota = mute_seafile_api.get_user_quota(email) if CALC_SHARE_USAGE: share_usage = mute_seafile_api.get_user_share_usage(email) share_quota = mute_seafile_api.get_user_share_quota(email) 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) # Repos that are share to user in_repos = mute_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: try: 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) except SearpcError as e: logger.error(e) continue 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: try: 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) except SearpcError as e: logger.error(e) continue 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))