def channel_list(): if request.method == "POST": action = request.form.get('@action', '') if action == "new": name = request.form.get('name') module = request.form.get('module') if module in get_modules_names( current_app.config["PLUGINS"].keys()): channel = Channel(name = name, module = get_module_full_name(module), config = "{}") db.session.add(channel) db.session.commit() elif action == "delete": channel_id = request.form.get("id") channel = Channel.query.get(channel_id) if channel: db.session.delete(channel) db.session.commit() elif action == "edit": channel_id = request.form.get("id") channel = Channel.query.get(channel_id) name = request.form.get('name') channel.name = name db.session.commit() channels = Channel.query.all() return render_template("channels.html", channels = channels, modules = get_modules_names( current_app.config["PLUGINS"].keys()))
def get_post_form_validations(): mods = get_modules_names(current_app.config["PLUGINS"].keys()) post_form_validations = dict() for m in mods: fields = {} post_form_validations[m] = fields return post_form_validations
def get_post_form_validations(): mods = get_modules_names(current_app.config["PLUGINS"].keys()) post_form_validations = dict() for m in mods: full_name = get_module_full_name(m) clas = get_instance_from_module_path(full_name) fields = clas.POST_FORM_VALIDATIONS post_form_validations[m] = fields return post_form_validations
def channel_list(): if request.method == "POST": action = request.form.get('@action', '') if action == "new": name = request.form.get('name') module = request.form.get('module') if module in get_modules_names( current_app.config["PLUGINS"].keys()): channel = Channel(name=name, module=get_module_full_name(module), config="{}", archival_frequency=DEFAULT_FREQUENCY, archival_date=DEFAULT_DATE) db.session.add(channel) db.session.commit() # Archival Module : configure_job(channel.id, DEFAULT_FREQUENCY, DEFAULT_DATE) # End of Archival Module elif action == "delete": channel_id = request.form.get("id") channel = Channel.query.get(channel_id) if channel: db.session.delete(channel) db.session.commit() # Archival Module : delete_job(channel_id) # End of Archival Module elif action == "edit": channel_id = request.form.get("id") channel = Channel.query.get(channel_id) name = request.form.get('name') channel.name = name db.session.commit() channels = Channel.query.all() return render_template("channels.html", channels=channels, modules=get_modules_names( current_app.config["PLUGINS"].keys()))
def channel_list(): if request.method == "POST": action = request.form.get('@action', '') if action == "new": name = request.form.get('name') username = request.form.get('username') password = request.form.get('password') module = request.form.get('module') if module in get_modules_names(current_app.config["PLUGINS"].keys()): channel = Channel(name=name, module=get_module_full_name(module), config="{}") db.session.add(channel) db.session.flush() db.session.commit() elif action == "delete": channel_id = request.form.get("id") channel = Channel.query.get(channel_id) if channel: db.session.delete(channel) db.session.commit() elif action == "edit": channel_id = request.form.get("id") channel = Channel.query.get(channel_id) name = request.form.get('name') username = request.form.get('username') password = request.form.get('password') if name is not '': channel.name = name conf = json.loads(channel.config) conf["channel_name"] = name channel.config = json.dumps(conf) db.session.commit() channels = Channel.query.all() mods = get_modules_names(current_app.config["PLUGINS"].keys()) auth_fields = dict() return render_template("channels.html", channels=channels, modules=get_modules_names(current_app.config["PLUGINS"].keys()), auth_fields=auth_fields)
def channel_list(): if request.method == "POST": action = request.form.get('@action', '') if action == "new": name = request.form.get('name') username = request.form.get('username') password = request.form.get('password') module = request.form.get('module') if module in get_modules_names( current_app.config["PLUGINS"].keys()): channel = Channel(name=name, module=get_module_full_name(module), config="{}") db.session.add(channel) db.session.flush() keepass.set_entry_from_data(str(channel.id), username, password) keepass.add_entry_in_group(module) db.session.commit() elif action == "delete": channel_id = request.form.get("id") channel = Channel.query.get(channel_id) if channel: db.session.delete(channel) db.session.commit() keepass.delete_entry(channel_id) elif action == "edit": channel_id = request.form.get("id") channel = Channel.query.get(channel_id) name = request.form.get('name') username = request.form.get('username') password = request.form.get('password') if name is not '': channel.name = name conf = json.loads(channel.config) conf["channel_name"] = name channel.config = json.dumps(conf) db.session.commit() if username is not '' or password is not '': keepass.set_entry_from_data(str(channel.id), username, password) keepass.modify_entry_in_group( get_modules_names([channel.module])[0], channel.id) channels = Channel.query.all() mods = get_modules_names(current_app.config["PLUGINS"].keys()) auth_fields = dict() for m in mods: full_name = get_module_full_name(m) clas = get_instance_from_module_path(full_name) fields = clas.AUTH_FIELDS auth_fields[m] = fields return render_template("channels.html", channels=channels, modules=get_modules_names( current_app.config["PLUGINS"].keys()), auth_fields=auth_fields)