summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas NOEL <tnoel@entrouvert.com>2016-07-04 13:14:00 (GMT)
committerThomas NOEL <tnoel@entrouvert.com>2016-07-04 13:14:32 (GMT)
commit012d67666f693d328c647f56e94c89aee1eacb19 (patch)
treebf645572f6ae6fa6e244b1c730a9e544ebc2c289
parent0b4dfb3d7f777040461158eef626ed62398c2de2 (diff)
downloadwelco-012d67666f693d328c647f56e94c89aee1eacb19.zip
welco-012d67666f693d328c647f56e94c89aee1eacb19.tar.gz
welco-012d67666f693d328c647f56e94c89aee1eacb19.tar.bz2
alfortville: better sorting roles on "copies" page (#12428)
-rw-r--r--welco/contrib/alfortville/views.py18
1 files 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):