Skip to content

Commit

Permalink
fix: improvements to submit form validation
Browse files Browse the repository at this point in the history
  • Loading branch information
rjsparks committed Jul 7, 2023
1 parent ff058e3 commit 457b950
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ietf/submit/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions ietf/submit/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down

0 comments on commit 457b950

Please sign in to comment.