From fce6e7145b40a6130a2d1bdb3a670f568256f374 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Mon, 27 Jan 2020 18:11:20 -0800 Subject: [PATCH] Connect create form to internal call --- amanuensis/server/home.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/amanuensis/server/home.py b/amanuensis/server/home.py index edadf12..b904252 100644 --- a/amanuensis/server/home.py +++ b/amanuensis/server/home.py @@ -1,8 +1,9 @@ -from flask import Blueprint, render_template +from flask import Blueprint, render_template, redirect, url_for from flask_login import login_required -from amanuensis.config import json_ro +from amanuensis.config import json_ro, json_rw from amanuensis.lexicon import LexiconModel +from amanuensis.lexicon.manage import create_lexicon from amanuensis.server.forms import LexiconCreateForm from amanuensis.server.helpers import admin_required from amanuensis.user import UserModel @@ -42,7 +43,11 @@ def get_bp(): lexicon_name = form.lexiconName.data editor_name = form.editorName.data prompt = form.promptText.data - return "
".join([lexicon_name, editor_name, prompt]) + editor = UserModel.by(name=editor_name) + lexicon = create_lexicon(lexicon_name, editor) + with json_rw(lexicon.config_path) as cfg: + cfg.prompt = prompt + return redirect(url_for('lexicon.session', name=lexicon_name)) return render_template('home/create.html', form=form)