firefighter-incident 0.0.35__py3-none-any.whl → 0.0.37__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
firefighter/_version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.0.35'
32
- __version_tuple__ = version_tuple = (0, 0, 35)
31
+ __version__ = version = '0.0.37'
32
+ __version_tuple__ = version_tuple = (0, 0, 37)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -204,11 +204,7 @@ class Incident(models.Model):
204
204
  null=True,
205
205
  blank=True,
206
206
  )
207
- severity.system_check_deprecated_details = {
208
- "msg": "The Incident.severity field has been deprecated.",
209
- "hint": "Use Incident.priority instead.",
210
- "id": "fields.W921",
211
- }
207
+ severity.system_check_deprecated_details = None
212
208
  priority = models.ForeignKey(
213
209
  Priority,
214
210
  on_delete=models.PROTECT,
@@ -292,7 +288,8 @@ class Incident(models.Model):
292
288
  ),
293
289
  models.CheckConstraint(
294
290
  name="%(app_label)s_%(class)s_closure_reason_valid",
295
- check=models.Q(closure_reason__in=[*ClosureReason.values, None]),
291
+ check=models.Q(closure_reason__in=[*ClosureReason.values, ""])
292
+ | models.Q(closure_reason__isnull=True),
296
293
  ),
297
294
  ]
298
295
 
@@ -418,14 +415,17 @@ class Incident(models.Model):
418
415
  f"Incident is not in {IncidentStatus.MITIGATED.label} status (currently {self.status.label}).",
419
416
  )
420
417
  )
421
- missing_milestones = self.missing_milestones()
422
- if len(missing_milestones) > 0:
423
- cant_closed_reasons.append(
424
- (
425
- "MISSING_REQUIRED_KEY_EVENTS",
426
- f"Missing key events: {', '.join(missing_milestones)}",
418
+ # Require key events only for P1-P3; P4+ can close without them.
419
+ require_milestones = not (self.priority and self.priority.value >= 4)
420
+ if require_milestones:
421
+ missing_milestones = self.missing_milestones()
422
+ if len(missing_milestones) > 0:
423
+ cant_closed_reasons.append(
424
+ (
425
+ "MISSING_REQUIRED_KEY_EVENTS",
426
+ f"Missing key events: {', '.join(missing_milestones)}",
427
+ )
427
428
  )
428
- )
429
429
 
430
430
  if len(cant_closed_reasons) > 0:
431
431
  return False, cant_closed_reasons
@@ -644,8 +644,20 @@ class Incident(models.Model):
644
644
  _update_incident_field(self, "description", description, updated_fields)
645
645
  _update_incident_field(self, "environment_id", environment_id, updated_fields)
646
646
 
647
+ skip_priority_sync = "priority_id" in updated_fields
648
+ skip_status_sync = "_status" in updated_fields
649
+
647
650
  if updated_fields:
651
+ # Mark to skip post_save priority sync (prevents double push to Jira)
652
+ if skip_priority_sync:
653
+ self._skip_priority_sync = True
654
+ if skip_status_sync:
655
+ self._skip_status_sync = True
648
656
  self.save(update_fields=[*updated_fields, "updated_at"])
657
+ if skip_priority_sync and hasattr(self, "_skip_priority_sync"):
658
+ del self._skip_priority_sync
659
+ if skip_status_sync and hasattr(self, "_skip_status_sync"):
660
+ del self._skip_status_sync
649
661
 
650
662
  if not (updated_fields or message):
651
663
  raise ValueError("No updated fields or message provided.")
@@ -58,11 +58,7 @@ class IncidentUpdate(models.Model):
58
58
  on_delete=models.SET(Severity.get_default),
59
59
  help_text="Superseded by priority",
60
60
  )
61
- severity.system_check_deprecated_details = {
62
- "msg": "The IncidentUpdate.severity field has been deprecated.",
63
- "hint": "Use IncidentUpdate.priority instead.",
64
- "id": "fields.W920",
65
- }
61
+ severity.system_check_deprecated_details = None
66
62
  priority = models.ForeignKey(
67
63
  Priority, null=True, blank=True, on_delete=models.SET(Priority.get_default)
68
64
  )
@@ -72,9 +68,7 @@ class IncidentUpdate(models.Model):
72
68
  blank=True,
73
69
  on_delete=models.SET(Environment.get_default),
74
70
  )
75
- incident = models.ForeignKey(
76
- "Incident", on_delete=models.CASCADE
77
- )
71
+ incident = models.ForeignKey("Incident", on_delete=models.CASCADE)
78
72
  incident_category = models.ForeignKey(
79
73
  IncidentCategory, null=True, blank=True, on_delete=models.SET_NULL
80
74
  )