mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 03:17:07 +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'),
|
('people', '0024_remove_age_gender'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
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'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ class Person(models.Model):
|
|||||||
'self',
|
'self',
|
||||||
related_name='relationship_sources',
|
related_name='relationship_sources',
|
||||||
through='Relationship',
|
through='Relationship',
|
||||||
through_fields=('source', 'target_person'),
|
through_fields=('source', 'target'),
|
||||||
symmetrical=False)
|
symmetrical=False)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class Relationship(models.Model):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
constraints = [
|
constraints = [
|
||||||
models.UniqueConstraint(fields=['source', 'target_person'],
|
models.UniqueConstraint(fields=['source', 'person'],
|
||||||
name='unique_relationship'),
|
name='unique_relationship'),
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -62,11 +62,11 @@ class Relationship(models.Model):
|
|||||||
blank=False, null=False)
|
blank=False, null=False)
|
||||||
|
|
||||||
#: Person with whom the relationship is reported
|
#: Person with whom the relationship is reported
|
||||||
target_person = models.ForeignKey(Person,
|
target = models.ForeignKey(Person,
|
||||||
related_name='relationships_as_target',
|
related_name='relationships_as_target',
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
blank=False,
|
blank=False,
|
||||||
null=False)
|
null=False)
|
||||||
# blank=True,
|
# blank=True,
|
||||||
# null=True)
|
# null=True)
|
||||||
|
|
||||||
@@ -83,13 +83,6 @@ class Relationship(models.Model):
|
|||||||
#: When was this marked as expired? Default None means it has not expired
|
#: When was this marked as expired? Default None means it has not expired
|
||||||
expired = models.DateTimeField(blank=True, null=True)
|
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
|
@property
|
||||||
def current_answers(self) -> 'RelationshipAnswerSet':
|
def current_answers(self) -> 'RelationshipAnswerSet':
|
||||||
return self.answer_sets.last()
|
return self.answer_sets.last()
|
||||||
@@ -107,8 +100,8 @@ class Relationship(models.Model):
|
|||||||
|
|
||||||
@raise Relationship.DoesNotExist: When the reverse relationship is not known
|
@raise Relationship.DoesNotExist: When the reverse relationship is not known
|
||||||
"""
|
"""
|
||||||
return type(self).objects.get(source=self.target_person,
|
return type(self).objects.get(source=self.target,
|
||||||
target_person=self.source)
|
target=self.source)
|
||||||
|
|
||||||
|
|
||||||
class RelationshipAnswerSet(AnswerSet):
|
class RelationshipAnswerSet(AnswerSet):
|
||||||
|
|||||||
Reference in New Issue
Block a user