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)
|
||||
|
|
16
app/portal/templates/distlist.html.j2
Normal file
16
app/portal/templates/distlist.html.j2
Normal file
|
@ -0,0 +1,16 @@
|
|||
{% extends "base.html.j2" %}
|
||||
{% from 'bootstrap5/form.html' import render_form %}
|
||||
{% from "tables.html.j2" import proxies_table %}
|
||||
|
||||
{% block content %}
|
||||
<h1 class="h2 mt-3">Distribution Lists</h1>
|
||||
<h2 class="h3">
|
||||
{{ list.url() }}
|
||||
<a href="{{ list.url() }}" class="btn btn-secondary btn-sm" target="_bypass"
|
||||
rel="noopener noreferer">⎋</a>
|
||||
</h2>
|
||||
|
||||
<div style="border: 1px solid #666;" class="p-3">
|
||||
{{ render_form(form) }}
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -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" %}
|
||||
|
|
|
@ -531,6 +531,8 @@
|
|||
<td><a href="{{ list.url() }}">{{ list.url() }}</a></td>
|
||||
<td>{{ list.description }}</td>
|
||||
<td>
|
||||
<a href="{{ url_for("portal.list.list_edit", list_id=list.id) }}"
|
||||
class="btn btn-primary btn-sm">View/Edit</a>
|
||||
<a href="{{ url_for("portal.list.list_destroy", list_id=list.id) }}"
|
||||
class="btn btn-danger btn-sm">Destroy</a>
|
||||
</td>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue