@@ -2258,9 +2258,9 @@ def create_new_job(self, execute_now=False):
22582258 schedules .clear_job (self .schedule_work_id )
22592259
22602260 return schedules .schedule_execution (self , execute_now ) if self .is_active else None
2261- class AdvisoryTODO (models .Model ):
2262- """Track the TODOs for advisory/ies that need to be addressed."""
22632261
2262+
2263+ class AdvisoryTODO (models .Model ):
22642264 ISSUE_TYPE_CHOICES = [
22652265 ("MISSING_AFFECTED_PACKAGE" , "Advisory is missing affected package" ),
22662266 ("MISSING_FIXED_BY_PACKAGE" , "Advisory is missing fixed-by package" ),
@@ -2278,6 +2278,20 @@ class AdvisoryTODO(models.Model):
22782278 ("CONFLICTING_SEVERITY_SCORES" , "Advisories have conflicting severity scores" ),
22792279 ]
22802280
2281+
2282+ class AdvisoryToDo (models .Model ):
2283+ """Track the TODOs for advisory/ies that need to be addressed."""
2284+
2285+ # Since we can not make advisories field (M2M field) unique
2286+ # (see https://code.djangoproject.com/ticket/702), we use related_advisories_id
2287+ # to avoid creating duplicate issue for same set of advisories,
2288+ related_advisories_id = models .CharField (
2289+ max_length = 40 ,
2290+ blank = False ,
2291+ null = False ,
2292+ help_text = "SHA1 digest of the unique_content_id field of the applicable advisories." ,
2293+ )
2294+
22812295 issue_type = models .CharField (
22822296 max_length = 50 ,
22832297 choices = ISSUE_TYPE_CHOICES ,
@@ -2286,9 +2300,11 @@ class AdvisoryTODO(models.Model):
22862300 db_index = True ,
22872301 help_text = "Select the issue that needs to be addressed from the available options." ,
22882302 )
2303+
22892304 issue_detail = models .TextField (
22902305 help_text = "Additional details about the issue." ,
22912306 )
2307+
22922308 advisories = models .ManyToManyField (
22932309 Advisory ,
22942310 related_name = "advisory_todos" ,
@@ -2313,3 +2329,6 @@ class AdvisoryTODO(models.Model):
23132329 resolution_detail = models .TextField (
23142330 help_text = "Additional detail on how this TODO was resolved." ,
23152331 )
2332+
2333+ class Meta :
2334+ unique_together = ("related_advisories_id" , "issue_type" )
0 commit comments