From 012d67666f693d328c647f56e94c89aee1eacb19 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Mon, 4 Jul 2016 15:14:00 +0200 Subject: [PATCH] alfortville: better sorting roles on "copies" page (#12428) --- welco/contrib/alfortville/views.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/welco/contrib/alfortville/views.py b/welco/contrib/alfortville/views.py index 1823fe7..1533d54 100644 --- a/welco/contrib/alfortville/views.py +++ b/welco/contrib/alfortville/views.py @@ -165,17 +165,13 @@ class Copies(DetailView): context['checked_info'] = checked_dicts[Inbox.INFO] context['checked_avis'] = checked_dicts[Inbox.AVIS] context['checked_mandatory_avis'] = checked_dicts[Inbox.MANDATORY_AVIS] - context['roles'] = get_wcs_data('api/roles').get('data') - context['roles'] = [x for x in context['roles'] if - x['text'].startswith('Maire') or - x['text'].startswith('Adjoint') or - x['text'].startswith('Conseiller') or - x['text'].startswith('Elu') or - x['text'].startswith('Cabinet') or - x['text'].startswith('Direction') or - x['text'].startswith('DGA') or - x['text'].startswith('DGS')] - context['roles'].sort(lambda x, y: cmp(x['text'], y['text'])) + context['roles'] = [] + all_roles = get_wcs_data('api/roles').get('data') + for start in ('Maire', 'Cabinet', 'Adjoint', 'Conseiller', 'Elu', 'DGS', 'DGA', + 'Direction'): + roles = [x for x in all_roles if x['text'].startswith(start)] + roles.sort(lambda x, y: cmp(x['text'], y['text'])) + context['roles'].extend(roles) return context def post(self, request, *args, **kwargs): -- 2.8.1