Verified Commit 1ce5b141 authored by Štěpán Henek's avatar Štěpán Henek 🌩

finished: last step added to guide

parent 0eb03ea9
......@@ -150,7 +150,6 @@ def reboot():
def leave_guide():
current_state.backend.perform("web", "update_guide", {
"enabled": False,
"workflow": current_state.guide.workflow,
})
bottle.redirect(reverse("/"))
......
......@@ -598,6 +598,32 @@ class UpdaterConfigPage(ConfigPageMixin, updater.UpdaterHandler):
return ConfigPageMixin.get_menu_tag_static(cls)
class GuideFinishedPage(ConfigPageMixin, misc.GuideFinishedHandler):
slug = "finished"
menu_order = 90
template_type = "jinja2"
template = "config/finished"
def save(self, *args, **kwargs):
result = super().save(no_messages=True, *args, **kwargs)
if not self.form.callback_results["result"]:
messages.error(_("Failed to finish the guide."))
return result
@classmethod
def is_visible(cls):
if not current_state.guide.enabled:
return False
return ConfigPageMixin.is_visible_static(cls)
@classmethod
def is_enabled(cls):
if not current_state.guide.enabled:
return False
return ConfigPageMixin.is_enabled_static(cls)
class AboutConfigPage(ConfigPageMixin):
slug = "about"
menu_order = 99
......@@ -626,6 +652,7 @@ config_pages = {
WifiConfigPage,
MaintenanceConfigPage,
UpdaterConfigPage,
GuideFinishedPage,
AboutConfigPage,
]
}
......
......@@ -296,3 +296,27 @@ class UnifiedTimeHandler(BaseConfigHandler):
region_and_time_form.add_callback(region_form_cb)
return region_and_time_form
class GuideFinishedHandler(BaseConfigHandler):
userfriendly_title = gettext("Guide Finished")
def get_form(self):
finished_form = fapi.ForisForm("guide_finished", {})
finished_form.add_section(
name="guide_finished", title=_(self.userfriendly_title),
description=_(
"Congratulations you've successfully reached the end of this guide. "
"Once you leave this guide you'll be granted access to the "
"full configuration interface of this device."
)
)
def guide_finished_cb(data):
res = current_state.backend.perform("web", "update_guide", {
"enabled": False,
})
return "save_result", res # store {"result": ...} to be used later...
finished_form.add_callback(guide_finished_cb)
return finished_form
This diff is collapsed.
......@@ -32,7 +32,9 @@
</form>
<form method="post" action="{{ url("leave_guide") }}">
<input type="hidden" name="csrf_token" value="{{ get_csrf_token() }}">
{% if foris_info.guide.display_leave_guide(foris_info.guide.current == active_config_page_key) %}
<button type="submit" name="target" class="button" value="save"><i class='fas fa-times'></i> {% trans %}Leave Guided Mode{% endtrans %}</button>
{% endif %}
</form>
{% if foris_info.guide.current != active_config_page_key %}
<a class="button" href="{{ url("config_page", page_name=foris_info.guide.current) }}"><i class='fas fa-share'></i> {% trans %}Next step{% endtrans %}</a>
......
{% extends 'config/base.html.j2' %}
{% block config_base %}
{% if is_xhr is not defined %}
<div id="page-config" class="config-page">
{% endif %}
<form id="main-form" class="config-form" action="{{ request.fullpath }}" method="post" autocomplete="off" novalidate>
<p class="config-description">{{ description|safe }}</p>
{% include '_messages.html.j2' %}
<input type="hidden" name="csrf_token" value="{{ get_csrf_token() }}">
<div id="{{ 'form-%s-buttons' % form.name }}" class="form-buttons">
<button type="submit" name="send" class="button">{% trans %}Continue{% endtrans %}</button>
</div>
</form>
{% if is_xhr is not defined %}
</div>
{% endif %}
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment