Commit 71da6d6f authored by rgaudin's avatar rgaudin
Browse files

Fixed #201: removed admin account toggle from GUI

parent 4585a507
......@@ -63,13 +63,12 @@ def set_config(config, args):
# admin account
if "admin_account" in config \
and isinstance(config["admin_account"], dict):
if config["admin_account"].get("custom") is not None:
# we need both login and password
if config["admin_account"].get("login") is not None \
and config["admin_account"].get("password") is not None:
setif('admin_account', [config["admin_account"]["login"],
config["admin_account"]["password"]])
# we need both login and password
if config["admin_account"].get("login") is not None \
and config["admin_account"].get("password") is not None:
setif('admin_account', [config["admin_account"]["login"],
config["admin_account"]["password"]])
# build_dir
if config.get("build_dir") is not None:
......
......@@ -245,9 +245,6 @@ class Application:
# wifi password
self.component.wifi_password_switch.connect("notify::active", lambda switch, state: self.component.wifi_password_revealer.set_reveal_child(not switch.get_active()))
# admin account
self.component.admin_account_switch.connect("notify::active", lambda switch, state: self.component.admin_account_revealer.set_reveal_child(switch.get_active()))
# edupi resources
self.component.edupi_switch.connect("notify::active", lambda switch, state: self.component.edupi_resources_revealer.set_reveal_child(switch.get_active()))
......@@ -443,7 +440,6 @@ class Application:
self.component.wifi_password_entry.set_text("kiwixplug-wifipwd")
# admin account
self.component.admin_account_switch.set_active(False)
self.component.admin_account_login_entry.set_text("admin")
self.component.admin_account_pwd_entry.set_text("admin-password")
......@@ -695,10 +691,6 @@ class Application:
# admin account
if "admin_account" in config \
and isinstance(config["admin_account"], dict):
if config["admin_account"].get("custom") is not None:
self.component.admin_account_switch.set_active(
bool(config["admin_account"]["custom"]))
for key, arg_key in {'login': 'login', 'password': 'pwd'}.items():
if config["admin_account"].get(key) is not None:
getattr(self.component, 'admin_account_{}_entry'
......@@ -844,7 +836,6 @@ class Application:
"password": self.component.wifi_password_entry.get_text(),
}),
("admin_account", {
"custom": self.component.admin_account_switch.get_active(),
"login": self.component.admin_account_login_entry.get_text(),
"password": self.component.admin_account_pwd_entry.get_text(),
}),
......@@ -908,19 +899,13 @@ class Application:
validate_label(self.component.wifi_password_label, condition)
all_valid = all_valid and condition
if not self.component.admin_account_switch.get_state():
admin_account = None
login_condition = True
pwd_condition = True
else:
admin_account = {
"login": self.component.admin_account_login_entry.get_text(),
"pwd": self.component.admin_account_pwd_entry.get_text(),
}
login_condition = len(admin_account["login"]) <= 31 and set(admin_account["login"]) <= set(string.ascii_uppercase + string.ascii_lowercase + string.digits + '-' + '_')
pwd_condition = len(admin_account["pwd"]) <= 31 and set(admin_account["pwd"]) <= set(string.ascii_uppercase + string.ascii_lowercase + string.digits + '-' + '_') and (admin_account["pwd"] != admin_account["login"])
self.component.admin_account_login_constraints_revealer.set_reveal_child(not login_condition)
self.component.admin_account_pwd_constraints_revealer.set_reveal_child(not pwd_condition)
admin_account = {
"login": self.component.admin_account_login_entry.get_text(),
"pwd": self.component.admin_account_pwd_entry.get_text(),
}
login_condition = len(admin_account["login"]) <= 31 and set(admin_account["login"]) <= set(string.ascii_uppercase + string.ascii_lowercase + string.digits + '-' + '_')
pwd_condition = len(admin_account["pwd"]) <= 31 and set(admin_account["pwd"]) <= set(string.ascii_uppercase + string.ascii_lowercase + string.digits + '-' + '_') and (admin_account["pwd"] != admin_account["login"])
validate_label(self.component.admin_account_login_label, login_condition)
validate_label(self.component.admin_account_pwd_label, pwd_condition)
all_valid = all_valid and pwd_condition and login_condition
......
......@@ -704,46 +704,6 @@ and digits '0' to '9'</property>
<property name="position">7</property>
</packing>
</child>
<child>
<object class="GtkBox" id="no_id_25">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="no_id_64">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Set the administrator account. Otherwise it will be ask to create one on the first run of the box.</property>
<property name="label" translatable="yes">Preset admin account :</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="admin_account_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">8</property>
</packing>
</child>
<child>
<object class="GtkRevealer" id="admin_account_revealer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="no_id_75">
<property name="visible">True</property>
......@@ -872,13 +832,6 @@ Must be different than login</property>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">9</property>
</packing>
</child>
<child>
<object class="GtkBox" id="no_id_14">
<property name="visible">True</property>
......
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