myspace: allow sorting forms with no receipt time (#39629)

This commit is contained in:
Frédéric Péters 2020-02-07 11:09:04 +01:00
parent 3e91606b06
commit 48f78b1360
1 changed files with 4 additions and 2 deletions

View File

@ -120,7 +120,8 @@ class JsonDirectory(Directory):
for formdef in formdefs:
user_forms.extend(formdef.data_class().get_with_indexed_value(
'user_id', self.user.id))
user_forms.sort(key=lambda x: x.receipt_time)
epoch = time.localtime(1970)
user_forms.sort(key=lambda x: x.receipt_time or epoch)
get_response().set_content_type('application/json')
@ -186,7 +187,8 @@ class MyspaceDirectory(wcs.myspace.MyspaceDirectory):
for formdef in formdefs:
user_forms.extend(formdef.data_class().get_with_indexed_value(
'user_id', user.id))
user_forms.sort(key=lambda x: x.receipt_time)
epoch = time.localtime(1970)
user_forms.sort(key=lambda x: x.receipt_time or epoch)
profile_links = []
if not get_cfg('sp', {}).get('idp-manage-user-attributes', False):