-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmodels.py
More file actions
79 lines (63 loc) · 2.61 KB
/
Copy pathmodels.py
File metadata and controls
79 lines (63 loc) · 2.61 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
"""
Models per docs/Schema.md section 7: WG21 Papers Tracker.
References cppa_user_tracker.WG21PaperAuthorProfile (section 1) as author.
"""
from django.db import models
class WG21Mailing(models.Model):
"""WG21 mailing release (mailing_date, title)."""
mailing_date = models.CharField(max_length=7, unique=True, db_index=True)
title = models.CharField(max_length=255)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
ordering = ["-mailing_date"]
verbose_name = "WG21 Mailing"
verbose_name_plural = "WG21 Mailings"
def __str__(self):
return f"{self.mailing_date} ({self.title})"
class WG21Paper(models.Model):
"""WG21 paper (paper_id, url, title, document_date, year, mailing, subgroup, is_downloaded)."""
paper_id = models.CharField(max_length=255, db_index=True)
url = models.URLField(max_length=1024)
title = models.CharField(max_length=1024, db_index=True)
document_date = models.DateField(db_index=True, null=True, blank=True)
year = models.IntegerField(default=0, db_index=True)
mailing = models.ForeignKey(
WG21Mailing,
on_delete=models.CASCADE,
related_name="papers",
)
subgroup = models.CharField(max_length=255, blank=True, db_index=True)
is_downloaded = models.BooleanField(default=False, db_index=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
unique_together = [["paper_id", "year"]]
ordering = ["-document_date", "-paper_id", "-year"]
verbose_name = "WG21 Paper"
verbose_name_plural = "WG21 Papers"
def __str__(self):
return f"{self.paper_id}: {self.title[:60]}"
class WG21PaperAuthor(models.Model):
"""Paper-author link (paper_id, profile_id->WG21PaperAuthorProfile)."""
paper = models.ForeignKey(
WG21Paper,
on_delete=models.CASCADE,
related_name="authors",
db_column="paper_id",
)
profile = models.ForeignKey(
"cppa_user_tracker.WG21PaperAuthorProfile",
on_delete=models.CASCADE,
related_name="papers",
db_column="profile_id",
)
author_order = models.PositiveIntegerField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
unique_together = (("paper", "profile"),)
ordering = ["id"]
verbose_name = "WG21 Paper Author"
verbose_name_plural = "WG21 Paper Authors"
def __str__(self):
return f"{self.paper.paper_id} - {self.profile.display_name}"