Pre-sort objects in tables

This commit is contained in:
Kumi 2019-02-01 15:07:12 +00:00
parent 384e5bc4ec
commit 20c410b5c4

View file

@ -10,13 +10,13 @@ def orgaString(context):
@register.simple_tag(takes_context=True) @register.simple_tag(takes_context=True)
def userDevices(context): def userDevices(context):
return set(Device.objects.filter(organization__in=context.request.user.organization_set.all())) return sorted(set(Device.objects.filter(organization__in=context.request.user.organization_set.all())), key=lambda x: x.serial)
@register.simple_tag(takes_context=True) @register.simple_tag(takes_context=True)
def userWifis(context): def userWifis(context):
return set(Wifi.objects.filter(organization__in=context.request.user.organization_set.all())) return sorted(set(Wifi.objects.filter(organization__in=context.request.user.organization_set.all())), key=lambda x: x.serial)
@register.simple_tag(takes_context=True) @register.simple_tag(takes_context=True)
def userUsers(context): def userUsers(context):
return set(User.objects.filter(organization__in=context.request.user.organization_set.all()) if context.request.user.is_superuser else []) return sorted(set(User.objects.filter(organization__in=context.request.user.organization_set.all()) if context.request.user.is_superuser else []), key=lambda x: x.username)