feat(lists): adds redirector data format
This commit is contained in:
parent
c16a80dc16
commit
60255afe3f
8 changed files with 117 additions and 4 deletions
|
@ -1,3 +1,4 @@
|
|||
import secrets
|
||||
from datetime import datetime
|
||||
|
||||
from flask import render_template, url_for, flash, redirect, Response, Blueprint
|
||||
|
@ -22,6 +23,8 @@ class NewPoolForm(FlaskForm): # type: ignore[misc]
|
|||
|
||||
class EditPoolForm(FlaskForm): # type: ignore[misc]
|
||||
description = StringField("Description", validators=[DataRequired()])
|
||||
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"})
|
||||
|
||||
|
||||
|
@ -48,6 +51,7 @@ def pool_new() -> ResponseReturnValue:
|
|||
pool = Pool()
|
||||
pool.pool_name = form.group_name.data
|
||||
pool.description = form.description.data
|
||||
pool.api_key = secrets.token_urlsafe(nbytes=32)
|
||||
pool.created = datetime.utcnow()
|
||||
pool.updated = datetime.utcnow()
|
||||
try:
|
||||
|
@ -70,9 +74,13 @@ def pool_edit(pool_id: int) -> ResponseReturnValue:
|
|||
header="404 Pool Not Found",
|
||||
message="The requested pool could not be found."),
|
||||
status=404)
|
||||
form = EditPoolForm(description=pool.description)
|
||||
form = EditPoolForm(description=pool.description,
|
||||
api_key=pool.api_key)
|
||||
if form.validate_on_submit():
|
||||
pool.description = form.description.data
|
||||
if form.api_key.data != pool.api_key:
|
||||
pool.api_key = secrets.token_urlsafe(nbytes=32)
|
||||
form.api_key.data = pool.api_key
|
||||
pool.updated = datetime.utcnow()
|
||||
try:
|
||||
db.session.commit()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue