diff --git a/conservancy/usethesource/models.py b/conservancy/usethesource/models.py index 84afcf204a42e08127ef57e80f3ff937230fe7f9..70b05b0cae7da8b197c6b120698865185d6d8acf 100644 --- a/conservancy/usethesource/models.py +++ b/conservancy/usethesource/models.py @@ -4,6 +4,11 @@ from django.contrib.auth.models import User from django.db import models +def gen_message_id(): + """Generate a time-based identifier for use in "In-Reply-To" header.""" + return f'<{uuid.uuid1()}@sfconservancy.org>' + + class Candidate(models.Model): """A source/binary release we'd like to verify CCS status of.""" @@ -16,6 +21,7 @@ class Candidate(models.Model): source_url = models.URLField() binary_url = models.URLField(blank=True) ordering = models.SmallIntegerField(default=0) + email_message_id = models.CharField(max_length=255, default=gen_message_id) class Meta: ordering = ['ordering', 'name'] @@ -24,11 +30,6 @@ class Candidate(models.Model): return self.name -def gen_message_id(): - """Generate a time-based identifier for use in "In-Reply-To" header.""" - return f'<{uuid.uuid1()}@sfconservancy.org>' - - class Comment(models.Model): """A comment about experiences or learnings building the candidate.""" @@ -48,14 +49,14 @@ class Comment(models.Model): return None def in_reply_to(self): - """Determine the message_id of the previous comment. + """Determine the message_id of the previous comment or the candidate. Used for email threading. """ if prev_comment := self._find_previous_comment(): return prev_comment.email_message_id else: - return None + return self.candidate.email_message_id class Meta: ordering = ['id']