Tweak device type list field when making new handheld batch

i.e. sort by display name, etc.
This commit is contained in:
Lance Edgar 2017-06-22 02:35:41 -05:00
parent b2f96f4217
commit 1ce2f410d0

View file

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8; -*-
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2016 Lance Edgar # Copyright © 2010-2017 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -85,11 +85,12 @@ class HandheldBatchView(FileBatchMasterView):
rows_editable = True rows_editable = True
def configure_grid(self, g): 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( g.configure(
include=[ include=[
g.id, 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.device_name,
g.created, g.created,
g.created_by, g.created_by,
@ -105,9 +106,13 @@ class HandheldBatchView(FileBatchMasterView):
attrs['class_'] = 'notice' attrs['class_'] = 'notice'
return attrs return attrs
def configure_fieldset(self, fs): def _preconfigure_fieldset(self, fs):
fs.device_type.set(renderer=forms.renderers.EnumFieldRenderer(enum.HANDHELD_DEVICE_TYPE)) 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: if self.creating:
fs.configure( fs.configure(
include=[ include=[