portal: link to context-specific help where we can
This commit is contained in:
parent
2801eefd43
commit
5b9946c431
6 changed files with 76 additions and 31 deletions
|
@ -19,6 +19,12 @@ from app.portal.util import response_404, view_lifecycle
|
|||
bp = Blueprint("list", __name__)
|
||||
|
||||
|
||||
_SECTION_TEMPLATE_VARS = {
|
||||
"section": "list",
|
||||
"help_url": "https://bypass.censorship.guide/user/lists.html"
|
||||
}
|
||||
|
||||
|
||||
@bp.app_template_filter("provider_name")
|
||||
def list_provider_name(key: str) -> str:
|
||||
return MirrorList.providers_supported.get(key, "Unknown")
|
||||
|
@ -38,7 +44,6 @@ def list_encoding_name(key: str) -> str:
|
|||
def list_list() -> ResponseReturnValue:
|
||||
lists = MirrorList.query.filter(MirrorList.destroyed.is_(None)).all()
|
||||
return render_template("list.html.j2",
|
||||
section="list",
|
||||
title="Distribution Lists",
|
||||
item="distribution list",
|
||||
new_link=url_for("portal.list.list_new"),
|
||||
|
@ -50,7 +55,8 @@ def list_list() -> ResponseReturnValue:
|
|||
"style": "secondary"
|
||||
}
|
||||
for k, v in MirrorList.formats_supported.items()
|
||||
]
|
||||
],
|
||||
**_SECTION_TEMPLATE_VARS
|
||||
)
|
||||
|
||||
|
||||
|
@ -110,7 +116,9 @@ def list_new(group_id: Optional[int] = None) -> ResponseReturnValue:
|
|||
return redirect(url_for("portal.list.list_list"))
|
||||
if group_id:
|
||||
form.group.data = group_id
|
||||
return render_template("new.html.j2", section="list", form=form)
|
||||
return render_template("new.html.j2",
|
||||
form=form,
|
||||
**_SECTION_TEMPLATE_VARS)
|
||||
|
||||
|
||||
class NewMirrorListForm(FlaskForm): # type: ignore
|
||||
|
@ -134,9 +142,9 @@ 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."),
|
||||
message="The requested distribution list could not be found.",
|
||||
**_SECTION_TEMPLATE_VARS),
|
||||
status=404)
|
||||
form = NewMirrorListForm(
|
||||
provider=list_.provider,
|
||||
|
@ -167,5 +175,5 @@ def list_edit(list_id: int) -> ResponseReturnValue:
|
|||
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)
|
||||
list=list_, form=form,
|
||||
**_SECTION_TEMPLATE_VARS)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue