Exemple #1
0
def search_menu(files, name):
    for category in xconfig.MENU_LIST:
        if category.need_login and not xauth.has_login():
            continue
        if category.need_admin and not xauth.is_admin():
            continue
        for child in category.children:
            if text_contains(u(child.name), u(name)):
                files.append(Storage(name='菜单 - ' + child.name, url=child.url))
Exemple #2
0
def search_in_cache(words, user):
    def fmap(word):
        return word.upper()

    words = list(map(fmap, words))
    hits = []
    for item in get_cached_files():
        if item.name is None:
            continue
        if user != item.creator and user != 'admin' and item.is_public == 0:
            continue
        if text_contains(item.name_upper, words):
            item = file_wrapper(item)
            hits.append(item)
    return sorted(hits, key=lambda x: x.mtime, reverse=True)