From 1ce2f410d0f860b87acdf50a29d2c5cd1981969e Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 22 Jun 2017 02:35:41 -0500 Subject: [PATCH] Tweak device type list field when making new handheld batch i.e. sort by display name, etc. --- tailbone/views/handheld.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tailbone/views/handheld.py b/tailbone/views/handheld.py index 88464dec..95fda982 100644 --- a/tailbone/views/handheld.py +++ b/tailbone/views/handheld.py @@ -1,8 +1,8 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8; -*- ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2016 Lance Edgar +# Copyright © 2010-2017 Lance Edgar # # This file is part of Rattail. # @@ -85,11 +85,12 @@ class HandheldBatchView(FileBatchMasterView): rows_editable = True def configure_grid(self, g): - enum = self.rattail_config.get_enum() + device_types = OrderedDict(sorted(self.enum.HANDHELD_DEVICE_TYPE.items(), + key=lambda item: item[1])) g.configure( include=[ g.id, - g.device_type.with_renderer(forms.renderers.EnumFieldRenderer(enum.HANDHELD_DEVICE_TYPE)), + g.device_type.with_renderer(forms.renderers.EnumFieldRenderer(device_types)), g.device_name, g.created, g.created_by, @@ -105,9 +106,13 @@ class HandheldBatchView(FileBatchMasterView): attrs['class_'] = 'notice' return attrs - def configure_fieldset(self, fs): - fs.device_type.set(renderer=forms.renderers.EnumFieldRenderer(enum.HANDHELD_DEVICE_TYPE)) + def _preconfigure_fieldset(self, fs): + super(HandheldBatchView, self)._preconfigure_fieldset(fs) + device_types = OrderedDict(sorted(self.enum.HANDHELD_DEVICE_TYPE.items(), + key=lambda item: item[1])) + fs.device_type.set(renderer=forms.renderers.EnumFieldRenderer(device_types)) + def configure_fieldset(self, fs): if self.creating: fs.configure( include=[