Skip to content

Commit bb324e4

Browse files
committed
Add Curator model and link curation advisories to curators
Reference: #2442 Signed-off-by: Pooja Thamb <poojathamb@gmail.com>
1 parent c4e58d3 commit bb324e4

3 files changed

Lines changed: 93 additions & 0 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Generated by Django 5.2.11 on 2026-10-08 03:37
2+
3+
import django.db.models.deletion
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
(
11+
"vulnerabilities",
12+
"0143_remove_impactedpackageaffecting_vulnerabili_impacte_1904b9_idx_and_more",
13+
),
14+
]
15+
16+
operations = [
17+
migrations.CreateModel(
18+
name="Curator",
19+
fields=[
20+
(
21+
"id",
22+
models.AutoField(
23+
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
24+
),
25+
),
26+
(
27+
"name",
28+
models.CharField(help_text="Name of the curator.", max_length=100, unique=True),
29+
),
30+
(
31+
"created_at",
32+
models.DateTimeField(
33+
auto_now_add=True,
34+
help_text="Timestamp indicating when this curator was added.",
35+
),
36+
),
37+
],
38+
),
39+
migrations.AddField(
40+
model_name="advisoryv2",
41+
name="curator",
42+
field=models.ForeignKey(
43+
blank=True,
44+
help_text="The curator who submitted this curation advisory.",
45+
null=True,
46+
on_delete=django.db.models.deletion.SET_NULL,
47+
related_name="curations",
48+
to="vulnerabilities.curator",
49+
),
50+
),
51+
]

‎vulnerabilities/models.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,6 +2923,24 @@ def to_dict(self):
29232923
}
29242924

29252925

2926+
class Curator(models.Model):
2927+
"""A person who submits curations for advisories."""
2928+
2929+
name = models.CharField(
2930+
max_length=100,
2931+
unique=True,
2932+
help_text="Name of the curator.",
2933+
)
2934+
2935+
created_at = models.DateTimeField(
2936+
auto_now_add=True,
2937+
help_text="Timestamp indicating when this curator was added.",
2938+
)
2939+
2940+
def __str__(self):
2941+
return self.name
2942+
2943+
29262944
class AdvisoryV2QuerySet(BaseQuerySet):
29272945
def latest_for_avid(self, avid: str):
29282946
try:
@@ -3229,6 +3247,15 @@ class AdvisoryV2(models.Model):
32293247
help_text="Indicates whether this is a curation advisory.",
32303248
)
32313249

3250+
curator = models.ForeignKey(
3251+
Curator,
3252+
null=True,
3253+
blank=True,
3254+
on_delete=models.SET_NULL,
3255+
related_name="curations",
3256+
help_text="The curator who submitted this curation advisory.",
3257+
)
3258+
32323259
date_published = models.DateTimeField(
32333260
blank=True,
32343261
null=True,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import pytest
2+
3+
from vulnerabilities.models import Curator
4+
5+
6+
@pytest.mark.django_db
7+
def test_curator_str_returns_name():
8+
curator = Curator.objects.create(name="John")
9+
assert str(curator) == "John"
10+
11+
12+
@pytest.mark.django_db
13+
def test_curator_has_no_curations_by_default():
14+
curator = Curator.objects.create(name="John")
15+
assert curator.curations.count() == 0

0 commit comments

Comments
 (0)