def get(p): # replace {{login}} p['navigation']['url'] = p['navigation']['url'].replace( '{{login}}', p['login']) # read the navigation information and redirect return tools.redirect(p['navigation']['url'])
def get(p): id = tools.get('id') # delete es.delete(p['host'], 'core_data', 'datasource', id) es.flush(p['host'], 'core_data') return tools.redirect(request.referrer)
def get(p): # get list of roles query = "site_id:{}".format(p['site']['id']) option = "size=10000&sort=name:asc" p['role_list'] = es.list(p['host'], 'core_nav', 'role', query, option) # selected role role_id = p['nav'][-1] p['role'] = es.get(p['host'], 'core_nav', 'role', role_id) if not p['role']: p['role'] = p['role_list'][0] # get permission permission_id = "{}_{}".format(p['role']['id'], p['navigation']['id']) p['permission'] = es.get(p['host'], 'core_nav', 'permission', permission_id) if request.method == "POST": doc = { "operations": [x for x in tools.get('operations', []) if x] } if not p['permission']: # create permission es.create(p['host'], 'core_nav', 'permission', permission_id, doc) else: # edit permission es.update(p['host'], 'core_nav', 'permission', permission_id, doc) es.flush(p['host'], 'core_nav') return tools.redirect(request.referrer) return render_template("post/permission/default.html", p=p)
def get(p): # load navigation navigation_id = p['nav'][-1] navigation = es.get(p['host'], 'core_nav', 'navigation', navigation_id) if not navigation: return tools.alert( 'not valid navigation id - {}'.format(navigation_id)) if not tools.get('site_id'): return tools.alert("site id missing") if not tools.get('module_id'): return tools.alert("module id missing") # edit role doc = { 'site_id': tools.get('site_id'), 'parent_id': tools.get('parent_id'), 'module_id': tools.get('module_id'), 'order_key': int(tools.get('order_key')), 'is_displayed': tools.get('is_displayed'), 'name': tools.get('name'), 'display_name': tools.get('display_name'), 'url': tools.get('url'), 'new_window': tools.get('new_window'), 'description': tools.get('description') } es.update(p['host'], 'core_nav', 'navigation', navigation_id, doc) es.flush(p['host'], 'core_nav') return tools.redirect(request.referrer)
def get(p): index = tools.get('index') id = tools.get('id') if not index or not id: return tools.alert('invalid id or index') # find config with matching index configs = es.list(p['host'], 'core_nav', 'config', "name:'index' AND value:'{}'".format(index)) if not len(configs) > 0: return tools.alert('site not found') # get site id navigation_id = configs[0]['id'].split('_')[0] navigation = es.get(p['host'], 'core_nav', 'navigation', navigation_id) site = es.get(p['host'], 'core_nav', 'site', navigation['site_id']) # form url url = '{}/{}'.format(site.get('name'), navigation.get('name')) url = "{}/post/view/{}".format(url, id) # when navigation or site is empty then it contains double slash url = url.replace("//", "/") url = urlparse.urljoin(request.url_root, url) return tools.redirect(url)
def post(p): # get login Process login_modules = get_login_modules(p) # try all login process until succeeds for login in login_modules: # find which auth module to use path = "web.modules.auth.services.{}".format( tools.get_conf(p['host'], '-1', 'auth', 'LDAP')) mod = importlib.import_module(path) if mod.authenticate(login['configuration'], tools.get('login'), tools.get('password')): # when authentication is successful # remember me if tools.get('remember'): # session will live for 31 days session.permanent = True else: session.permanent = False # save user_id in session session['user'] = tools.get('login') return tools.redirect(get_return_url()) # ending up here means login failed p['message'] = "Login Failed. Check your login name and password." return render_template("auth/default.html", p=p)
def get(p): host = p['c']['host'] index = p['c']['index'] # load comment post_id = p['nav'][-1] p['post'] = es.get(host, index, 'post', post_id) if not p['post']: return tools.alert('not valid post id - {}'.format(post_id)) # comment_id comment_id = tools.get("id") p['comment'] = next( (x for x in p['post']['comment'] if x['id'] == comment_id), {}) if not p['comment']: return tools.alert('not valid comment_id - {}'.format(comment_id)) # init workflow wf = tools.get('wf', 'comment_delete') p['workflow'] = workflow.init(wf, host, index) # remove comment p['post']['comment'].remove(p['comment']) es.update(host, index, 'post', post_id, p['post']) es.flush(host, index) return tools.redirect(request.referrer)
def get(p): host = p['c']['host'] index = p['c']['index'] # load notification notification_id = p['nav'][-1] p['notification'] = es.get(host, index, 'notification', notification_id) if not p['notification']: return tools.alert( 'not valid notification id - {}'.format(notification_id)) # save notification if request.method == "POST": doc = { 'header': tools.get('header'), 'message': tools.get('message'), 'recipients': tools.get('recipients'), 'condition': tools.get('condition'), 'workflow': tools.get('workflow') } es.update(host, index, 'notification', notification_id, doc) es.flush(host, index) return tools.redirect("{}/notification/edit/{}".format( p['url'], notification_id)) return render_template("post/notification/edit.html", p=p)
def get(p): host = p['c']['host']; index = p['c']['index']; # init workflow wf = tools.get("wf", 'comment_edit') p['workflow'] = workflow.init(wf, host, index) # load comment post_id = p['nav'][-1] p['post'] = es.get(host, index, 'post', post_id) if not p['post']: return tools.alert('not valid post id - {}'.format(post_id)) # comment_id comment_id = tools.get("id") p['comment'] = next((x for x in p['post']['comment'] if x['id'] == comment_id), None) if not p['comment']: return tools.alert('not valid comment_id - {}'.format(comment_id)) # field map fields = es.list(host, index, 'field') p['field_map'] = {} for field in fields: p['field_map'][field['name']] = field['id'] # update comment p['comment']['updated'] = es.now() p['comment']['updated_by'] = p['login'] p['comment']['comment'] = tools.get("comment") es.update(host, index, 'post', post_id, p['post']) es.flush(host, index) return tools.redirect(request.referrer)
def get(p): if request.method == "POST": # save configuration set_all_conf(p['host']) return tools.redirect(request.referrer) # get list authentication plugins p['login_modules'] = get_login_modules(p) return render_template("admin/login/default.html", p=p)
def get(p): if request.method == "POST": # save configuration set_all_conf(p['host']) return tools.redirect(request.referrer) # get configuration p['conf'] = get_all_conf(p['host']) return render_template("admin/config/default.html", p=p)
def get(p): es.create(p['host'], 'core_task', 'task', '', { 'navigation_id': p['navigation']['id'], 'name': tools.get('name'), 'runat': tools.get('runat', 'anywhere'), 'description': tools.get('description') }) es.flush(p['host'], 'core_task') return tools.redirect(request.referrer)
def get(p): # load schedule schedule_id = p['nav'][-1] schedule = es.get(p['host'], 'core_task', 'schedule', schedule_id) if not schedule: return tools.alert('schedule not found - {}'.format(schedule_id)) es.delete(p['host'], 'core_task', 'schedule', schedule_id) es.flush(p['host'], 'core_task') return tools.redirect(request.referrer)
def get(p): # load task task_id = p['nav'][-1] p['task'] = es.get(p['host'], 'core_task', 'task', task_id) if not p['task']: return tools.alert('task not found - {}'.format(task_id)) es.delete(p['host'], 'core_task', 'task', task_id) es.flush(p['host'], 'core_task') return tools.redirect(request.referrer)
def get(p): # Load Action action_id = p['nav'][-1] p['action'] = es.get(p['host'], 'core_task', 'action', action_id) if not p['action']: return tools.alert('not valid action id - {}'.format(action_id)) # delete es.delete(p['host'], 'core_task', 'action', p['action']['id']) es.flush(p['host'], 'core_task') return tools.redirect(request.referrer)
def get(p): # url shall exist if not tools.get('url'): return tools.alert("url is missing") # create new reverse proxy rule doc = { 'url': tools.get('url') } es.create(p['host'], 'core_proxy', 'public', '', doc) es.flush(p['host'], 'core_proxy') return tools.redirect(request.referrer)
def get(p): # load role role_id = p['nav'][-1] p['role'] = es.get(p['host'], 'core_nav', 'role', role_id) if not p['role']: return tools.alert('not valid role id - {}'.format(role_id)) # delete es.delete(p['host'], 'core_nav', 'role', role_id) es.flush(p['host'], 'core_nav') return tools.redirect(request.referrer)
def get(p): # Save Email Configuration if request.method == "POST": set_conf(p['host'], { 'gmail_id': tools.get('gmail_id'), 'gmail_pw': tools.get('gmail_pw') }) return tools.redirect(request.referrer) # Display Email Configuration p['conf'] = get_conf(p['host']) return render_template("admin/email/default.html", p=p)
def get(p): if request.method == "POST": # save login html tools.set_conf(p['host'], p['navigation']['id'], 'login_html', request.form['login_html']) # return tools.redirect(request.referrer) # get login html p['login_html'] = tools.get_conf(p['host'], p['navigation']['id'], 'login_html', '') return render_template("auth/admin.html", p=p)
def get(p): # load rule rev_proxy_id = p['nav'][-1] rev_proxy = es.get(p['host'], 'core_proxy', 'rev_proxy', rev_proxy_id) if not rev_proxy: return tools.alert('not valid rev_proxy id - {}'.format(rev_proxy_id)) # delete es.delete(p['host'], 'core_proxy', 'rev_proxy', rev_proxy_id) es.flush(p['host'], 'core_proxy') return tools.redirect(request.referrer)
def get(p): # create new login module doc = { "type": tools.get('type'), "name": tools.get('name'), "description": tools.get('description'), "priority": tools.get('priority'), "configuration": tools.get('configuration') } es.create(p['host'], 'core_nav', 'login_module', '', doc) es.flush(p['host'], 'core_nav') return tools.redirect(request.referrer)
def get(p): # load public url public_id = p['nav'][-1] public = es.get(p['host'], 'core_proxy', 'public', public_id) if not public: return tools.alert('not valid public url id - {}'.format(public_id)) # edit role doc = {'url': tools.get('url')} es.update(p['host'], 'core_proxy', 'public', public_id, doc) es.flush(p['host'], 'core_proxy') return tools.redirect(request.referrer)
def get(p={}): if request.method == "POST": # install elasticsearch essential index install(request.form['HOST'], request.form, app.config.get("BASE_DIR")) # return to the root page return tools.redirect("/") # display current configuration p["HOST"] = app.config.get("HOST") if app.config.get("HOST") else "http://localhost:9200" p["DEBUG"] = app.config.get("DEBUG") if app.config.get("DEBUG") else False p["KEYSTRING"] = app.config.get("KEYSTRING") if app.config.get("KEYSTRING") else "some random string for encryption" return render_template("install/install.html",p=p)
def get(p): # create new site site = { 'order_key': tools.get('order_key'), 'name': tools.get('name'), 'display_name': tools.get('display_name'), 'description': tools.get('description') } es.create(p['host'], 'core_nav', 'site', '', site) es.flush(p['host'], 'core_nav') return tools.redirect(request.referrer)
def get(p): # load login module login_module_id = p['nav'][-1] login_module = es.get(p['host'], 'core_nav', 'login_module', login_module_id) if not login_module: return tools.alert( 'not valid login module id - {}'.format(login_module_id)) # deletelogin module es.delete(p['host'], 'core_nav', 'login_module', login_module_id) es.flush(p['host'], 'core_nav') return tools.redirect(request.referrer)
def get(p): host = p['c']['host'] index = p['c']['index'] # load workflow workflow_id = p['nav'][-1] p['workflow'] = es.get(host, index, 'workflow', workflow_id) if not p['workflow']: return tools.alert('not valid workflow id - {}'.format(workflow_id)) # delete es.delete(host, index, 'workflow', workflow_id) es.flush(host, index) return tools.redirect(request.referrer)
def get(p): h = p['c']['host'] n = p['c']['index'] if request.method == "POST": config.set_conf(h, n, 'top', tools.get('top')) config.set_conf(h, n, 'footer', tools.get('footer')) config.set_conf(h, n, 'side', tools.get('side')) config.set_conf(h, n, 'content_header', tools.get('content_header')) config.set_conf(h, n, 'content_footer', tools.get('content_footer')) config.set_conf(h, n, 'intro', tools.get('intro')) return tools.redirect(request.referrer) return render_template("post/layout/default.html", p=p)
def get(p): host = p['c']['host'] index = p['c']['index'] # load notification notification_id = p['nav'][-1] p['notification'] = es.get(host, index, 'notification', notification_id) if not p['notification']: return tools.alert( 'not valid notification id - {}'.format(notification_id)) # delete notification es.delete(host, index, 'notification', notification_id) es.flush(host, index) return tools.redirect(request.referrer)
def get(p): site_id = p['nav'][-1] # root site can't be deleted if site_id == "0": return tools.alert("Root site can't be deleted") # check if site id is valid site = es.get(p['host'], 'core_nav', 'site', site_id) if not site: return tools.alert("not valid site id: {}".format(site_id)) es.delete(p['host'], 'core_nav', 'site', site_id) es.flush(p['host'], 'core_nav') return tools.redirect(request.referrer)
def get(p): # name shall exist if not tools.get('inc_url'): return tools.alert("incoming url is missing") if not tools.get('out_url'): return tools.alert("outgoing url is missing") # create new reverse proxy rule doc = { 'inc_url': tools.get('inc_url'), 'out_url': tools.get('out_url'), 'auth_method': tools.get('auth_method'), 'header': tools.get('header') } es.create(p['host'], 'core_proxy', 'rev_proxy', '', doc) es.flush(p['host'], 'core_proxy') return tools.redirect(request.referrer)