From a21c6044461097a8551efd7bbcae2cd4d466fb07 Mon Sep 17 00:00:00 2001 From: Sawyer Bergeron Date: Wed, 22 May 2019 10:13:03 -0400 Subject: Make steps possible to hide/show Change-Id: Ice5036ea9801655032cb080537fbd471fb3fda3e Signed-off-by: Sawyer Bergeron --- src/workflow/models.py | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) (limited to 'src/workflow/models.py') 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" -- cgit 1.2.3-korg