mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 03:17:07 +00:00
refactor: views to handled ended relationships
Add ending of organisation relationships
This commit is contained in:
@@ -61,9 +61,14 @@ class Relationship(models.Model):
|
||||
|
||||
@property
|
||||
def current_answers(self) -> typing.Optional['RelationshipAnswerSet']:
|
||||
answer_set = self.answer_sets.latest()
|
||||
if answer_set.is_current:
|
||||
return answer_set
|
||||
try:
|
||||
answer_set = self.answer_sets.latest()
|
||||
if answer_set.is_current:
|
||||
return answer_set
|
||||
|
||||
except RelationshipAnswerSet.DoesNotExist:
|
||||
# No AnswerSet created yet
|
||||
pass
|
||||
|
||||
return None
|
||||
|
||||
@@ -145,9 +150,14 @@ class OrganisationRelationship(models.Model):
|
||||
|
||||
@property
|
||||
def current_answers(self) -> typing.Optional['OrganisationRelationshipAnswerSet']:
|
||||
answer_set = self.answer_sets.latest()
|
||||
if answer_set.is_current:
|
||||
return answer_set
|
||||
try:
|
||||
answer_set = self.answer_sets.latest()
|
||||
if answer_set.is_current:
|
||||
return answer_set
|
||||
|
||||
except OrganisationRelationshipAnswerSet.DoesNotExist:
|
||||
# No AnswerSet created yet
|
||||
pass
|
||||
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user