[Django]-Django: How to keep track of a linear (yet flexible) project management workflow?

1👍

Make more use of the Step model. You can have it hold the possible next steps as foreign keys. This way you can edit the flow by changing data (using the admin for example, instead of hardcoding it). Maybe something like:

class Step(models.Model):
    name = models.CharField(max_length=50)
    responsible_role = models.CharField(max_length=50) # this contains 'sales_rep', 'sales_mgr' etc
    allowed_actions = models.ManyToManyField('AllowedAction')

class AllowedAction(models.Model):
    name = models.CharField(max_length=50)
    next_step = models.ForeignKey('Step') # the next step, if this action is chosen

Seperate the actual project history to another model:

class ProjectHistoryStep(models.Model):
    timestamp = models.DateTimeField()
    step = models.ForeignKey('Step')
    project = models.ForeignKey('Project')  

You can use this model to track the actual progress of your projects (don’t forget that models have get_next_by_FOO).

You’ll only need 1 view that handles all the logic (it should just call some method on the Project class to do the actual work) – check what state the project is in now (latest ProjectHistoryStep for that project), and what was the User’s action, and act accordingly.

Leave a comment