feat(portal/pool): adds rdr domain field to the pool table
This commit is contained in:
parent
96f81ecfb4
commit
574c348bc1
3 changed files with 39 additions and 1 deletions
|
@ -26,6 +26,7 @@ class Group(AbstractConfiguration):
|
||||||
class Pool(AbstractConfiguration):
|
class Pool(AbstractConfiguration):
|
||||||
pool_name = db.Column(db.String(80), unique=True, nullable=False)
|
pool_name = db.Column(db.String(80), unique=True, nullable=False)
|
||||||
api_key = db.Column(db.String(80), nullable=False)
|
api_key = db.Column(db.String(80), nullable=False)
|
||||||
|
redirector_domain = db.Column(db.String(128), nullable=True)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def csv_header(cls) -> List[str]:
|
def csv_header(cls) -> List[str]:
|
||||||
|
|
|
@ -18,11 +18,13 @@ bp = Blueprint("pool", __name__)
|
||||||
class NewPoolForm(FlaskForm): # type: ignore[misc]
|
class NewPoolForm(FlaskForm): # type: ignore[misc]
|
||||||
group_name = StringField("Short Name", validators=[DataRequired()])
|
group_name = StringField("Short Name", validators=[DataRequired()])
|
||||||
description = StringField("Description", validators=[DataRequired()])
|
description = StringField("Description", validators=[DataRequired()])
|
||||||
|
redirector_domain = StringField("Redirector Domain")
|
||||||
submit = SubmitField('Save Changes', render_kw={"class": "btn btn-success"})
|
submit = SubmitField('Save Changes', render_kw={"class": "btn btn-success"})
|
||||||
|
|
||||||
|
|
||||||
class EditPoolForm(FlaskForm): # type: ignore[misc]
|
class EditPoolForm(FlaskForm): # type: ignore[misc]
|
||||||
description = StringField("Description", validators=[DataRequired()])
|
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 = StringField("API Key", description=("Any change to this field (e.g. clearing it) will result in the "
|
||||||
"API key being regenerated."))
|
"API key being regenerated."))
|
||||||
submit = SubmitField('Save Changes', render_kw={"class": "btn btn-success"})
|
submit = SubmitField('Save Changes', render_kw={"class": "btn btn-success"})
|
||||||
|
@ -51,6 +53,7 @@ def pool_new() -> ResponseReturnValue:
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
pool.pool_name = form.group_name.data
|
pool.pool_name = form.group_name.data
|
||||||
pool.description = form.description.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.api_key = secrets.token_urlsafe(nbytes=32)
|
||||||
pool.created = datetime.utcnow()
|
pool.created = datetime.utcnow()
|
||||||
pool.updated = 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."),
|
message="The requested pool could not be found."),
|
||||||
status=404)
|
status=404)
|
||||||
form = EditPoolForm(description=pool.description,
|
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():
|
if form.validate_on_submit():
|
||||||
pool.description = form.description.data
|
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:
|
if form.api_key.data != pool.api_key:
|
||||||
pool.api_key = secrets.token_urlsafe(nbytes=32)
|
pool.api_key = secrets.token_urlsafe(nbytes=32)
|
||||||
form.api_key.data = pool.api_key
|
form.api_key.data = pool.api_key
|
||||||
|
|
32
migrations/versions/09b5f4bd75b8_adding_redirector_domain.py
Normal file
32
migrations/versions/09b5f4bd75b8_adding_redirector_domain.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
"""Adding redirector domain
|
||||||
|
|
||||||
|
Revision ID: 09b5f4bd75b8
|
||||||
|
Revises: a08ce5e7246a
|
||||||
|
Create Date: 2023-01-17 10:48:59.742946
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '09b5f4bd75b8'
|
||||||
|
down_revision = 'a08ce5e7246a'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('pool', schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column('redirector_domain', sa.String(length=128), nullable=True))
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('pool', schema=None) as batch_op:
|
||||||
|
batch_op.drop_column('redirector_domain')
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
Loading…
Add table
Add a link
Reference in a new issue