mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 11:27:09 +00:00
fix: revert relationship link change
Fixes issue where migrations will not run on MySQL
This commit is contained in:
@@ -9,18 +9,4 @@ class Migration(migrations.Migration):
|
||||
('people', '0024_remove_age_gender'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveConstraint(
|
||||
model_name='relationship',
|
||||
name='unique_relationship',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='relationship',
|
||||
old_name='target',
|
||||
new_name='target_person',
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='relationship',
|
||||
constraint=models.UniqueConstraint(fields=('source', 'target_person'), name='unique_relationship'),
|
||||
),
|
||||
]
|
||||
operations = []
|
||||
|
||||
@@ -119,7 +119,7 @@ class Person(models.Model):
|
||||
'self',
|
||||
related_name='relationship_sources',
|
||||
through='Relationship',
|
||||
through_fields=('source', 'target_person'),
|
||||
through_fields=('source', 'target'),
|
||||
symmetrical=False)
|
||||
|
||||
@property
|
||||
|
||||
@@ -52,7 +52,7 @@ class Relationship(models.Model):
|
||||
|
||||
class Meta:
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=['source', 'target_person'],
|
||||
models.UniqueConstraint(fields=['source', 'person'],
|
||||
name='unique_relationship'),
|
||||
]
|
||||
|
||||
@@ -62,11 +62,11 @@ class Relationship(models.Model):
|
||||
blank=False, null=False)
|
||||
|
||||
#: Person with whom the relationship is reported
|
||||
target_person = models.ForeignKey(Person,
|
||||
related_name='relationships_as_target',
|
||||
on_delete=models.CASCADE,
|
||||
blank=False,
|
||||
null=False)
|
||||
target = models.ForeignKey(Person,
|
||||
related_name='relationships_as_target',
|
||||
on_delete=models.CASCADE,
|
||||
blank=False,
|
||||
null=False)
|
||||
# blank=True,
|
||||
# null=True)
|
||||
|
||||
@@ -83,13 +83,6 @@ class Relationship(models.Model):
|
||||
#: When was this marked as expired? Default None means it has not expired
|
||||
expired = models.DateTimeField(blank=True, null=True)
|
||||
|
||||
@property
|
||||
def target(self) -> Person:
|
||||
if self.target_person:
|
||||
return self.target_person
|
||||
|
||||
raise ObjectDoesNotExist('Relationship has no target linked')
|
||||
|
||||
@property
|
||||
def current_answers(self) -> 'RelationshipAnswerSet':
|
||||
return self.answer_sets.last()
|
||||
@@ -107,8 +100,8 @@ class Relationship(models.Model):
|
||||
|
||||
@raise Relationship.DoesNotExist: When the reverse relationship is not known
|
||||
"""
|
||||
return type(self).objects.get(source=self.target_person,
|
||||
target_person=self.source)
|
||||
return type(self).objects.get(source=self.target,
|
||||
target=self.source)
|
||||
|
||||
|
||||
class RelationshipAnswerSet(AnswerSet):
|
||||
|
||||
Reference in New Issue
Block a user