diff --git a/app/portal/list.py b/app/portal/list.py index f7041e7..0fa6093 100644 --- a/app/portal/list.py +++ b/app/portal/list.py @@ -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/', 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) diff --git a/app/portal/templates/distlist.html.j2 b/app/portal/templates/distlist.html.j2 new file mode 100644 index 0000000..fbe99c4 --- /dev/null +++ b/app/portal/templates/distlist.html.j2 @@ -0,0 +1,16 @@ +{% extends "base.html.j2" %} +{% from 'bootstrap5/form.html' import render_form %} +{% from "tables.html.j2" import proxies_table %} + +{% block content %} +

Distribution Lists

+

+ {{ list.url() }} + +

+ +
+ {{ render_form(form) }} +
+{% endblock %} diff --git a/app/portal/templates/list.html.j2 b/app/portal/templates/list.html.j2 index 06ad596..3b62dcd 100644 --- a/app/portal/templates/list.html.j2 +++ b/app/portal/templates/list.html.j2 @@ -23,7 +23,7 @@ {{ eotk_table(items) }} {% elif item == "group" %} {{ groups_table(items) }} - {% elif item == "mirror list" %} + {% elif item == "distribution list" %} {{ mirrorlists_table(items) }} {% elif item == "onion service" %} {% if section == "onion" %} diff --git a/app/portal/templates/tables.html.j2 b/app/portal/templates/tables.html.j2 index bff009c..761de4a 100644 --- a/app/portal/templates/tables.html.j2 +++ b/app/portal/templates/tables.html.j2 @@ -531,6 +531,8 @@ {{ list.url() }} {{ list.description }} + View/Edit Destroy