@@ -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
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 self.candidate.email_message_id
ordering = ['id']