'Allow/deny `username` to edit this wiki `page`'

@require_oauth2_scope('modwiki')
@validate(VModhash(), VWikiModerator(), page=VWikiPage('page'), act=VOneOf('act', ('del', 'add')), user=VExistingUname('username'))
@api_doc(api_section.wiki, uri='/api/wiki/alloweditor/{act}', uses_site=True, uri_variants=[('/api/wiki/alloweditor/%s' % act) for act in ('del', 'add')])
def POST_wiki_allow_editor(self, act, page, user):

    if (not user):
        self.handle_error(404, 'UNKNOWN_USER')
    elif (act == 'del'):
        VNotInTimeout().run(action_name='wikipermlevel', details_text='del_editor', target=user)
        page.remove_editor(user._id36)
    elif (act == 'add'):
        VNotInTimeout().run(action_name='wikipermlevel', details_text='allow_editor', target=user)
        page.add_editor(user._id36)
    else:
        self.handle_error(400, 'INVALID_ACTION')
    return json.dumps({})
