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
|
@ -16,6 +16,12 @@ from app.portal.util import response_404, view_lifecycle
|
|||
bp = Blueprint("bridgeconf", __name__)
|
||||
|
||||
|
||||
_SECTION_TEMPLATE_VARS = {
|
||||
"section": "bridgeconf",
|
||||
"help_url": "https://bypass.censorship.guide/user/bridges.html"
|
||||
}
|
||||
|
||||
|
||||
class NewBridgeConfForm(FlaskForm): # type: ignore
|
||||
provider = SelectField('Provider', validators=[DataRequired()])
|
||||
method = SelectField('Distribution Method', validators=[DataRequired()])
|
||||
|
@ -35,11 +41,11 @@ class EditBridgeConfForm(FlaskForm): # type: ignore
|
|||
def bridgeconf_list() -> ResponseReturnValue:
|
||||
bridgeconfs: List[BridgeConf] = BridgeConf.query.filter(BridgeConf.destroyed.is_(None)).all()
|
||||
return render_template("list.html.j2",
|
||||
section="bridgeconf",
|
||||
title="Tor Bridge Configurations",
|
||||
item="bridge configuration",
|
||||
items=bridgeconfs,
|
||||
new_link=url_for("portal.bridgeconf.bridgeconf_new"))
|
||||
new_link=url_for("portal.bridgeconf.bridgeconf_new"),
|
||||
**_SECTION_TEMPLATE_VARS)
|
||||
|
||||
|
||||
@bp.route("/new", methods=['GET', 'POST'])
|
||||
|
@ -79,7 +85,9 @@ def bridgeconf_new(group_id: Optional[int] = None) -> ResponseReturnValue:
|
|||
return redirect(url_for("portal.bridgeconf.bridgeconf_list"))
|
||||
if group_id:
|
||||
form.group.data = group_id
|
||||
return render_template("new.html.j2", section="bridgeconf", form=form)
|
||||
return render_template("new.html.j2",
|
||||
form=form,
|
||||
**_SECTION_TEMPLATE_VARS)
|
||||
|
||||
|
||||
@bp.route('/edit/<bridgeconf_id>', methods=['GET', 'POST'])
|
||||
|
@ -87,9 +95,9 @@ def bridgeconf_edit(bridgeconf_id: int) -> ResponseReturnValue:
|
|||
bridgeconf = BridgeConf.query.filter(BridgeConf.id == bridgeconf_id).first()
|
||||
if bridgeconf is None:
|
||||
return Response(render_template("error.html.j2",
|
||||
section="bridge",
|
||||
header="404 Bridge Configuration Not Found",
|
||||
message="The requested bridge configuration could not be found."),
|
||||
message="The requested bridge configuration could not be found.",
|
||||
**_SECTION_TEMPLATE_VARS),
|
||||
status=404)
|
||||
form = EditBridgeConfForm(description=bridgeconf.description,
|
||||
number=bridgeconf.number)
|
||||
|
@ -103,8 +111,9 @@ def bridgeconf_edit(bridgeconf_id: int) -> ResponseReturnValue:
|
|||
except exc.SQLAlchemyError:
|
||||
flash("An error occurred saving the changes to the bridge configuration.", "danger")
|
||||
return render_template("bridgeconf.html.j2",
|
||||
section="bridgeconf",
|
||||
bridgeconf=bridgeconf, form=form)
|
||||
bridgeconf=bridgeconf,
|
||||
form=form,
|
||||
**_SECTION_TEMPLATE_VARS)
|
||||
|
||||
|
||||
@bp.route("/destroy/<bridgeconf_id>", methods=['GET', 'POST'])
|
||||
|
@ -117,7 +126,7 @@ def bridgeconf_destroy(bridgeconf_id: int) -> ResponseReturnValue:
|
|||
message=bridgeconf.description,
|
||||
success_view="portal.bridgeconf.bridgeconf_list",
|
||||
success_message="All bridges from the destroyed configuration will shortly be destroyed at their providers.",
|
||||
section="bridgeconf",
|
||||
resource=bridgeconf,
|
||||
action="destroy"
|
||||
action="destroy",
|
||||
**_SECTION_TEMPLATE_VARS
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue