コード例 #1
0
ファイル: logic.py プロジェクト: youmuyou/CuteOne
def get_data(disk_id,
             path='',
             search='',
             sortTable='lastModifiedDateTime',
             sortType='more',
             page=1):
    search_type = systemModels.config.get_config('search_type')
    drivename = "drive_" + str(disk_id)
    collection = MongoDB.db[drivename]
    data = []
    if sortType == "more":
        sortType = pymongo.DESCENDING
    else:
        sortType = pymongo.ASCENDING
    if search is None:
        result = collection.find({"path": path}).sort([(sortTable, sortType)])
        for x in result:
            x["lastModifiedDateTime"] = str(x["lastModifiedDateTime"])
            x["createdDateTime"] = str(x["createdDateTime"])
            x["size"] = common.size_cov(x["size"])
            if x["file"] == "folder":
                data.insert(0, x)
            else:
                x["downloadUrl"] = x["downloadUrl"]
                data.append(x)
    else:
        result = collection.find({
            "name": re.compile(search)
        }).sort([(sortTable, sortType)])
        for x in result:
            if search_type == "1":
                x["lastModifiedDateTime"] = str(x["lastModifiedDateTime"])
                x["createdDateTime"] = str(x["createdDateTime"])
                x["size"] = common.size_cov(x["size"])
                if x["file"] == "folder":
                    data.insert(0, x)
                else:
                    x["downloadUrl"] = x["downloadUrl"]
                    data.append(x)
            else:
                dirve_id = driveModels.drive_list.find_by_drive_id(
                    disk_id)[0].id
                authorres = authorModels.authrule.find_by_drive_id_all(
                    dirve_id)
                authorpath = []  # 搜索不可见的集和,加密皆不可见
                for i in authorres:
                    authorpath.append(i.path)
                if x["path"] not in authorpath:
                    x["lastModifiedDateTime"] = str(x["lastModifiedDateTime"])
                    x["createdDateTime"] = str(x["createdDateTime"])
                    x["size"] = common.size_cov(x["size"])
                    if x["file"] == "folder":
                        data.insert(0, x)
                    else:
                        x["downloadUrl"] = x["downloadUrl"]
                        data.append(x)
    data = Pagination_data(data, page)
    return data
コード例 #2
0
ファイル: views.py プロジェクト: zqm840527/CuteOne
def files(id):
    drive_info = models.drive_list.find_by_id(id)
    drive_id = drive_info.drive_id
    chief = int(drive_info.chief)
    uploads_path = request.args.get('path')
    if request.args.get('path'):
        path = request.args.get("path")
        current_url = '/admin/drive/files/' + str(id) + '/?path=' + path
    else:
        path = ''
        current_url = '/admin/drive/files/' + str(id) + '/?path='
    data = logic.get_one_file_list(id, path)
    for i in data["data"]:
        i["lastModifiedDateTime"] = common.utc_to_local(
            i["lastModifiedDateTime"])
        i["size"] = common.size_cov(i["size"])
    data = data["data"]
    return render_template('admin/drive/files.html',
                           top_nav='drive',
                           activity_nav='edit',
                           chief=chief,
                           id=id,
                           current_url=current_url,
                           drive_id=drive_id,
                           uploads_path=uploads_path,
                           data=data)
コード例 #3
0
def files_disk_files(id):
    uploads_path = request.args.get('path')
    if request.args.get('path'):
        path = request.args.get("path")
        current_url = '/admin/files/files_disk_files/' + str(id) + '/?path=' + path
    else:
        path = ''
        current_url = '/admin/files/files_disk_files/' + str(id) + '/?path='
    data = logic.get_one_file_list(id, path)
    for i in data["data"]["value"]:
        i["lastModifiedDateTime"] = common.utc_to_local(i["lastModifiedDateTime"])
        i["size"] = common.size_cov(i["size"])
    data = data["data"]["value"]
    return render_template('admin/files/files_disk_files.html', top_nav='files', activity_nav='edit', id=id, current_url=current_url, data=data)
