feat(portal/pool): adds rdr domain field to the pool table

This commit is contained in:
Owen 2023-01-18 10:25:34 +00:00 committed by irl
parent 96f81ecfb4
commit 574c348bc1
3 changed files with 39 additions and 1 deletions

View file

@ -18,11 +18,13 @@ bp = Blueprint("pool", __name__)
class NewPoolForm(FlaskForm): # type: ignore[misc]
group_name = StringField("Short Name", validators=[DataRequired()])
description = StringField("Description", validators=[DataRequired()])
redirector_domain = StringField("Redirector Domain")
submit = SubmitField('Save Changes', render_kw={"class": "btn btn-success"})
class EditPoolForm(FlaskForm): # type: ignore[misc]
description = StringField("Description", validators=[DataRequired()])
redirector_domain = StringField("Redirector Domain")
api_key = StringField("API Key", description=("Any change to this field (e.g. clearing it) will result in the "
"API key being regenerated."))
submit = SubmitField('Save Changes', render_kw={"class": "btn btn-success"})
@ -51,6 +53,7 @@ def pool_new() -> ResponseReturnValue:
pool = Pool()
pool.pool_name = form.group_name.data
pool.description = form.description.data
pool.redirector_domain = form.redirector_domain.data if form.redirector_domain.data != "" else None
pool.api_key = secrets.token_urlsafe(nbytes=32)
pool.created = datetime.utcnow()
pool.updated = datetime.utcnow()
@ -75,9 +78,11 @@ def pool_edit(pool_id: int) -> ResponseReturnValue:
message="The requested pool could not be found."),
status=404)
form = EditPoolForm(description=pool.description,
api_key=pool.api_key)
api_key=pool.api_key,
redirector_domain=pool.redirector_domain)
if form.validate_on_submit():
pool.description = form.description.data
pool.redirector_domain = form.redirector_domain.data if form.redirector_domain.data != "" else None
if form.api_key.data != pool.api_key:
pool.api_key = secrets.token_urlsafe(nbytes=32)
form.api_key.data = pool.api_key