diff --git a/console_conf/controllers/identity.py b/console_conf/controllers/identity.py index 0719707b..c6b50e15 100644 --- a/console_conf/controllers/identity.py +++ b/console_conf/controllers/identity.py @@ -19,7 +19,8 @@ import os import subprocess import sys -from subiquitycore.controllers.identity import BaseIdentityController +from subiquitycore.controller import BaseController +from subiquitycore.models import IdentityModel from subiquitycore.utils import disable_first_boot_service, run_command from console_conf.ui.views import IdentityView, LoginView @@ -98,8 +99,11 @@ def write_login_details_standalone(): return 0 -class IdentityController(BaseIdentityController): - identity_view = IdentityView +class IdentityController(BaseController): + + def __init__(self, common): + super().__init__(common) + self.model = IdentityModel(self.opts) def default(self): title = "Profile setup" @@ -107,7 +111,7 @@ class IdentityController(BaseIdentityController): footer = "" self.ui.set_header(title, excerpt) self.ui.set_footer(footer, 40) - self.ui.set_body(self.identity_view(self.model, self, self.opts, self.loop)) + self.ui.set_body(IdentityView(self.model, self, self.opts, self.loop)) device_owner = get_device_owner() if device_owner is not None: self.model.add_user(device_owner) diff --git a/console_conf/controllers/welcome.py b/console_conf/controllers/welcome.py index 16e61be0..868651cc 100644 --- a/console_conf/controllers/welcome.py +++ b/console_conf/controllers/welcome.py @@ -13,20 +13,25 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . - from console_conf.ui.views import WelcomeView -from subiquitycore.controllers.welcome import ( - WelcomeController as WelcomeControllerBase, - ) +from subiquitycore.controller import BaseController -class WelcomeController(WelcomeControllerBase): +class WelcomeController(BaseController): + def default(self): title = "Ubuntu Core" excerpt = ("Configure the network and setup an administrator " "account on this all-snap Ubuntu Core system.") self.ui.set_header(title, excerpt) self.ui.set_footer("") - view = WelcomeView(self.model, self) + view = WelcomeView(self) self.ui.set_body(view) + + def done(self): + self.signal.emit_signal('next-screen') + + def cancel(self): + # Can't go back from here! + pass diff --git a/console_conf/ui/views/welcome.py b/console_conf/ui/views/welcome.py index 837e5eed..92515859 100644 --- a/console_conf/ui/views/welcome.py +++ b/console_conf/ui/views/welcome.py @@ -19,18 +19,28 @@ Welcome provides user with language selection """ import logging -from urwid import Pile -from subiquitycore.ui.buttons import start_btn -from subiquitycore.ui.utils import Color -from subiquitycore.ui.views.welcome import CoreWelcomeView +from urwid import ListBox, Pile +from subiquitycore.ui.buttons import ok_btn +from subiquitycore.ui.utils import Padding, Color +from subiquitycore.view import BaseView log = logging.getLogger("console_conf.views.welcome") -class WelcomeView(CoreWelcomeView): +class WelcomeView(BaseView): + def __init__(self, controller): + self.controller = controller + self.body = [ + Padding.fixed_10(self._build_buttons()) + ] + super().__init__(ListBox(self.body)) + def _build_buttons(self): self.buttons = [ - Color.button(start_btn(on_press=self.confirm), + Color.button(ok_btn(on_press=self.confirm), focus_map='button focus'), ] return Pile(self.buttons) + + def confirm(self, result): + self.controller.done() diff --git a/subiquity/controllers/__init__.py b/subiquity/controllers/__init__.py index d9c2acac..5072884b 100644 --- a/subiquity/controllers/__init__.py +++ b/subiquity/controllers/__init__.py @@ -15,9 +15,9 @@ from subiquitycore.controllers.login import LoginController # NOQA from subiquitycore.controllers.network import NetworkController # NOQA -from subiquitycore.controllers.welcome import WelcomeController # NOQA from .identity import IdentityController # NOQA from .installpath import InstallpathController # NOQA from .installprogress import InstallProgressController # NOQA from .filesystem import FilesystemController # NOQA +from .welcome import WelcomeController # NOQA diff --git a/subiquity/controllers/identity.py b/subiquity/controllers/identity.py index 4d3eb667..4a26fa05 100644 --- a/subiquity/controllers/identity.py +++ b/subiquity/controllers/identity.py @@ -14,10 +14,54 @@ # along with this program. If not, see . -from subiquitycore.controllers.identity import BaseIdentityController +import logging + +from subiquitycore.controller import BaseController +from subiquitycore.models import IdentityModel +from subiquitycore import utils from subiquity.ui.views import IdentityView +log = logging.getLogger('subiquity.controllers.identity') -class IdentityController(BaseIdentityController): - identity_view = IdentityView + +class IdentityController(BaseController): + + def __init__(self, common): + super().__init__(common) + self.model = IdentityModel(self.opts) + + def default(self): + title = "Profile setup" + excerpt = ("Input your username and password to log in to the system.") + footer = "" + self.ui.set_header(title, excerpt) + self.ui.set_footer(footer, 40) + self.ui.set_body(IdentityView(self.model, self, self.opts)) + + def cancel(self): + self.signal.emit_signal('prev-screen') + + # None of the commented out code below is actually called. Maybe it should be? + + ## def identity_done(self): + ## self.login() + + ## def login(self): + ## log.debug("Identity login view") + ## title = ("Configuration Complete") + ## footer = ("View configured user and device access methods") + ## self.ui.set_header(title) + ## self.ui.set_footer(footer) + + ## net_model = self.controllers['Network'].model + ## configured_ifaces = net_model.get_configured_interfaces() + ## login_view = LoginView(self.model, self, configured_ifaces) + + ## self.ui.set_body(login_view) + + ## def login_done(self): + ## # mark ourselves complete + ## utils.disable_subiquity() + + ## self.signal.emit_signal('next-screen') diff --git a/subiquitycore/controllers/welcome.py b/subiquity/controllers/welcome.py similarity index 93% rename from subiquitycore/controllers/welcome.py rename to subiquity/controllers/welcome.py index f585a0e8..98139c42 100644 --- a/subiquitycore/controllers/welcome.py +++ b/subiquity/controllers/welcome.py @@ -14,10 +14,11 @@ # along with this program. If not, see . -from subiquitycore.ui.views import WelcomeView -from subiquitycore.models import WelcomeModel from subiquitycore.controller import BaseController +from subiquity.ui.views import WelcomeView +from subiquity.models import WelcomeModel + class WelcomeController(BaseController): diff --git a/subiquity/models/__init__.py b/subiquity/models/__init__.py index 2fa1c07a..da84a97f 100644 --- a/subiquity/models/__init__.py +++ b/subiquity/models/__init__.py @@ -17,3 +17,4 @@ from .installpath import InstallpathModel # NOQA from .installprogress import InstallProgressModel # NOQA from .filesystem import FilesystemModel # NOQA from .raid import RaidModel # NOQA +from .welcome import WelcomeModel diff --git a/subiquitycore/models/welcome.py b/subiquity/models/welcome.py similarity index 95% rename from subiquitycore/models/welcome.py rename to subiquity/models/welcome.py index 8d6c320d..fba585a4 100644 --- a/subiquitycore/models/welcome.py +++ b/subiquity/models/welcome.py @@ -16,7 +16,7 @@ import logging -log = logging.getLogger('subiquitycore.welcome') +log = logging.getLogger('subiquity.models.welcome') class WelcomeModel(object): diff --git a/subiquity/ui/views/__init__.py b/subiquity/ui/views/__init__.py index 98895167..de274b03 100644 --- a/subiquity/ui/views/__init__.py +++ b/subiquity/ui/views/__init__.py @@ -26,3 +26,4 @@ from .lvm import LVMVolumeGroupView # NOQA from .identity import IdentityView # NOQA from .installpath import InstallpathView # NOQA from .installprogress import ProgressView # NOQA +from .welcome import WelcomeView diff --git a/subiquitycore/ui/views/welcome.py b/subiquity/ui/views/welcome.py similarity index 95% rename from subiquitycore/ui/views/welcome.py rename to subiquity/ui/views/welcome.py index 78b4667c..f65074f3 100644 --- a/subiquitycore/ui/views/welcome.py +++ b/subiquity/ui/views/welcome.py @@ -25,10 +25,11 @@ from subiquitycore.ui.buttons import menu_btn, ok_btn from subiquitycore.ui.utils import Padding, Color from subiquitycore.view import BaseView -log = logging.getLogger("subiquitycore.views.welcome") +log = logging.getLogger("subiquity.views.welcome") -class CoreWelcomeView(BaseView): +class WelcomeView(BaseView): + def __init__(self, model, controller): self.model = model self.controller = controller diff --git a/subiquitycore/controllers/identity.py b/subiquitycore/controllers/identity.py deleted file mode 100644 index eb55bcbf..00000000 --- a/subiquitycore/controllers/identity.py +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright 2015 Canonical, Ltd. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import logging -from subiquitycore.controller import BaseController -from subiquitycore.models import IdentityModel -from subiquitycore.ui.views import LoginView -from subiquitycore import utils - -log = logging.getLogger('subiquitycore.controllers.identity') - - -class BaseIdentityController(BaseController): - - identity_view = None - - def __init__(self, common): - super().__init__(common) - self.model = IdentityModel(self.opts) - - def default(self): - title = "Profile setup" - excerpt = ("Input your username and password to log in to the system.") - footer = "" - self.ui.set_header(title, excerpt) - self.ui.set_footer(footer, 40) - self.ui.set_body(self.identity_view(self.model, self, self.opts)) - - def cancel(self): - self.signal.emit_signal('prev-screen') - - def identity_done(self): - self.login() - - def login(self): - log.debug("Identity login view") - title = ("Configuration Complete") - footer = ("View configured user and device access methods") - self.ui.set_header(title) - self.ui.set_footer(footer) - - net_model = self.controllers['Network'].model - configured_ifaces = net_model.get_configured_interfaces() - login_view = LoginView(self.model, self, configured_ifaces) - - self.ui.set_body(login_view) - - def login_done(self): - # mark ourselves complete - utils.disable_subiquity() - - self.signal.emit_signal('next-screen') diff --git a/subiquitycore/models/__init__.py b/subiquitycore/models/__init__.py index 77fd4084..ad52ce20 100644 --- a/subiquitycore/models/__init__.py +++ b/subiquitycore/models/__init__.py @@ -14,6 +14,5 @@ # along with this program. If not, see . from .network import NetworkModel # NOQA -from .welcome import WelcomeModel # NOQA from .identity import IdentityModel # NOQA from .login import LoginModel # NOQA diff --git a/subiquitycore/ui/views/__init__.py b/subiquitycore/ui/views/__init__.py index 8ba5af49..86b86e4d 100644 --- a/subiquitycore/ui/views/__init__.py +++ b/subiquitycore/ui/views/__init__.py @@ -19,5 +19,4 @@ from .network_configure_interface import NetworkConfigureInterfaceView # NOQA from .network_configure_manual_interface import NetworkConfigureIPv4InterfaceView, NetworkConfigureIPv6InterfaceView # NOQA from .network_configure_wlan_interface import NetworkConfigureWLANView # NOQA from .network_bond_interfaces import NetworkBondInterfacesView # NOQA -from .welcome import CoreWelcomeView as WelcomeView # NOQA from .login import LoginView # NOQA