python - Allow a model instance to be added to the moderation queue based on a condition using Django-Moderation -
given model :
class blog(models.model): title = models.charfield(max_length=200)#title of post body = models.textfield(blank=false) state = models.charfield(max_length=60,choices=state_choices,default='raw')` a blog instance added django-moderation's moderation queue if state=published
the solution problem use "automoderation" feature of django-moderation. whenever save our model instance using instance.save() automoderate model instance over-riding is_auto_approve() function of generic moderator shown.
class blogmoderator(genericmoderator): def is_auto_approve(self, obj, user): if obj.state == "raw": return self.reason('not submitted yet !') super(mymodelmoderator, self).is_auto_approve(obj, user) here instances in state = raw bypass moderation or else added moderation queue.
Comments
Post a Comment