Move model save() method to conventional location
By convention we put fields first, meta and then methods.
@@ -330,14 +330,6 @@ class Advisory(models.Model):
into structured data
"""
- def save(self, *args, **kwargs):
- checksum = hashlib.md5()
- for field in (self.summary, self.affected_packages, self.references):
- value = json.dumps(field, separators=(",", ":")).encode("utf-8")
- checksum.update(value)
- self.unique_content_id = checksum.hexdigest()
- super().save(*args, **kwargs)
-
unique_content_id = models.CharField(max_length=32, blank=True, null=True)
aliases = models.JSONField(blank=True, default=list, help_text="A list of alias strings")
summary = models.TextField(blank=True, null=True)
@@ -373,6 +365,14 @@ class Advisory(models.Model):
"date_published",
)
+ def save(self, *args, **kwargs):
+ checksum = hashlib.md5()
+ for field in (self.summary, self.affected_packages, self.references):
+ value = json.dumps(field, separators=(",", ":")).encode("utf-8")
+ checksum.update(value)
+ self.unique_content_id = checksum.hexdigest()
+ super().save(*args, **kwargs)
+
def to_advisory_data(self) -> AdvisoryData:
return AdvisoryData(
aliases=self.aliases,
