From 457b95094aa1d8bf26baf5e2dcccf3cc05f55b9f Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Fri, 7 Jul 2023 15:08:41 -0500 Subject: [PATCH] fix: improvements to submit form validation --- ietf/submit/forms.py | 2 +- ietf/submit/tests.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ietf/submit/forms.py b/ietf/submit/forms.py index b29669a0f1..c2f99975b2 100644 --- a/ietf/submit/forms.py +++ b/ietf/submit/forms.py @@ -707,7 +707,7 @@ def clean(self): elif alias.document.get_state_slug() == "rfc": self.add_error( 'replaces', - forms.ValidationError("An Internet-Draft cannot replace an RFC"), + forms.ValidationError("An Internet-Draft cannot replace another Internet-Draft that has become an RFC"), ) elif alias.document.get_state_slug('draft-iesg') in ('approved', 'ann', 'rfcqueue'): self.add_error( diff --git a/ietf/submit/tests.py b/ietf/submit/tests.py index 6eeaa47c56..17bf178199 100644 --- a/ietf/submit/tests.py +++ b/ietf/submit/tests.py @@ -3099,13 +3099,15 @@ def test_replaces_field(self): # can't replace RFC rfc = WgRfcFactory() + draft = WgDraftFactory(states=[("draft", "rfc")]) + draft.relateddocument_set.create(relationship_id="became_rfc", target=rfc.docalias.first()) form = SubmissionAutoUploadForm( request_factory.get('/some/url'), - data={'user': auth.user.username, 'replaces': rfc.name}, + data={'user': auth.user.username, 'replaces': draft.name}, files=files_dict, ) self.assertFalse(form.is_valid()) - self.assertIn('An Internet-Draft cannot replace an RFC', form.errors['replaces']) + self.assertIn('An Internet-Draft cannot replace another Internet-Draft that has become an RFC', form.errors['replaces']) # can't replace draft approved by iesg existing_drafts[0].set_state(State.objects.get(type='draft-iesg', slug='approved'))