# Path: wikked/web.py
# def get_wiki():
# def uncaching_wiki_updater(wiki, url):
# def user_loader(username):
# def get_read_url(url):
# def get_edit_url(url):
# def get_rev_url(url, rev):
# def get_diff_url(url, rev1=None, rev2=None):
#     def async_updater(wiki):
#     def on_request_started(sender, **extra):
#     def on_request_tearing_down(sender, **extra):
# 
# Path: wikked/webimpl/decorators.py
# def requires_permission(perm):
#     if isinstance(perm, str):
#         perm = [perm]
# 
#     p_bit = 0
#     for p in perm:
#         p_bit |= PERM_NAMES[p]
# 
#     def decorator(f):
#         @functools.wraps(f)
#         def wrapper(*args, **kwargs):
#             wiki = get_wiki()
#             if not wiki.auth.hasPermission(current_user.get_id(), p_bit):
#                 raise UserPermissionError(
#                     perm, "You don't have permission for this.")
#             return f(*args, **kwargs)
#         return wrapper
#     return decorator


from flask import jsonify
from wikked.web import app, get_wiki
from wikked.webimpl.decorators import requires_permission


@app.route('/api/admin/reindex', methods=['POST'])
@requires_permission('index')
def api_admin_reindex():
    wiki = get_wiki()
    wiki.index.reset(wiki.getPages())
    result = {'ok': 1}

# Path: wikked/web.py
# def get_wiki():
# def uncaching_wiki_updater(wiki, url):
# def user_loader(username):
# def get_read_url(url):
# def get_edit_url(url):
# def get_rev_url(url, rev):
# def get_diff_url(url, rev1=None, rev2=None):
#     def async_updater(wiki):
#     def on_request_started(sender, **extra):
#     def on_request_tearing_down(sender, **extra):
# 
# Path: wikked/webimpl/decorators.py
# def requires_permission(perm):
#     if isinstance(perm, str):
#         perm = [perm]
# 
#     p_bit = 0
#     for p in perm:
#         p_bit |= PERM_NAMES[p]
# 
#     def decorator(f):
#         @functools.wraps(f)
#         def wrapper(*args, **kwargs):
#             wiki = get_wiki()
#             if not wiki.auth.hasPermission(current_user.get_id(), p_bit):
#                 raise UserPermissionError(
#                     perm, "You don't have permission for this.")
#             return f(*args, **kwargs)
#         return wrapper
#     return decorator


# Path: wikked/api/admin.py
from flask import jsonify
from wikked.web import app, get_wiki
from wikked.webimpl.decorators import requires_permission



@app.route('/api/admin/reindex', methods=['POST'])
@requires_permission('index')
def api_admin_reindex():
    wiki = get_wiki()
    wiki.index.reset(wiki.getPages())
    result = {'ok': 1}

    return jsonify(result)