feat: add view to end relationship

This commit is contained in:
James Graham
2021-03-19 12:00:32 +00:00
parent 8093b23870
commit 42d95beb5a
10 changed files with 160 additions and 19 deletions

View File

@@ -124,6 +124,7 @@ class AnswerSet(models.Model):
ordering = [
'timestamp',
]
get_latest_by = 'timestamp'
#: Entity to which this answer set belongs
#: This foreign key must be added to each concrete subclass
@@ -145,6 +146,10 @@ class AnswerSet(models.Model):
null=True,
editable=False)
@property
def is_current(self) -> bool:
return self.replaced_timestamp is None
def as_dict(self, answers: typing.Optional[typing.Dict[str, typing.Any]] = None):
"""Get the answers from this set as a dictionary for use in Form.initial."""
if answers is None: