-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
87 lines (76 loc) · 2.35 KB
/
models.py
File metadata and controls
87 lines (76 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from django.db import models
from django.utils import timezone
CLAIM_STATUS_CHOICES = (
('pending', 'Pending'),
('confirmed', 'Confirmed'),
('rejected', 'Rejected'),
('withdrawn', 'Withdrawn'),
)
class VAEPoolMember(models.Model):
"""Tracks which accounts are in the VAE pool for a given journal."""
journal = models.ForeignKey(
'journal.Journal',
on_delete=models.CASCADE,
)
account = models.ForeignKey(
'core.Account',
on_delete=models.CASCADE,
related_name='vae_pool_memberships',
)
added = models.DateTimeField(default=timezone.now)
added_by = models.ForeignKey(
'core.Account',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='vae_pool_additions',
)
class Meta:
unique_together = ('journal', 'account')
ordering = ('account__last_name', 'account__first_name')
def __str__(self):
return '{} — {}'.format(self.journal.code, self.account.full_name())
class EditorClaim(models.Model):
"""A VAE's claim on an article."""
article = models.ForeignKey(
'submission.Article',
on_delete=models.CASCADE,
related_name='vae_claims',
)
claimed_by = models.ForeignKey(
'core.Account',
on_delete=models.CASCADE,
related_name='vae_claims_made',
)
date_claimed = models.DateTimeField(default=timezone.now)
status = models.CharField(
max_length=20,
choices=CLAIM_STATUS_CHOICES,
default='pending',
)
notes = models.TextField(
blank=True,
default='',
help_text='Optional notes from the VAE about why they are claiming this article.',
)
date_resolved = models.DateTimeField(null=True, blank=True)
resolved_by = models.ForeignKey(
'core.Account',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='vae_claims_resolved',
)
class Meta:
ordering = ('date_claimed',)
def __str__(self):
return 'Claim by {} on article #{} ({})'.format(
self.claimed_by.full_name(),
self.article.pk,
self.status,
)
def resolve(self, status, resolved_by):
self.status = status
self.date_resolved = timezone.now()
self.resolved_by = resolved_by
self.save()