parent
92ea4d527b
commit
1b93938a8e
4 changed files with 62 additions and 3 deletions
|
@ -39,8 +39,8 @@ def list_list() -> ResponseReturnValue:
|
|||
lists = MirrorList.query.filter(MirrorList.destroyed.is_(None)).all()
|
||||
return render_template("list.html.j2",
|
||||
section="list",
|
||||
title="Mirror Lists",
|
||||
item="mirror list",
|
||||
title="Distribution Lists",
|
||||
item="distribution list",
|
||||
new_link=url_for("portal.list.list_new"),
|
||||
items=lists,
|
||||
extra_buttons=[
|
||||
|
@ -127,3 +127,44 @@ class NewMirrorListForm(FlaskForm): # type: ignore
|
|||
description="(Optional) ARN for IAM role to assume for interaction with the S3 bucket.")
|
||||
filename = StringField('Filename', validators=[DataRequired()])
|
||||
submit = SubmitField('Save Changes')
|
||||
|
||||
@bp.route('/edit/<list_id>', methods=['GET', 'POST'])
|
||||
def list_edit(list_id: int) -> ResponseReturnValue:
|
||||
list_: Optional[MirrorList] = MirrorList.query.filter(MirrorList.id == list_id).first()
|
||||
if list is None:
|
||||
return Response(render_template("error.html.j2",
|
||||
section="list",
|
||||
header="404 Distribution List Not Found",
|
||||
message="The requested distribution list could not be found."),
|
||||
status=404)
|
||||
form = NewMirrorListForm(
|
||||
provider=list_.provider,
|
||||
format=list_.format,
|
||||
encoding=list_.encoding,
|
||||
description=list_.description,
|
||||
container=list_.container,
|
||||
branch=list_.branch,
|
||||
role=list_.role,
|
||||
filename=list_.filename
|
||||
)
|
||||
form.provider.choices = list(MirrorList.providers_supported.items())
|
||||
form.format.choices = list(MirrorList.formats_supported.items())
|
||||
form.encoding.choices = list(MirrorList.encodings_supported.items())
|
||||
if form.validate_on_submit():
|
||||
list_.provider = form.provider.data
|
||||
list_.format = form.format.data
|
||||
list_.encoding = form.encoding.data
|
||||
list_.description = form.description.data
|
||||
list_.container = form.container.data
|
||||
list_.branch = form.branch.data
|
||||
list_.role = form.role.data
|
||||
list_.filename = form.filename.data
|
||||
list_.updated = datetime.utcnow()
|
||||
try:
|
||||
db.session.commit()
|
||||
flash("Saved changes to group.", "success")
|
||||
except exc.SQLAlchemyError:
|
||||
flash("An error occurred saving the changes to the distribution list.", "danger")
|
||||
return render_template("distlist.html.j2",
|
||||
section="list",
|
||||
list=list_, form=form)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue