Commit 25eef348 by Eric Fischer Committed by Andy Armstrong

Move initialization code to __init__

parent 7d599598
...@@ -96,29 +96,24 @@ class AssessmentWorkflow(TimeStampedModel, StatusModel): ...@@ -96,29 +96,24 @@ class AssessmentWorkflow(TimeStampedModel, StatusModel):
ordering = ["-created"] ordering = ["-created"]
# TODO: In migration, need a non-unique index on (course_id, item_id, status) # TODO: In migration, need a non-unique index on (course_id, item_id, status)
@classmethod def __init__(self, *args, **kwargs):
@transaction.atomic super(AssessmentWorkflow, self).__init__(*args, **kwargs)
def include_staff_in_class(cls): if 'staff' not in AssessmentWorkflow.STEPS:
if 'staff' not in cls.STEPS:
new_list = ['staff'] new_list = ['staff']
new_list.extend(cls.STEPS) new_list.extend(AssessmentWorkflow.STEPS)
cls.STEPS = new_list AssessmentWorkflow.STEPS = new_list
cls.STATUS_VALUES = cls.STEPS + cls.STATUSES AssessmentWorkflow.STATUS_VALUES = AssessmentWorkflow.STEPS + AssessmentWorkflow.STATUSES
cls.STATUS = Choices(*cls.STATUS_VALUES) AssessmentWorkflow.STATUS = Choices(*AssessmentWorkflow.STATUS_VALUES)
if 'staff' not in cls.ASSESSMENT_SCORE_PRIORITY: if 'staff' not in AssessmentWorkflow.ASSESSMENT_SCORE_PRIORITY:
new_list = ['staff'] new_list = ['staff']
new_list.extend(cls.ASSESSMENT_SCORE_PRIORITY) new_list.extend(AssessmentWorkflow.ASSESSMENT_SCORE_PRIORITY)
cls.ASSESSMENT_SCORE_PRIORITY = new_list AssessmentWorkflow.ASSESSMENT_SCORE_PRIORITY = new_list
@classmethod
def from_db(cls, db, field_names, values):
cls.include_staff_in_class()
super(AssessmentWorkflow).from_db(db, field_names, values)
@classmethod @classmethod
@transaction.commit_on_success @transaction.atomic
>>>>>>> Include staff in class def include_staff_in_class(cls):
if 'staff' not in cls.STEPS:
def start_workflow(cls, submission_uuid, step_names, on_init_params): def start_workflow(cls, submission_uuid, step_names, on_init_params):
""" """
Start a new workflow. Start a new workflow.
...@@ -146,8 +141,6 @@ class AssessmentWorkflow(TimeStampedModel, StatusModel): ...@@ -146,8 +141,6 @@ class AssessmentWorkflow(TimeStampedModel, StatusModel):
new_list.extend(step_names) new_list.extend(step_names)
step_names = new_list step_names = new_list
cls.include_staff_in_class()
# Create the workflow and step models in the database # Create the workflow and step models in the database
# For now, set the status to waiting; we'll modify it later # For now, set the status to waiting; we'll modify it later
# based on the first step in the workflow. # based on the first step in the workflow.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment