Skip to content

Commit ca67643

Browse files
committed
move the validation on the mixin
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent c92b446 commit ca67643

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

vulnerabilities/models.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,21 @@ class Response(models.TextChoices):
345345
),
346346
)
347347

348+
def save(self, *args, **kwargs):
349+
# At least one of those fields must be provided.
350+
main_fields = [
351+
self.state,
352+
self.justification,
353+
self.responses,
354+
self.detail,
355+
]
356+
if not any(main_fields):
357+
raise ValueError(
358+
"At least one of state, justification, responses or detail must be provided."
359+
)
360+
361+
super().save(*args, **kwargs)
362+
348363
class Meta:
349364
abstract = True
350365

@@ -364,21 +379,6 @@ class VulnerabilityAnalysisMixin(VulnerabilityAnalysisContentMixin):
364379
class Meta:
365380
abstract = True
366381

367-
def save(self, *args, **kwargs):
368-
# At least one of those fields must be provided.
369-
main_fields = [
370-
self.state,
371-
self.justification,
372-
self.responses,
373-
self.detail,
374-
]
375-
if not any(main_fields):
376-
raise ValueError(
377-
"At least one of state, justification, responses or detail must be provided."
378-
)
379-
380-
super().save(*args, **kwargs)
381-
382382
def as_cyclonedx(self):
383383
state = None
384384
if self.state:

0 commit comments

Comments
 (0)