fix: improvements to submit form validation

This commit is contained in:
Robert Sparks 2023-07-07 15:08:41 -05:00
parent ff058e3c63
commit 457b95094a
No known key found for this signature in database
GPG key ID: 6E2A6A5775F91318
2 changed files with 5 additions and 3 deletions

View file

@ -707,7 +707,7 @@ class SubmissionAutoUploadForm(SubmissionBaseUploadForm):
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(

View file

@ -3099,13 +3099,15 @@ class SubmissionUploadFormTests(BaseSubmitTestCase):
# 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'))