Skip to content

Commit a9fbea1

Browse files
committed
Changed incorrect use of 404 status code in api to 400. Fixes issue ietf-tools#2498.
- Legacy-Id: 15044
1 parent 760a14b commit a9fbea1

5 files changed

Lines changed: 10 additions & 10 deletions

File tree

ietf/api/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ def test_api_set_session_video_url(self):
9595

9696
r = self.client.post(url, {'apikey': apikey.hash(), 'meeting': '1', 'group': group.acronym,
9797
'item': '1', 'url': video, })
98-
self.assertContains(r, "No sessions found for meeting", status_code=404)
98+
self.assertContains(r, "No sessions found for meeting", status_code=400)
9999

100100
r = self.client.post(url, {'apikey': apikey.hash(), 'meeting': meeting.number, 'group': 'bogous',
101101
'item': '1', 'url': video, })
102-
self.assertContains(r, "No sessions found in meeting '%s' for group 'bogous'"%meeting.number, status_code=404)
102+
self.assertContains(r, "No sessions found in meeting '%s' for group 'bogous'"%meeting.number, status_code=400)
103103

104104
r = self.client.post(url, {'apikey': apikey.hash(), 'meeting': meeting.number, 'group': group.acronym,
105105
'item': '1', 'url': "foobar", })

ietf/doc/views_ballot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def err(code, text):
259259
try:
260260
doc = Document.objects.get(docalias__name=name)
261261
except Document.DoesNotExist:
262-
return err(404, "Document not found")
262+
return err(400, "Document not found")
263263
position_names = BallotPositionName.objects.values_list('slug', flat=True)
264264
position = request.POST.get('position')
265265
if not position:
@@ -268,7 +268,7 @@ def err(code, text):
268268
return err(400, "Bad position name, must be one of: %s " % ','.join(position_names))
269269
ballot = doc.active_ballot()
270270
if not ballot:
271-
return err(404, "No open ballot found")
271+
return err(400, "No open ballot found")
272272
form = EditPositionForm(request.POST, ballot_type=ballot.ballot_type)
273273
if form.is_valid():
274274
save_position(form, doc, ballot, ad)

ietf/meeting/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,11 +2205,11 @@ def err(code, text):
22052205
number = request.POST.get('meeting')
22062206
sessions = Session.objects.filter(meeting__number=number)
22072207
if not sessions.exists():
2208-
return err(404, "No sessions found for meeting '%s'" % (number, ))
2208+
return err(400, "No sessions found for meeting '%s'" % (number, ))
22092209
acronym = request.POST.get('group')
22102210
sessions = sessions.filter(group__acronym=acronym)
22112211
if not sessions.exists():
2212-
return err(404, "No sessions found in meeting '%s' for group '%s'" % (number, acronym))
2212+
return err(400, "No sessions found in meeting '%s' for group '%s'" % (number, acronym))
22132213
session_times = [ (s.official_timeslotassignment().timeslot.time, s) for s in sessions ]
22142214
session_times.sort()
22152215
item = request.POST.get('item')

ietf/submit/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,14 +1630,14 @@ def test_api_submit_no_user(self):
16301630
email='nonexistant.user@example.org'
16311631
r, author, name = self.post_submission('00', email=email)
16321632
expected = "No such user: %s" % email
1633-
self.assertContains(r, expected, status_code=404)
1633+
self.assertContains(r, expected, status_code=400)
16341634

16351635
def test_api_submit_no_person(self):
16361636
user = UserFactory()
16371637
email = user.username
16381638
r, author, name = self.post_submission('00', email=email)
16391639
expected = "No person with username %s" % email
1640-
self.assertContains(r, expected, status_code=404)
1640+
self.assertContains(r, expected, status_code=400)
16411641

16421642
def test_api_submit_wrong_revision(self):
16431643
r, author, name = self.post_submission('01')

ietf/submit/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ def err(code, text):
9292
username = form.cleaned_data['user']
9393
user = User.objects.filter(username=username)
9494
if user.count() == 0:
95-
return err(404, "No such user: %s" % username)
95+
return err(400, "No such user: %s" % username)
9696
if user.count() > 1:
9797
return err(500, "Multiple matching accounts for %s" % username)
9898
user = user.first()
9999
if not hasattr(user, 'person'):
100-
return err(404, "No person with username %s" % username)
100+
return err(400, "No person with username %s" % username)
101101

102102
authors, abstract, file_name, file_size = get_draft_meta(form)
103103
for a in authors:

0 commit comments

Comments
 (0)