コード例 #4
0
def get_data(disk_id,
             path='',
             search='',
             sortTable='lastModifiedDateTime',
             sortType='more',
             page=1):
    drive_id = driveModels.drive_list.find_by_id(disk_id).id
    authorres = authorModels.authrule.find_by_drive_id_all(drive_id)
    authorpath = []  # 权限路径信息数组
    for i in authorres:
        authorpath.append({"path": i.path, "login_hide": i.login_hide})
    search_type = systemModels.config.get_config('search_type')
    drivename = "drive_" + str(disk_id)
    collection = MongoDB.db[drivename]
    data = []
    if sortType == "more":
        sortType = pymongo.DESCENDING
    else:
        sortType = pymongo.ASCENDING
    if search is None:
        result = collection.find({"path": path}).sort([(sortTable, sortType)])
        for x in result:
            x["lastModifiedDateTime"] = str(x["lastModifiedDateTime"])
            x["createdDateTime"] = str(x["createdDateTime"])
            x["size"] = common.size_cov(x["size"])
            if x["file"] == "folder":
                author_if_res = True
                if current_user.get_id() is not None:
                    for a in authorpath:
                        if x["path"] == "" and x["name"] == a["path"].strip(
                                "/"
                        ) and a["login_hide"] == 1 and a["login_hide"] == 2:
                            author_if_res = False
                            exit()
                        elif x["path"] == a["path"] and a[
                                "login_hide"] == 1 and a["login_hide"] == 2:
                            author_if_res = False
                else:
                    for a in authorpath:
                        if x["path"] == "" and x["name"] == a["path"].strip(
                                "/") and a["login_hide"] == 2:
                            author_if_res = False
                        elif x["path"] == a["path"] and a["login_hide"] == 1:
                            author_if_res = False
                if author_if_res:
                    data.insert(0, x)
            else:
                x["downloadUrl"] = x["downloadUrl"]
                data.append(x)
    else:
        result = collection.find({
            "name": re.compile(search)
        }).sort([(sortTable, sortType)])
        for x in result:
            if search_type == "1":
                x["lastModifiedDateTime"] = str(x["lastModifiedDateTime"])
                x["createdDateTime"] = str(x["createdDateTime"])
                x["size"] = common.size_cov(x["size"])
                if x["file"] == "folder":
                    author_if_res = True
                    if current_user.get_id() is not None:
                        for a in authorpath:
                            if x["name"] == a["path"].strip(
                                    "/") and a["login_hide"] == 1 and a[
                                        "login_hide"] == 2:
                                author_if_res = False
                    else:
                        for a in authorpath:
                            if x["name"] == a["path"].strip(
                                    "/") and a["login_hide"] == 2:
                                author_if_res = False
                    if author_if_res:
                        data.insert(0, x)
                else:
                    x["downloadUrl"] = x["downloadUrl"]
                    data.append(x)
            else:
                x["lastModifiedDateTime"] = str(x["lastModifiedDateTime"])
                x["createdDateTime"] = str(x["createdDateTime"])
                x["size"] = common.size_cov(x["size"])
                if x["file"] == "folder":
                    author_if_res = True
                    if current_user.get_id() is not None:
                        for a in authorpath:
                            if x["path"] == "" and x["name"] == a["path"].strip(
                                    "/") and a["login_hide"] == 1 and a[
                                        "login_hide"] == 2:
                                author_if_res = False
                                exit()
                            elif x["path"] == a["path"] and a[
                                    "login_hide"] == 1 and a["login_hide"] == 2:
                                author_if_res = False
                    else:
                        for a in authorpath:
                            if x["path"] == "" and x["name"] == a["path"].strip(
                                    "/") and a["login_hide"] == 2:
                                author_if_res = False
                            elif x["path"] == a["path"] and a[
                                    "login_hide"] == 1:
                                author_if_res = False
                    if author_if_res:
                        data.insert(0, x)
                else:
                    x["downloadUrl"] = x["downloadUrl"]
                    data.append(x)
    data = Pagination_data(data, page)
    return data