Move lexicon create form to server.home

This commit is contained in:
Tim Van Baak 2020-04-27 17:13:11 -07:00
parent b6d7a4a54e
commit da236a83ba
3 changed files with 18 additions and 13 deletions

View File

@ -40,18 +40,6 @@ def Lexicon(should_exist: bool = True):
# Forms # 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): class LexiconConfigForm(FlaskForm):
"""/lexicon/<name>/session/settings/""" """/lexicon/<name>/session/settings/"""
# General # General

View File

@ -4,10 +4,10 @@ from flask_login import login_required, current_user
from amanuensis.config import RootConfigDirectoryContext from amanuensis.config import RootConfigDirectoryContext
from amanuensis.lexicon import create_lexicon, load_all_lexicons from amanuensis.lexicon import create_lexicon, load_all_lexicons
from amanuensis.models import UserModel from amanuensis.models import UserModel
from amanuensis.server.forms import LexiconCreateForm
from amanuensis.server.helpers import admin_required from amanuensis.server.helpers import admin_required
from amanuensis.user import load_all_users from amanuensis.user import load_all_users
from .forms import LexiconCreateForm
bp_home = Blueprint('home', __name__, bp_home = Blueprint('home', __name__,
url_prefix='/home', url_prefix='/home',

View File

@ -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')