Start work on models and ui
Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
This commit is contained in:
parent
d812ff23b8
commit
9f78c2a775
|
@ -0,0 +1,36 @@
|
|||
# Copyright 2015 Canonical, Ltd.
|
||||
|
||||
""" Model Classes
|
||||
|
||||
Model's represent the stateful data bound from
|
||||
input from the user.
|
||||
"""
|
||||
|
||||
|
||||
class Model:
|
||||
"""Base model"""
|
||||
|
||||
def to_json(self):
|
||||
"""Marshals the model to json"""
|
||||
return NotImplementedError
|
||||
|
||||
def create(self):
|
||||
"""Creates model instance with validation"""
|
||||
return NotImplementedError
|
||||
|
||||
|
||||
class Field:
|
||||
"""Base field class
|
||||
|
||||
New field types inherit this class, provides access to
|
||||
validation checks and type definitions.
|
||||
"""
|
||||
default_error_messages = {
|
||||
'invalid_choice': ('Value %(value)r is not a valid choice.'),
|
||||
'null': ('This field cannot be null.'),
|
||||
'blank': ('This field cannot be blank.')
|
||||
}
|
||||
|
||||
def __init__(self, name=None, blank=False, null=False):
|
||||
self.name = name
|
||||
self.blank, self.null = blank, null
|
|
@ -0,0 +1,18 @@
|
|||
# Copyright 2015 Canonical, Ltd.
|
||||
|
||||
""" Identity Model
|
||||
|
||||
Represents information related to identification, for example,
|
||||
User's first and last name, timezone, country, language preferences.
|
||||
"""
|
||||
|
||||
from subiquity import models
|
||||
|
||||
|
||||
class UserModel(models.Model):
|
||||
""" User class to support personal information
|
||||
"""
|
||||
username = None
|
||||
language = None
|
||||
keyboard = None
|
||||
timezone = None
|
|
@ -0,0 +1,16 @@
|
|||
# Copyright 2015 Canonical, Ltd.
|
||||
|
||||
""" Welcome Model
|
||||
|
||||
Welcome model provides user with installation options
|
||||
|
||||
"""
|
||||
|
||||
from subiquity import models
|
||||
|
||||
|
||||
class WelcomeModel(models.Model):
|
||||
""" Model representing installation type
|
||||
"""
|
||||
|
||||
install_type = None
|
|
@ -0,0 +1,5 @@
|
|||
# Copyright 2015 Canonical, Ltd.
|
||||
|
||||
""" Subiquity UI Components """
|
||||
|
||||
__version__ = "0.0.1"
|
|
@ -0,0 +1,36 @@
|
|||
# Copyright 2015 Canonical, Ltd.
|
||||
|
||||
from urwid import WidgetWrap, AttrWrap, Pile, Text, Columns
|
||||
|
||||
|
||||
class Header(WidgetWrap):
|
||||
""" Header Widget
|
||||
|
||||
This widget uses the style key `frame_header`
|
||||
|
||||
:param str title: Title of Header
|
||||
:returns: Header()
|
||||
"""
|
||||
def __init__(self, title="Ubuntu Server Installer"):
|
||||
title = title
|
||||
title_widget = AttrWrap(Text(title), "frame_header")
|
||||
pile = Pile([title_widget])
|
||||
super().__init__(Columns(pile))
|
||||
|
||||
|
||||
class Footer(WidgetWrap):
|
||||
""" Footer widget
|
||||
|
||||
Style key: `frame_footer`
|
||||
|
||||
"""
|
||||
def __init__(self):
|
||||
status = Pile([Text("")])
|
||||
super().__init__(Columns(status))
|
||||
|
||||
|
||||
class Body(WidgetWrap):
|
||||
""" Body widget
|
||||
"""
|
||||
def __init__(self):
|
||||
super().__init__(Text("Welcome to the Server Installation"))
|
|
@ -0,0 +1,13 @@
|
|||
# Copyright 2015 Canonical, Ltd.
|
||||
|
||||
""" Base Frame Widget """
|
||||
|
||||
from urwid import Frame, WidgetWrap
|
||||
|
||||
|
||||
class Base(WidgetWrap):
|
||||
def __init__(self, header, body, footer):
|
||||
self.frame = Frame(body,
|
||||
header,
|
||||
footer)
|
||||
super().__init__(self.frame)
|
Loading…
Reference in New Issue