Update first time setup flow; update strings, include strings from figma

This commit is contained in:
Ana Custura 2026-03-29 17:17:47 +01:00
parent 9937cc8884
commit 4c25aeabf9
23 changed files with 1451 additions and 245 deletions

View file

@ -10,13 +10,13 @@ def hostname_check(form, field):
regex= re.compile("[a-zA-Z0-9-_]+")
matches = re.fullmatch(regex, field.data)
if not matches:
raise ValidationError(_l('Only dashes, underscores, letters and numbers allowed'))
raise ValidationError(_l('Only dashes, underscores, letters and numbers allowed.'))
def wifi_length_check(form, field):
if len(field.data) > 63:
raise ValidationError('Wifi password cannot be longer than 63 characters.')
raise ValidationError(_l('Wifi password cannot be longer than 63 characters.'))
if len(field.data) in range(1,9):
raise ValidationError('Wifi password cannot be shorter than 8 characters.')
raise ValidationError(_l('Wifi password cannot be shorter than 8 characters.'))
class LoginForm(FlaskForm):
username = StringField(_l('Username'), validators=[DataRequired()])
@ -24,6 +24,34 @@ class LoginForm(FlaskForm):
submit = SubmitField(_l('Sign In'))
remember_me = BooleanField('Remember Me')
class Step1Form(FlaskForm):
enable_file_viewer = BooleanField(_l('Enable File Viewer'))
enable_chat = BooleanField(_l('Enable Chat'))
enable_deltachat = BooleanField(_l('Enable DeltaChat'))
submit = SubmitField(_l('Next'))
class Step2Form(FlaskForm):
butterbox_name = StringField(_l('Butterbox Name'), validators=[DataRequired()])
butterbox_logo = FileField((_l('Butterbox Logo')), validators=[FileAllowed(['jpg', 'png', 'svg'], 'Images only!')])
butterbox_hostname = StringField(_l('Butterbox Hostname'), validators=[DataRequired(), Length(1, 64), hostname_check])
submit = SubmitField(_l('Next'))
class Step3Form(FlaskForm):
ssid = StringField(_l('WiFi Name'), validators=[DataRequired(), Length(1, 64), hostname_check])
wifi_password = StringField(_l('WiFi Password'), validators=[wifi_length_check])
enable_wifi_sharing = BooleanField(_l('Enable WiFi Sharing'))
enable_access_point = BooleanField(_l('Enable Access Point'))
submit = SubmitField(_l('Next'))
class Step4Form(FlaskForm):
admin_password = StringField(_l('Admin Password'), widget=PasswordInput(hide_value=False))
root_password = StringField(_l('Root Password'), widget=PasswordInput(hide_value=False), validators=[DataRequired()])
root_account_settings= RadioField(_l('Secure Root Account Method'), choices=[ ('lock_root_account', _l('Lock root account')), ( 'set_root_password', _l('Use root password'))], validators=[DataRequired()])
ssh_access_settings = RadioField(_l('SSH Access Method'), choices=[ ('disable_ssh', _l('Disable SSH')), ( 'enable_ssh_with_root_password', _l('Enable SSH with root password')), ], validators=[DataRequired()])
# ('enable_ssh_with_public_key', 'Enable SSH with public key'),
lock_root_account = BooleanField(_l('Lock Root Account'))
submit = SubmitField(_l('Apply Changes'))
class SettingsForm(FlaskForm):
# Access point settings
@ -32,23 +60,19 @@ class SettingsForm(FlaskForm):
enable_access_point = BooleanField(_l('Enable Access Point'))
# Customisation settings
butterbox_name = StringField(_l('Butterbox Name'), validators=[DataRequired()])
butterbox_logo = FileField((_l('Butterbox Logo')), validators=[FileAllowed(['jpg', 'png', 'svg'], 'Images only!')])
butterbox_logo = FileField((_l('Butterbox Logo')), validators=[FileAllowed(['jpg', 'png', 'svg'], _l('Images only!'))])
# Services settings
enable_file_viewer = BooleanField(_l('Enable File Viewer'))
enable_map_viewer = BooleanField(_l('Enable Map Viewer'))
enable_chat = BooleanField(_l('Enable Chat'))
enable_app_store = BooleanField(_l('Enable App Store'))
enable_deltachat = BooleanField(_l('Enable DeltaChat'))
enable_wifi_sharing = BooleanField(_l('Enable WiFi Sharing'))
# Access Settings
admin_password = StringField('Admin Password', widget=PasswordInput(hide_value=False))
root_password = StringField('Root Password', widget=PasswordInput(hide_value=False), validators=[DataRequired()])
admin_password = StringField(_l('Admin Password'), widget=PasswordInput(hide_value=False))
root_password = StringField(_l('Root Password'), widget=PasswordInput(hide_value=False), validators=[DataRequired()])
root_account_settings= RadioField(_l('Secure Root Account Method'), choices=[ ('lock_root_account', 'Lock root account'), ( 'set_root_password', 'Use root password')], validators=[DataRequired()])
ssh_access_settings = RadioField(_l('SSH Access Method'), choices=[ ('disable_ssh', 'Disable SSH'), ( 'enable_ssh_with_root_password', 'Enable SSH with root password'), ], validators=[DataRequired()])
root_account_settings= RadioField(_l('Secure Root Account Method'), choices=[('lock_root_account', _l('Lock root account')), ( 'set_root_password', _l('Use root password'))], validators=[DataRequired()])
ssh_access_settings = RadioField(_l('SSH Access Method'), choices=[ ('disable_ssh', _l('Disable SSH')), ( 'enable_ssh_with_root_password', _l('Enable SSH with root password')), ], validators=[DataRequired()])
# ('enable_ssh_with_public_key', 'Enable SSH with public key'),
lock_root_account = BooleanField(_l('Lock Root Account'))
butterbox_hostname = StringField(_l('Butterbox Hostname'), validators=[DataRequired(), Length(1, 64), hostname_check])
submit = SubmitField(_l('Submit'))
apply_changes = SubmitField(_l('Apply Changes'))