Exemple #1
0
def admin_unmatched_files(user):
    if not user['uid'] in settings.ADMINS:
        abort(401)
    files = defaultdict(list)
    users = []
    for k in storage.all_keys():
        uid = k.split('/')[1]
        files[uid].append(k)
    for u in find_users():
        try:
            del files[u['uid']]
        except KeyError:
            pass
    return _jsonify(files)
Exemple #2
0
def admin_users(user):
    if not user['uid'] in settings.ADMINS:
        abort(401)
    args = request.args.copy()
    page = int(args.pop('page', 1))
    rpp = int(request.args.get('rpp', 100))
    skip = (page - 1) * rpp
    files = defaultdict(list)
    users = []
    query = {}
    if args.get('uname'):
        if args.get('unamesearch') == 'is':
            query.update({'uname': args['uname']})
        else:
            query.update({'uname': {'$regex': args['uname'], '$options': 'i'}})
    if args.get('uid'):
        query.update({'uid': args['uid']})
    migrated = args.get('migrated')
    if migrated == 'migrated':
        query.update({'migrated': 1})
    elif migrated == 'unmigrated':
        query.update({'migrated': 0})
    for k in storage.all_keys():
        uid = k.split('/')[1]
        files[uid].append(k)
    pages = 0
    if query:
        for u in find_users(query, skip, limit):
            u.update({'files': files[u['uid']]})
            users.append(u)
        pages = int(math.ceil(_user.find(query).count() / rpp))
    return render_template(
        'admin/users.html', **{
            'users': users,
            'page': page,
            'pages': pages,
            'args': args,
            'querystring': urllib.urlencode(args.items()),
            'storage_root': settings.AWS_STORAGE_BUCKET_URL
        })
Exemple #3
0
def admin_users(user):
    if not user['uid'] in settings.ADMINS:
        abort(401)
    args = request.args.copy()
    page = int(args.pop('page', 1))
    rpp = int(request.args.get('rpp', 100))
    skip = (page - 1) * rpp
    files = defaultdict(list)
    users = []
    query = {}
    if args.get('uname'):
        if args.get('unamesearch') == 'is':
            query.update({'uname': args['uname']})
        else:
            query.update({'uname__like': args['uname']})
    if args.get('uid'):
        query.update({'uid': args['uid']})
    migrated = args.get('migrated')
    if migrated == 'migrated':
        query.update({'migrated': 1})
    elif migrated == 'unmigrated':
        query.update({'migrated': 0})
    for k in storage.all_keys():
        uid = k.split('/')[1]
        files[uid].append(k)
    pages = 0
    if query:
        query.update({'limit': rpp, 'offset': page - 1})
        users, pages = find_users(**query)
    return render_template(
        'admin/users.html', **{
            'users': users,
            'page': page,
            'pages': pages,
            'args': args,
            'querystring': urlencode(list(args.items())),
            'storage_root': settings.AWS_STORAGE_BUCKET_URL
        })