--- a/src/iconolab/models.py Thu Dec 15 16:35:01 2016 +0100
+++ b/src/iconolab/models.py Fri Dec 16 11:35:10 2016 +0100
@@ -313,7 +313,17 @@
that will be displayed by default in most pages.
Annotation data (title, description, fragment) is thus stored in the revision.
+
+ Annotations can be considered validated or not depending on the metacategories posted in their comments through the attribute validation_state. Their validation state
+ can also be overriden and in such case we can use validation_state_overriden attribute to remember it in the model (so for instance if an admin un-validates an annotation
+ we could block it from being validated again)
"""
+ UNVALIDATED = 0
+ VALIDATED = 1
+ VALIDATION_STATES = (
+ (UNVALIDATED, 'unvalidated'),
+ (VALIDATED, 'validated'),
+ )
annotation_guid = models.UUIDField(default=uuid.uuid4, editable=False)
image = models.ForeignKey('Image', related_name='annotations', on_delete=models.CASCADE)
source_revision = models.ForeignKey('AnnotationRevision', related_name='source_related_annotation', blank=True, null=True)
@@ -321,6 +331,8 @@
author = models.ForeignKey(User, null=True)
created = models.DateTimeField(auto_now_add=True, null=True)
comments = GenericRelation('IconolabComment', content_type_field='content_type_id', object_id_field='object_pk')
+ validation_state = models.IntegerField(choices=VALIDATION_STATES, default=UNVALIDATED)
+ validation_state_overriden = models.BooleanField(default=False)
objects = AnnotationManager()
@@ -769,12 +781,18 @@
- CONTRIBUTORS : Notifies contributors (revision owners) on target annotation
- COMMENTERS : Notifies commenters (contributors + comment owners) on target annotation
- COLLECTION_ADMINS : Notifies collection admins
+
+ Metacategories can be used to consider an annotation as "validated" if a certain agreement threshold is reached using their validation_value property
+
+ - NEUTRAL : The metacategory doesn't affect the validation state
+ - AGREEMENT : The metacategory can be used to validate the annotation when linked to a comment on said annotation
+ - DISAGREEMENT : The metacategory can be used to unvalidate the annotation when linked to a comment on said annotation
+
"""
NONE = 0
CONTRIBUTORS = 1
COMMENTERS = 2
COLLECTION_ADMINS = 3
-
NOTIFIED_USERS = (
(NONE, 'none'),
(CONTRIBUTORS, 'contributors'),
@@ -782,9 +800,19 @@
(COLLECTION_ADMINS, 'collection admins'),
)
+ NEUTRAL = 0
+ AGREEMENT = 1
+ DISAGREEMENT = 2
+ VALIDATION_VALUES = (
+ (NEUTRAL, 'neutral'),
+ (AGREEMENT, 'agreement'),
+ (DISAGREEMENT, 'disagreement'),
+ )
+
collection = models.ForeignKey(Collection, related_name="metacategories")
label = models.CharField(max_length=255)
triggers_notifications = models.IntegerField(choices=NOTIFIED_USERS, default=NONE)
+ validation_value = models.IntegerField(choices=VALIDATION_VALUES, default=NEUTRAL)
def __str__(self):
return self.label