mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
67 lines
3.2 KiB
Python
67 lines
3.2 KiB
Python
from urlparse import urlparse
|
|
import os, cherrypy
|
|
from gettext import gettext as _
|
|
from plugin_mount import PagePlugin, PluginMount, FormPlugin
|
|
from modules.auth import require
|
|
from forms import Form
|
|
import util as u
|
|
from vendor.withsqlite.withsqlite import sqlite_db
|
|
import cfg
|
|
|
|
class FirstBoot(PagePlugin):
|
|
def __init__(self, *args, **kwargs):
|
|
PagePlugin.__init__(self, *args, **kwargs)
|
|
self.register_page("firstboot") # this is the url this page will hang off of (/firstboot)
|
|
|
|
@cherrypy.expose
|
|
def index(self, *args, **kwargs):
|
|
return self.state0(*args, **kwargs)
|
|
|
|
@cherrypy.expose
|
|
def state0(self, message=None, box_name=None, box_key=""):
|
|
"""
|
|
All the parameters are form inputs. They get passed in when
|
|
the form is submitted. This method checks the inputs and if
|
|
they validate, uses them to take action. If they do not
|
|
validate, it displays the form to give the user a chance to
|
|
input correct values. It might display an error message (in
|
|
the message parameter).
|
|
|
|
message is an optional string that we can display to the
|
|
user. It's a good place to put error messages.
|
|
"""
|
|
|
|
with sqlite_db(cfg.store_file, table="firstboot") as db:
|
|
db['state']=0
|
|
db.commit()
|
|
|
|
main = "<p>Welcome. It looks like this FreedomBox isn't set up yet. We'll need to ask you a just few questions to get started.</p>"
|
|
form = Form(title="Welcome to Your FreedomBox!",
|
|
action="/firstboot",
|
|
name="whats_my_name",
|
|
message=message)
|
|
if not box_name:
|
|
box_name = cfg.box_name
|
|
form.html("<p>For convenience, your FreedomBox needs a name. It should be something short that doesn't contain spaces or punctuation. 'Willard' would be a good name. 'Freestyle McFreedomBox!!!' would not.</p>")
|
|
form.text_input('Name your FreedomBox', id="box_name", value=box_name)
|
|
form.html("<p>%(box_name)s uses cryptographic keys so it can prove its identity when talking to you. %(box_name)s can make a key for itself, but if one already exists (from a prior FreedomBox, for example), you can paste it below. This key should not be the same as your key because you are not your FreedomBox!</p>" % {'box_name':cfg.box_name})
|
|
form.text_box("If you want, paste your box's key here.", id="box_key", value=box_key)
|
|
|
|
### State 1 ###
|
|
|
|
form.submit("Box it up!")
|
|
|
|
main += form.render()
|
|
return self.fill_template(template="base", title=_("First Boot!"), main=main,
|
|
sidebar_right=_("""<strong>Statement of Principles</strong><p>When we say your
|
|
privacy is important, it's not just an empty pleasantry. We really
|
|
mean it. Your privacy control panel should give you fine-grained
|
|
control over exactly who can access your %s and the
|
|
information on it.</p>
|
|
|
|
<p>Your personal information should not leave this box without your
|
|
knowledge and direction. And if companies or government wants this
|
|
information, they have to ask <strong>you</strong> for it. This gives you a
|
|
change to refuse and also tells you who wants your data.</p>
|
|
""" % cfg.product_name))
|