---
pyanaconda/ui/tui/spokes/user.py | 92 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 92 insertions(+)
create mode 100644 pyanaconda/ui/tui/spokes/user.py
diff --git a/pyanaconda/ui/tui/spokes/user.py b/pyanaconda/ui/tui/spokes/user.py
new file mode 100644
index 0000000..52c14b4
--- /dev/null
+++ b/pyanaconda/ui/tui/spokes/user.py
@@ -0,0 +1,92 @@
+# Root password text spoke
+#
+# Copyright (C) 2013 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): Martin Sivak <msivak(a)redhat.com>
+#
+
+from pyanaconda.ui.tui.spokes import EditTUISpoke
+from pyanaconda.ui.tui.spokes import EditTUISpokeEntry as Entry
+from pyanaconda.ui.common import FirstbootSpokeMixIn
+from pyanaconda.ui.tui.simpleline import TextWidget
+from pyanaconda.ui.tui import YesNoDialog
+from pyanaconda.users import validatePassword, guess_username
+
+import re
+import gettext
+import unicodedata
+
+_ = lambda x: gettext.ldgettext("anaconda", x)
+
+__all__ = ["UserSpoke"]
+
+class UserSpoke(FirstbootSpokeMixIn, EditTUISpoke):
+ title = _("Create user")
+ category = "password"
+
+ edit_fields = [
+ Entry("Fullname", "gecos", re.compile("^[^:]*$"),
True),
+ Entry("Username", "name",
re.compile("^[a-z0-9_]+$"), True),
+ Entry("Use password", "_use_password", EditTUISpoke.CHECK,
True),
+ Entry("Password", "password", EditTUISpoke.PASSWORD, lambda
self,args: args._use_password),
+ Entry("Administrator", "_admin", EditTUISpoke.CHECK, True),
+ Entry("Groups", "_groups", re.compile("^([a-z0-9_]+)?(,
?([a-z0-9_]+))*$"), True)
+ ]
+
+ def __init__(self, app, data, storage, payload, instclass):
+ FirstbootSpokeMixIn.__init__(self)
+ EditTUISpoke.__init__(self, app, data, storage, payload, instclass)
+
+ if self.data.user.userList:
+ self.args = self.data.user.userList[0]
+ else:
+ self.args = self.data.UserData()
+
+ self.args._use_password = self.args.isCrypted or self.args.password
+
+ def refresh(self, args = None):
+ self.args._admin = "wheel" in self.args.groups
+ self.args._groups = ", ".join(self.args.groups)
+ return EditTUISpoke.refresh(self, args)
+
+ @property
+ def completed(self):
+ return self.data.user.userList
+
+ @property
+ def mandatory(self):
+ return True
+
+ @property
+ def status(self):
+ if len(self.data.user.userList) == 0:
+ return _("No user will be created")
+ elif "wheel" in self.data.user.userList[0].groups:
+ return _("Administrator %s will be created") %
self.data.user.userList[0].name
+ else:
+ return _("User %s will be created") %
self.data.user.userList[0].name
+
+ def apply(self):
+ if self.args.gecos and not self.args.name:
+ self.args.name = guess_username(self.args.gecos)
+
+ self.args.groups = [g.strip() for g in self.args._groups.split(",") if
g]
+
+ if self.args._admin and "wheel" not in self.args.groups:
+ self.args.groups.append("wheel")
+ elif not self.args._admin and "wheel" in self.args.groups:
+ self.args.groups.remove("wheel")
--
1.7.11.7