change validateurs, reviewsers and authors to one field (actors)
This commit is contained in:
parent
61e887f71f
commit
32c860a5e3
|
@ -141,6 +141,26 @@ class Document(models.Model):
|
|||
return self.title
|
||||
|
||||
|
||||
ROLE_CHOICES = (
|
||||
(1, 'Validator'),
|
||||
(2, 'Reviewer'),
|
||||
(3, 'Author'),
|
||||
)
|
||||
|
||||
|
||||
class Role(models.Model):
|
||||
"""Defines possible roles for users.
|
||||
|
||||
These roles will (or can) be used for running processes.
|
||||
|
||||
:attributes
|
||||
name (str): the name of the role.
|
||||
"""
|
||||
type = models.IntegerField(choices=ROLE_CHOICES)
|
||||
actor = models.ForeignKey(User)
|
||||
Version = models.ForeignKey('Version')
|
||||
|
||||
|
||||
@reversion.register()
|
||||
class Version(models.Model):
|
||||
"""A version represents the writing steps of a document.
|
||||
|
@ -159,9 +179,7 @@ class Version(models.Model):
|
|||
restricted
|
||||
|
||||
Actors:
|
||||
Validators
|
||||
Writers
|
||||
Reviewers
|
||||
actors
|
||||
"""
|
||||
# instance structure
|
||||
document = models.ForeignKey(Document, related_name='versions')
|
||||
|
@ -181,16 +199,14 @@ class Version(models.Model):
|
|||
nodes = models.ManyToManyField(Node, blank=True)
|
||||
|
||||
# actors
|
||||
authors = models.ManyToManyField(User, related_name='versions_as_author')
|
||||
reviewers = models.ManyToManyField(User, related_name='versions_as_reviewer')
|
||||
validators = models.ManyToManyField(User, related_name='versions_as_validator')
|
||||
actors = models.ManyToManyField(User, related_name='versions', through='Role')
|
||||
|
||||
@reversion.create_revision()
|
||||
def publish(self):
|
||||
"""Starts a new publication process, based on the people set as `validators`.
|
||||
"""Starts a new publication process, based on the people set with a role `validator`.
|
||||
|
||||
If the current version has not been published yet, this method checks that
|
||||
there are people in the `validators` fields and assign a task to each one of them.
|
||||
there are people in the role `validator` and assign a task to each one of them.
|
||||
|
||||
:exception
|
||||
ActorException: when no validator has been set.
|
||||
|
|
Loading…
Reference in New Issue