views:

50

answers:

1

Hi folks,

I have a nice admin panel setup so users can manage the data within the site.

Problem is that I need to implement a workflow, so saved models can be approved from and to various stages, to then be finally published.


As the model in question is just one, I thougth of adding a boolean 'approved_for_publishing' field and a 'approved_by' manytomany field.

The obstancle is integrating this within the admin panel.

If someone has a few opinions on the topic that would be really awesome. =)

+1  A: 

Some time early I completed similar functionality. Here is what you need to do: Create an approval status model, and have different variants of approval, i.e each model object represents different approval stage.Also you must have a StatusHistory model which reflects what current status does your article(for example) has.

class Article(models.Model)
      title=models.CharField(max_length=32)
      body=models.TextField()

class ApprovalStatus(models.Model):
      name=models.CharField(max_length=32)
      alias=models.CharField(max_length=32,pk=True)

class StatusHistory(models.Model):
      status=models.ForeignKey(ApprovalStatus)
      article=models.ForeignKey(Article)
      current=models.BooleanField(default=True)

So when in your admin you change the status of the article, a new StatusHistory object is created and old object is given current=False variable. This approach seems a bit bulky, but when you implement it, all you need easily falls into ORM: status history is just a list of all objects, changes to workflow involve only creating new approval status and changing your hardcoded status flow routines

Frost.baka