Skip to content

Commit 8ff1441

Browse files
committed
chore: continued refactoring
1 parent d6f58b3 commit 8ff1441

11 files changed

Lines changed: 40 additions & 41 deletions

File tree

ietf/doc/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ def related_ipr(self):
969969
iprs = (
970970
IprDocRel.objects.filter(
971971
document__in=list(self.docalias.all())
972-
+ [x.docalias.first() for x in self.all_related_that_doc(("obs", "replaces"))]
972+
+ [x.docalias.first() for x in self.all_related_that_doc(("obs", "replaces"))] # this really is docalias until IprDocRel changes
973973
)
974974
.filter(disclosure__state__in=("posted", "removed"))
975975
.values_list("disclosure", flat=True)

ietf/doc/tests_draft.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,7 +2034,7 @@ def test_change_replaces(self):
20342034
# Post that says replaceboth replaces both base a and base b
20352035
url = urlreverse('ietf.doc.views_draft.replaces', kwargs=dict(name=self.replaceboth.name))
20362036
self.assertEqual(self.baseb.get_state().slug,'expired')
2037-
r = self.client.post(url, dict(replaces=[self.basea.docalias.first().pk, self.baseb.docalias.first().pk]))
2037+
r = self.client.post(url, dict(replaces=[self.basea.pk, self.baseb.pk]))
20382038
self.assertEqual(r.status_code, 302)
20392039
self.assertEqual(Document.objects.get(name='draft-test-base-a').get_state().slug,'repl')
20402040
self.assertEqual(Document.objects.get(name='draft-test-base-b').get_state().slug,'repl')
@@ -2093,7 +2093,7 @@ def test_stream_state_changes_when_replaced(self):
20932093
new_doc = IndividualDraftFactory(stream_id=stream)
20942094

20952095
url = urlreverse('ietf.doc.views_draft.replaces', kwargs=dict(name=new_doc.name))
2096-
r = self.client.post(url, dict(replaces=old_doc.docalias.first().pk))
2096+
r = self.client.post(url, dict(replaces=old_doc.pk))
20972097
self.assertEqual(r.status_code,302)
20982098
old_doc = Document.objects.get(name=old_doc.name)
20992099
self.assertEqual(old_doc.get_state_slug('draft'),'repl')

ietf/doc/tests_review.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ def test_doc_page(self):
153153
# check we can fish it out
154154
old_doc = WgDraftFactory(name="draft-foo-mars-test")
155155
older_doc = WgDraftFactory(name="draft-older")
156-
RelatedDocument.objects.create(source=old_doc, target=older_doc.docalias.first(), relationship_id='replaces')
157-
RelatedDocument.objects.create(source=doc, target=old_doc.docalias.first(), relationship_id='replaces')
156+
RelatedDocument.objects.create(source=old_doc, target=older_doc, relationship_id='replaces')
157+
RelatedDocument.objects.create(source=doc, target=old_doc, relationship_id='replaces')
158158
review_req.doc = older_doc
159159
review_req.save()
160160

ietf/doc/tests_status_change.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from django.urls import reverse as urlreverse
1616

1717
from ietf.doc.factories import DocumentFactory, IndividualRfcFactory, WgRfcFactory
18-
from ietf.doc.models import ( Document, DocAlias, State, DocEvent,
18+
from ietf.doc.models import ( Document, State, DocEvent,
1919
BallotPositionDocEvent, NewRevisionDocEvent, TelechatDocEvent, WriteupDocEvent )
2020
from ietf.doc.utils import create_ballot_if_not_open
2121
from ietf.doc.views_status_change import default_approval_text
@@ -74,7 +74,7 @@ def test_start_review(self):
7474
self.assertEqual(status_change.rev,'00')
7575
self.assertEqual(status_change.ad.name,'Areað Irector')
7676
self.assertEqual(status_change.notify,'ipu@ietf.org')
77-
self.assertTrue(status_change.relateddocument_set.filter(relationship__slug='tois',target__name='draft-ietf-random-thing'))
77+
self.assertTrue(status_change.relateddocument_set.filter(relationship__slug='tois',target__name='rfc9999'))
7878

7979
# Verify that it's possible to start a status change without a responsible ad.
8080
r = self.client.post(url,dict(
@@ -159,8 +159,8 @@ def test_edit_notices(self):
159159
self.assertTrue(doc.latest_event(DocEvent,type="added_comment").desc.startswith('Notification list changed'))
160160

161161
# Some additional setup so there's something to put in a generated notify list
162-
doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc9999'),relationship_id='tois')
163-
doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc9998'),relationship_id='tohist')
162+
doc.relateddocument_set.create(target=Document.objects.get(name='rfc9999'),relationship_id='tois')
163+
doc.relateddocument_set.create(target=Document.objects.get(name='rfc9998'),relationship_id='tohist')
164164

165165
# Ask the form to regenerate the list
166166
r = self.client.post(url,dict(regenerate_addresses="1"))
@@ -263,8 +263,8 @@ def test_edit_lc(self):
263263
login_testing_unauthorized(self, "ad", url)
264264

265265
# additional setup
266-
doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc9999'),relationship_id='tois')
267-
doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc9998'),relationship_id='tohist')
266+
doc.relateddocument_set.create(target=Document.objects.get(name='rfc9999'),relationship_id='tois')
267+
doc.relateddocument_set.create(target=Document.objects.get(name='rfc9998'),relationship_id='tohist')
268268
doc.ad = Person.objects.get(name='Ad No2')
269269
doc.save_with_history([DocEvent.objects.create(doc=doc, rev=doc.rev, type="changed_document", by=Person.objects.get(user__username="secretary"), desc="Test")])
270270

@@ -307,8 +307,8 @@ def test_approve(self):
307307
login_testing_unauthorized(self, "secretary", url)
308308

309309
# Some additional setup
310-
doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc9999'),relationship_id='tois')
311-
doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc9998'),relationship_id='tohist')
310+
doc.relateddocument_set.create(target=Document.objects.get(name='rfc9999'),relationship_id='tois')
311+
doc.relateddocument_set.create(target=Document.objects.get(name='rfc9998'),relationship_id='tohist')
312312
create_ballot_if_not_open(None, doc, Person.objects.get(user__username="secretary"), "statchg")
313313
doc.set_state(State.objects.get(slug='appr-pend',type='statchg'))
314314

@@ -348,10 +348,10 @@ def approval_pend_notice_test_helper(self, role):
348348
url = urlreverse('ietf.doc.views_status_change.change_state',kwargs=dict(name=doc.name))
349349

350350
# Add some status change related documents
351-
doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc9999'),relationship_id='tois')
352-
doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc9998'),relationship_id='tohist')
351+
doc.relateddocument_set.create(target=Document.objects.get(name='rfc9999'),relationship_id='tois')
352+
doc.relateddocument_set.create(target=Document.objects.get(name='rfc9998'),relationship_id='tohist')
353353
# And a non-status change related document
354-
doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc14'),relationship_id='updates')
354+
doc.relateddocument_set.create(target=Document.objects.get(name='rfc14'),relationship_id='updates')
355355

356356
login_testing_unauthorized(self, role, url)
357357
empty_outbox()
@@ -373,9 +373,9 @@ def approval_pend_notice_test_helper(self, role):
373373
self.assertTrue(notification['Subject'].startswith('Approved:'))
374374
notification_text = get_payload_text(notification)
375375
self.assertIn('The AD has approved changing the status', notification_text)
376-
self.assertIn(DocAlias.objects.get(name='rfc9999').document.canonical_name(), notification_text)
377-
self.assertIn(DocAlias.objects.get(name='rfc9998').document.canonical_name(), notification_text)
378-
self.assertNotIn(DocAlias.objects.get(name='rfc14').document.canonical_name(), notification_text)
376+
self.assertIn(Document.objects.get(name='rfc9999').canonical_name(), notification_text)
377+
self.assertIn(Document.objects.get(name='rfc9998').canonical_name(), notification_text)
378+
self.assertNotIn(Document.objects.get(name='rfc14').canonical_name(), notification_text)
379379
self.assertNotIn('No value found for', notification_text) # make sure all interpolation values were set
380380
else:
381381
self.assertEqual(len(outbox), 0)
@@ -395,8 +395,8 @@ def test_edit_relations(self):
395395
login_testing_unauthorized(self, "secretary", url)
396396

397397
# Some additional setup
398-
doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc9999'),relationship_id='tois')
399-
doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc9998'),relationship_id='tohist')
398+
doc.relateddocument_set.create(target=Document.objects.get(name='rfc9999'),relationship_id='tois')
399+
doc.relateddocument_set.create(target=Document.objects.get(name='rfc9998'),relationship_id='tohist')
400400

401401
# get
402402
r = self.client.get(url)
@@ -449,9 +449,9 @@ def verify_relations(doc,target_name,status):
449449

450450
def setUp(self):
451451
super().setUp()
452-
IndividualRfcFactory(alias2__name='rfc14',name='draft-was-never-issued',std_level_id='unkn')
453-
WgRfcFactory(alias2__name='rfc9999',name='draft-ietf-random-thing',std_level_id='ps')
454-
WgRfcFactory(alias2__name='rfc9998',name='draft-ietf-random-other-thing',std_level_id='inf')
452+
IndividualRfcFactory(name='rfc14',std_level_id='unkn')
453+
WgRfcFactory(name='rfc9999',std_level_id='ps')
454+
WgRfcFactory(name='rfc9998',std_level_id='inf')
455455
DocumentFactory(type_id='statchg',name='status-change-imaginary-mid-review',notify='notify@example.org')
456456

457457
class StatusChangeSubmitTests(TestCase):

ietf/doc/tests_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,11 @@ def setUp(self):
328328
self.normative, self.informative, self.unknown = WgRfcFactory.create_batch(3)
329329
for relationship in ['refnorm', 'refinfo', 'refunk', 'refold']:
330330
self.doc.relateddocument_set.create(
331-
target=WgRfcFactory().docalias.first(),
331+
target=WgRfcFactory(),
332332
relationship_id=relationship,
333333
)
334334
self.updated = WgRfcFactory() # related document that should be left alone
335-
self.doc.relateddocument_set.create(target=self.updated.docalias.first(), relationship_id='updates')
335+
self.doc.relateddocument_set.create(target=self.updated, relationship_id='updates')
336336
self.assertCountEqual(self.doc.relateddocument_set.values_list('relationship__slug', flat=True),
337337
['refnorm', 'refinfo', 'refold', 'refunk', 'updates'],
338338
'Test conditions set up incorrectly: wrong prior document relationships')
@@ -389,7 +389,7 @@ def test_xml(self, mock_init, mock_get_refs):
389389
(self.normative.canonical_name(), 'refnorm'),
390390
(self.informative.canonical_name(), 'refinfo'),
391391
(self.unknown.canonical_name(), 'refunk'),
392-
(self.updated.docalias.first().name, 'updates'),
392+
(self.updated.name, 'updates'),
393393
]
394394
)
395395

@@ -420,7 +420,7 @@ def test_plaintext(self, mock_init, mock_get_refs):
420420
(self.normative.canonical_name(), 'refnorm'),
421421
(self.informative.canonical_name(), 'refinfo'),
422422
(self.unknown.canonical_name(), 'refunk'),
423-
(self.updated.docalias.first().name, 'updates'),
423+
(self.updated.name, 'updates'),
424424
]
425425
)
426426

