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))
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))
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]) if ENABLE_TRIAL_ACCOUNT: trial_users = TrialAccount.objects.filter( user_or_org__in=[x.email for x in users]) else: trial_users = [] for user in users: if user.props.id == request.user.id: user.is_self = True _populate_user_quota_usage(user) # 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 user.trial_info = None for trial_user in trial_users: if trial_user.user_or_org == user.email: user.trial_info = {'expire_date': trial_user.expire_date} have_ldap = True if len(get_emailusers('LDAP', 0, 1)) > 0 else False platform = get_platform_name() server_id = get_server_id() pro_server = 1 if is_pro_version() else 0 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], 'default_user': DEFAULT_USER, 'guest_user': GUEST_USER, 'enable_guest': ENABLE_GUEST, 'pro_server': pro_server, }, context_instance=RequestContext(request))
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]) if enable_trial_account: trial_users = TrialAccount.objects.filter(user_or_org__in=[x.email for x in users]) else: trial_users = [] for user in users: if user.props.id == request.user.id: user.is_self = True _populate_user_quota_usage(user) # 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 user.trial_info = None for trial_user in trial_users: if trial_user.user_or_org == user.email: user.trial_info = {'expire_date': trial_user.expire_date} have_ldap = True if len(get_emailusers('LDAP', 0, 1)) > 0 else False platform = get_platform_name() server_id = get_server_id() pro_server = 1 if is_pro_version() else 0 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], 'default_user': DEFAULT_USER, 'guest_user': GUEST_USER, 'enable_guest': ENABLE_GUEST, 'pro_server': pro_server, }, context_instance=RequestContext(request))