From da236a83bad69744c911a73bf35541a96833425a Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Mon, 27 Apr 2020 17:13:11 -0700 Subject: [PATCH] Move lexicon create form to server.home --- amanuensis/server/forms.py | 12 ------------ amanuensis/server/home/__init__.py | 2 +- amanuensis/server/home/forms.py | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 amanuensis/server/home/forms.py diff --git a/amanuensis/server/forms.py b/amanuensis/server/forms.py index 544d317..a2805e8 100644 --- a/amanuensis/server/forms.py +++ b/amanuensis/server/forms.py @@ -40,18 +40,6 @@ def Lexicon(should_exist: bool = True): # Forms -class LexiconCreateForm(FlaskForm): - """/admin/create/""" - lexiconName = StringField( - 'Lexicon name', - validators=[DataRequired(), Lexicon(should_exist=False)]) - editorName = StringField( - 'Username of editor', - validators=[DataRequired(), User(should_exist=True)]) - promptText = TextAreaField('Prompt') - submit = SubmitField('Create') - - class LexiconConfigForm(FlaskForm): """/lexicon//session/settings/""" # General diff --git a/amanuensis/server/home/__init__.py b/amanuensis/server/home/__init__.py index 64fa4c1..e0912f5 100644 --- a/amanuensis/server/home/__init__.py +++ b/amanuensis/server/home/__init__.py @@ -4,10 +4,10 @@ from flask_login import login_required, current_user from amanuensis.config import RootConfigDirectoryContext from amanuensis.lexicon import create_lexicon, load_all_lexicons from amanuensis.models import UserModel -from amanuensis.server.forms import LexiconCreateForm from amanuensis.server.helpers import admin_required from amanuensis.user import load_all_users +from .forms import LexiconCreateForm bp_home = Blueprint('home', __name__, url_prefix='/home', diff --git a/amanuensis/server/home/forms.py b/amanuensis/server/home/forms.py new file mode 100644 index 0000000..b270281 --- /dev/null +++ b/amanuensis/server/home/forms.py @@ -0,0 +1,17 @@ +from flask_wtf import FlaskForm +from wtforms import StringField, SubmitField, TextAreaField +from wtforms.validators import DataRequired + +from amanuensis.server.forms import User, Lexicon + + +class LexiconCreateForm(FlaskForm): + """/admin/create/""" + lexiconName = StringField( + 'Lexicon name', + validators=[DataRequired(), Lexicon(should_exist=False)]) + editorName = StringField( + 'Username of editor', + validators=[DataRequired(), User(should_exist=True)]) + promptText = TextAreaField('Prompt') + submit = SubmitField('Create')