@@ -452,6 +452,6 @@ def test_xml_and_plaintext(self, mock_init, mock_get_refs, mock_plaintext_init):
452452
(self.normative.canonical_name(), 'refnorm'),
453453
(self.informative.canonical_name(), 'refinfo'),
454454
(self.unknown.canonical_name(), 'refunk'),
455-
(self.updated.docalias.first().name, 'updates'),
455+
(self.updated.name, 'updates'),
456456
]
457457
)

ietf/doc/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from ietf.community.utils import docs_tracked_by_community_list
3232

3333
from ietf.doc.models import Document, DocHistory, State, DocumentAuthor, DocHistoryAuthor
34-
from ietf.doc.models import DocAlias, RelatedDocument, RelatedDocHistory, BallotType, DocReminder
34+
from ietf.doc.models import RelatedDocument, RelatedDocHistory, BallotType, DocReminder
3535
from ietf.doc.models import DocEvent, ConsensusDocEvent, BallotDocEvent, IRSGBallotDocEvent, NewRevisionDocEvent, StateDocEvent
3636
from ietf.doc.models import TelechatDocEvent, DocumentActionHolder, EditedAuthorsDocEvent
3737
from ietf.name.models import DocReminderTypeName, DocRelationshipName
@@ -771,9 +771,9 @@ def rebuild_reference_relations(doc, filenames):
771771
errors = []
772772
unfound = set()
773773
for ( ref, refType ) in refs.items():
774-
refdoc = DocAlias.objects.filter(name=ref)
774+
refdoc = Document.objects.filter(name=ref)
775775
if not refdoc and re.match(r"^draft-.*-\d{2}$", ref):
776-
refdoc = DocAlias.objects.filter(name=ref[:-3])
776+
refdoc = Document.objects.filter(name=ref[:-3])
777777
count = refdoc.count()
778778
# As of Dec 2021, DocAlias has a unique constraint on the name field, so count > 1 should not occur
779779
if count == 0:

