SciPost Code Repository

Skip to content
Snippets Groups Projects
models.py 1.82 KiB
Newer Older
__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
Jorran de Wit's avatar
Jorran de Wit committed
__license__ = "AGPL v3"


Jorran de Wit's avatar
COI
Jorran de Wit committed
from django.db import models

Jorran de Wit's avatar
Jorran de Wit committed
from .managers import ConflictOfInterestQuerySet


Jorran de Wit's avatar
COI
Jorran de Wit committed
class ConflictOfInterest(models.Model):
Jorran de Wit's avatar
Jorran de Wit committed
    """
    A flagged relation between two scientists that could be conflicting in a refereeing
    phase.
    """
    STATUS_UNVERIFIED, STATUS_VERIFIED = 'unverified', 'verified'
    STATUS_DEPRECATED = 'deprecated'
    CONFLICT_OF_INTEREST_STATUSES = (
        (STATUS_UNVERIFIED, 'Unverified'),
        (STATUS_VERIFIED, 'Verified by Admin'),
        (STATUS_DEPRECATED, 'Deprecated'),
    )

    TYPE_OTHER, TYPE_COAUTHOR, TYPE_COWORKER = 'other', 'coauthor', 'coworker'
    COI_TYPES = (
        (TYPE_COWORKER, 'Co-worker'),
        (TYPE_COAUTHOR, 'Co-authorship'),
        (TYPE_OTHER, 'Other'),
    )
Jorran de Wit's avatar
COI
Jorran de Wit committed

    status = models.CharField(
Jorran de Wit's avatar
Jorran de Wit committed
         max_length=16, choices=CONFLICT_OF_INTEREST_STATUSES, default=STATUS_UNVERIFIED)
    type = models.CharField(max_length=16, choices=COI_TYPES, default=TYPE_OTHER)
    profile = models.ForeignKey('profiles.Profile',
                                on_delete=models.CASCADE, related_name='conflicts')
    related_profile = models.ForeignKey('profiles.Profile',
                                        on_delete=models.CASCADE, related_name='+')
Jorran de Wit's avatar
Jorran de Wit committed

Jorran de Wit's avatar
Jorran de Wit committed
    # To
    related_submissions = models.ManyToManyField(
        'submissions.Submission', blank=True, related_name='conflict_of_interests')

Jorran de Wit's avatar
Jorran de Wit committed
    header = models.CharField(max_length=265)
    url = models.URLField(blank=True)
    comment = models.TextField(blank=True)
Jorran de Wit's avatar
Jorran de Wit committed

Jorran de Wit's avatar
Jorran de Wit committed
    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)

Jorran de Wit's avatar
Jorran de Wit committed
    objects = ConflictOfInterestQuerySet.as_manager()

Jorran de Wit's avatar
Jorran de Wit committed
    def __str__(self):
Jorran de Wit's avatar
Jorran de Wit committed
        return '{} - {} ({})'.format(self.profile, self.related_profile, self.get_type_display())