chore: use more expressive related_name

This commit is contained in:
Robert Sparks 2023-06-16 15:26:52 -05:00
parent f3566c2743
commit d6f58b3e67
No known key found for this signature in database
GPG key ID: 6E2A6A5775F91318
4 changed files with 5 additions and 5 deletions

View file

@ -49,7 +49,7 @@ class Migration(migrations.Migration):
field=ietf.utils.models.ForeignKey(
default=1, # A lie, but a convenient one - no relations point here.
on_delete=django.db.models.deletion.CASCADE,
related_name="target",
related_name="targets_related",
to="doc.document",
db_index=False,
),
@ -61,7 +61,7 @@ class Migration(migrations.Migration):
name="target",
field=ietf.utils.models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="target",
related_name="targets_related",
to="doc.document",
db_index=True,
),

View file

@ -667,7 +667,7 @@ STATUSCHANGE_RELATIONS = ('tops','tois','tohist','toinf','tobcp','toexp')
class RelatedDocument(models.Model):
source = ForeignKey('Document')
target = ForeignKey('Document', related_name='target')
target = ForeignKey('Document', related_name='targets_related')
relationship = ForeignKey(DocRelationshipName)
def action(self):
return self.relationship.name

View file

@ -416,7 +416,7 @@ def start_review_sanity_check(request, name):
raise Http404
# sanity check that there's not already a conflict review document for this document
if [ rel.source for rel in doc_to_review.target.filter(relationship='conflrev') ]: # TODO whould be targets or targets_related
if [ rel.source for rel in doc_to_review.targets_related.filter(relationship='conflrev') ]:
raise Http404
return doc_to_review

View file

@ -673,7 +673,7 @@ def edit_info(request, name):
e.save()
events.append(e)
replaces = Document.objects.filter(target__source=doc, target__relationship="replaces") # TODO: again target needs to change
replaces = Document.objects.filter(targets_related__source=doc, targets_related__relationship="replaces")
if replaces:
# this should perhaps be somewhere else, e.g. the
# place where the replace relationship is established?