2016-07-27 04:05:47 +00:00
|
|
|
# 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import logging
|
2019-08-07 20:35:35 +00:00
|
|
|
from urwid import connect_signal
|
2016-07-27 04:05:47 +00:00
|
|
|
|
2016-07-27 10:15:22 +00:00
|
|
|
from subiquitycore.view import BaseView
|
2020-05-18 10:57:41 +00:00
|
|
|
from subiquitycore.ui.utils import SomethingFailed
|
2019-08-07 20:35:35 +00:00
|
|
|
from subiquitycore.ui.form import (
|
|
|
|
Form,
|
|
|
|
EmailField,
|
|
|
|
)
|
|
|
|
|
2016-07-27 04:05:47 +00:00
|
|
|
|
|
|
|
log = logging.getLogger("console_conf.views.identity")
|
|
|
|
|
2019-08-07 20:35:35 +00:00
|
|
|
sso_help = ("If you do not have an account, visit "
|
|
|
|
"https://login.ubuntu.com to create one.")
|
|
|
|
|
|
|
|
|
|
|
|
class IdentityForm(Form):
|
|
|
|
cancel_label = "Back"
|
2016-07-27 04:05:47 +00:00
|
|
|
|
2019-08-07 20:35:35 +00:00
|
|
|
email = EmailField("Email address:", help=sso_help)
|
2016-07-27 10:15:22 +00:00
|
|
|
|
2016-09-09 04:08:37 +00:00
|
|
|
|
2016-07-27 10:15:22 +00:00
|
|
|
class IdentityView(BaseView):
|
2019-08-07 20:35:35 +00:00
|
|
|
title = "Profile setup"
|
|
|
|
excerpt = "Enter an email address from your account in the store."
|
2016-07-27 10:15:22 +00:00
|
|
|
|
2019-08-07 20:35:35 +00:00
|
|
|
def __init__(self, model, controller):
|
2016-07-27 10:15:22 +00:00
|
|
|
self.model = model
|
2016-10-10 23:48:28 +00:00
|
|
|
self.controller = controller
|
2019-08-07 20:35:35 +00:00
|
|
|
self.form = IdentityForm()
|
2017-02-14 02:22:43 +00:00
|
|
|
|
2019-08-07 20:35:35 +00:00
|
|
|
connect_signal(self.form, 'submit', self.done)
|
|
|
|
connect_signal(self.form, 'cancel', self.cancel)
|
2016-07-27 10:15:22 +00:00
|
|
|
|
2020-04-01 13:32:55 +00:00
|
|
|
super().__init__(self.form.as_screen(focus_buttons=False,
|
|
|
|
excerpt=_(self.excerpt)))
|
2016-07-27 10:15:22 +00:00
|
|
|
|
2017-04-04 04:20:56 +00:00
|
|
|
def cancel(self, button=None):
|
2016-10-10 23:48:28 +00:00
|
|
|
self.controller.cancel()
|
2016-07-27 10:15:22 +00:00
|
|
|
|
2019-08-07 20:35:35 +00:00
|
|
|
def done(self, result):
|
|
|
|
self.controller.identity_done(result.email.value)
|
2020-05-18 10:57:41 +00:00
|
|
|
|
|
|
|
def snap_create_user_failed(self, msg, stderr):
|
|
|
|
self.show_stretchy_overlay(SomethingFailed(self, msg, stderr))
|