alfortville: better sorting roles on "copies" page (#12428)

This commit is contained in:
Thomas NOËL 2016-07-04 15:14:00 +02:00
parent 0b4dfb3d7f
commit 012d67666f
1 changed files with 7 additions and 11 deletions

View File

@ -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):