Skip to content

Commit cd0c1f3

Browse files
committed
Merged in [19224] from rjsparks@nostrum.com:
Guard a sort that gets a mix of integers and None. - Legacy-Id: 19236 Note: SVN reference [19224] has been migrated to Git commit 62c3648
2 parents 302f001 + 62c3648 commit cd0c1f3

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

ietf/group/milestones.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ def save_milestone_form(f):
383383
if group.uses_milestone_dates:
384384
forms.sort(key=lambda f: f.milestone.due if f.milestone else datetime.date.max)
385385
else:
386-
forms.sort(key=lambda f: (f.milestone is None, f.milestone.order if f.milestone else None) )
386+
forms.sort(key=lambda f: (f.milestone is None, f.milestone.order if f.milestone and f.milestone.order is not None else -1) )
387387

388388
return render(request, 'group/edit_milestones.html',
389389
dict(group=group,

ietf/group/tests_info.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,18 @@ def test_reset_charter_milestones(self):
13211321

13221322
self.assertEqual(group.charter.docevent_set.count(), events_before + 2) # 1 delete, 1 add
13231323

1324+
def test_edit_sort(self):
1325+
group = GroupFactory(uses_milestone_dates=False)
1326+
DatelessGroupMilestoneFactory(group=group,order=1)
1327+
DatelessGroupMilestoneFactory(group=group,order=0)
1328+
DatelessGroupMilestoneFactory(group=group,order=None)
1329+
url = urlreverse('ietf.group.milestones.edit_milestones;current', kwargs=dict(group_type=group.type_id, acronym=group.acronym))
1330+
login_testing_unauthorized(self, "secretary", url)
1331+
r = self.client.get(url)
1332+
self.assertEqual(r.status_code, 200)
1333+
q = PyQuery(r.content)
1334+
self.assertEqual([x.value for x in q('input[id^=id_m][id$=order]')], [None, '0', '1'])
1335+
13241336
class DatelessMilestoneTests(TestCase):
13251337
def test_switch_to_dateless(self):
13261338
ad_role = RoleFactory(group__type_id='area',name_id='ad')

0 commit comments

Comments
 (0)