More tweaks for python 3
This commit is contained in:
parent
ee35cc6f22
commit
b0821e8011
|
@ -30,7 +30,7 @@ import os
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import tempfile
|
import tempfile
|
||||||
from cStringIO import StringIO
|
from six import StringIO
|
||||||
|
|
||||||
import six
|
import six
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
|
@ -48,6 +48,10 @@ class PrincipalMasterView(MasterView):
|
||||||
'/principal/{}.mako'.format(template),
|
'/principal/{}.mako'.format(template),
|
||||||
] + super(PrincipalMasterView, self).get_fallback_templates(template, mobile=mobile)
|
] + super(PrincipalMasterView, self).get_fallback_templates(template, mobile=mobile)
|
||||||
|
|
||||||
|
def perm_sortkey(self, item):
|
||||||
|
key, value = item
|
||||||
|
return value['label'].lower()
|
||||||
|
|
||||||
def find_by_perm(self):
|
def find_by_perm(self):
|
||||||
"""
|
"""
|
||||||
View for finding all users who have been granted a given permission
|
View for finding all users who have been granted a given permission
|
||||||
|
@ -55,9 +59,9 @@ class PrincipalMasterView(MasterView):
|
||||||
permissions = copy.deepcopy(self.request.registry.settings.get('tailbone_permissions', {}))
|
permissions = copy.deepcopy(self.request.registry.settings.get('tailbone_permissions', {}))
|
||||||
|
|
||||||
# sort groups, and permissions for each group, for UI's sake
|
# sort groups, and permissions for each group, for UI's sake
|
||||||
sorted_perms = sorted(permissions.items(), key=lambda (k, v): v['label'].lower())
|
sorted_perms = sorted(permissions.items(), key=self.perm_sortkey)
|
||||||
for key, group in sorted_perms:
|
for key, group in sorted_perms:
|
||||||
group['perms'] = sorted(group['perms'].items(), key=lambda (k, v): v['label'].lower())
|
group['perms'] = sorted(group['perms'].items(), key=self.perm_sortkey)
|
||||||
|
|
||||||
# group options are stable, permission options may depend on submitted group
|
# group options are stable, permission options may depend on submitted group
|
||||||
group_choices = [(gkey, group['label']) for gkey, group in sorted_perms]
|
group_choices = [(gkey, group['label']) for gkey, group in sorted_perms]
|
||||||
|
|
Loading…
Reference in a new issue