aboutsummaryrefslogtreecommitdiffstats
path: root/src/workflow/models.py
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2019-05-22 10:13:03 -0400
committerSawyer Bergeron <sbergeron@iol.unh.edu>2019-05-22 13:34:13 -0400
commita21c6044461097a8551efd7bbcae2cd4d466fb07 (patch)
treee4150db2439f12a2fe8f06a1ea499327235af46d /src/workflow/models.py
parent2fd2b83361813e0a8375d81729c86adcb2c6feda (diff)
Make steps possible to hide/show
Change-Id: Ice5036ea9801655032cb080537fbd471fb3fda3e Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
Diffstat (limited to 'src/workflow/models.py')
-rw-r--r--src/workflow/models.py49
1 files changed, 43 insertions, 6 deletions
diff --git a/src/workflow/models.py b/src/workflow/models.py
index bf5751d..25d7e84 100644
--- a/src/workflow/models.py
+++ b/src/workflow/models.py
@@ -158,12 +158,52 @@ class BookingAuthManager():
return False
+class WorkflowStepStatus(object):
+ UNTOUCHED = 0
+ INVALID = 100
+ VALID = 200
+
+
class WorkflowStep(object):
template = 'bad_request.html'
title = "Generic Step"
description = "You were led here by mistake"
short_title = "error"
metastep = None
+ # phasing out metastep:
+
+ valid = WorkflowStepStatus.UNTOUCHED
+ message = ""
+
+ enabled = True
+
+ def cleanup(self):
+ raise Exception("WorkflowStep subclass of type " + str(type(self)) + " has no concrete implemented cleanup() method")
+
+ def enable(self):
+ if not self.enabled:
+ self.enabled = True
+
+ def disable(self):
+ if self.enabled:
+ self.cleanup()
+ self.enabled = False
+
+ def set_invalid(self, message, code=WorkflowStepStatus.INVALID):
+ self.valid = code
+ self.message = message
+
+ def set_valid(self, message, code=WorkflowStepStatus.VALID):
+ self.valid = code
+ self.message = message
+
+ def to_json(self):
+ return {
+ 'title': self.short_title,
+ 'enabled': self.enabled,
+ 'valid': self.valid,
+ 'message': self.message,
+ }
def __init__(self, id, repo=None):
self.repo = repo
@@ -205,6 +245,8 @@ class Confirmation_Step(WorkflowStep):
title = "Confirm Changes"
description = "Does this all look right?"
+ short_title = "confirm"
+
def get_context(self):
context = super(Confirmation_Step, self).get_context()
context['form'] = ConfirmationForm()
@@ -245,12 +287,6 @@ class Confirmation_Step(WorkflowStep):
pass
-class Workflow():
-
- steps = []
- active_index = 0
-
-
class Repository():
EDIT = "editing"
@@ -271,6 +307,7 @@ class Repository():
CONFIG_MODELS = "configuration bundle models"
OPNFV_MODELS = "opnfv configuration models"
SESSION_USER = "session owner user account"
+ SESSION_MANAGER = "session manager for current session"
VALIDATED_MODEL_GRB = "valid grb config model instance in db"
VALIDATED_MODEL_CONFIG = "valid config model instance in db"
VALIDATED_MODEL_BOOKING = "valid booking model instance in db"