ietf/doc/views_draft.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import debug # pyflakes:ignore
2525

26-
from ietf.doc.models import ( Document, DocAlias, RelatedDocument, State,
26+
from ietf.doc.models import ( Document, RelatedDocument, State,
2727
StateType, DocEvent, ConsensusDocEvent, TelechatDocEvent, WriteupDocEvent, StateDocEvent,
2828
IanaExpertDocEvent, IESG_SUBSTATE_TAGS)
2929
from ietf.doc.mails import ( email_pulled_from_rfc_queue, email_resurrect_requested,

ietf/doc/views_status_change.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def clean_helper(form, formtype):
439439

440440
if not re.match(r'(?i)rfc\d{1,4}',key):
441441
errors.append(key+" is not a valid RFC - please use the form RFCn\n")
442-
elif not DocAlias.objects.filter(name=key):
442+
elif not Document.objects.filter(name=key):
443443
errors.append(key+" does not exist\n")
444444

445445
if new_relations[key] not in STATUSCHANGE_RELATIONS:
@@ -564,10 +564,9 @@ def start_rfc_status_change(request, name=None):
564564
DocAlias.objects.create( name= 'status-change-'+form.cleaned_data['document_name']).docs.add(status_change)
565565

566566
for key in form.cleaned_data['relations']:
567-
status_change.relateddocument_set.create(target=DocAlias.objects.get(name=key),
567+
status_change.relateddocument_set.create(target=Document.objects.get(name=key),
568568
relationship_id=form.cleaned_data['relations'][key])
569569

570-
571570
tc_date = form.cleaned_data['telechat_date']
572571
if tc_date:
573572
update_telechat(request, status_change, login, tc_date)
@@ -609,7 +608,7 @@ def edit_relations(request, name):
609608
new_relations=form.cleaned_data['relations']
610609
status_change.relateddocument_set.filter(relationship__slug__in=STATUSCHANGE_RELATIONS).delete()
611610
for key in new_relations:
612-
status_change.relateddocument_set.create(target=DocAlias.objects.get(name=key),
611+
status_change.relateddocument_set.create(target=Document.objects.get(name=key),
613612
relationship_id=new_relations[key])
614613
c = DocEvent(type="added_comment", doc=status_change, rev=status_change.rev, by=login)
615614
c.desc = "Affected RFC list changed.\nOLD:"

ietf/group/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def setUp(self):
6969
a = WgDraftFactory()
7070
b = WgDraftFactory()
7171
RelatedDocument.objects.create(
72-
source=a, target=b.docalias.first(), relationship_id="refnorm"
72+
source=a, target=b, relationship_id="refnorm"
7373
)
7474

7575
def test_group_stats(self):
@@ -95,7 +95,7 @@ def setUp(self):
9595
a = WgDraftFactory()
9696
b = WgDraftFactory()
9797
RelatedDocument.objects.create(
98-
source=a, target=b.docalias.first(), relationship_id="refnorm"
98+
source=a, target=b, relationship_id="refnorm"
9999
)
100100

101101
def test_group_document_dependencies(self):

ietf/stats/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def test_document_stats(self):
8282
DocAlias.objects.create(name=referencing_draft.name).docs.add(referencing_draft)
8383
RelatedDocument.objects.create(
8484
source=referencing_draft,
85-
target=draft.docalias.first(),
85+
target=draft,
8686
relationship=DocRelationshipName.objects.get(slug="refinfo")
8787
)
8888
NewRevisionDocEvent.objects.create(

0 commit comments

Comments
 (0)