Add support for system-unique ID in batch views etc.
This commit is contained in:
parent
343f9bde1b
commit
cf1b9acfb1
|
@ -49,3 +49,5 @@ from .products import (ProductFieldRenderer, GPCFieldRenderer,
|
||||||
from .stores import StoreFieldRenderer
|
from .stores import StoreFieldRenderer
|
||||||
|
|
||||||
from .vendors import VendorFieldRenderer
|
from .vendors import VendorFieldRenderer
|
||||||
|
|
||||||
|
from .batch import BatchIDFieldRenderer
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2015 Lance Edgar
|
# Copyright © 2010-2016 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -24,16 +24,28 @@
|
||||||
Batch Field Renderers
|
Batch Field Renderers
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
import formalchemy as fa
|
||||||
from formalchemy.ext import fsblob
|
from formalchemy.ext import fsblob
|
||||||
from formalchemy.fields import FileFieldRenderer as Base
|
from formalchemy.fields import FileFieldRenderer as Base
|
||||||
|
|
||||||
|
|
||||||
|
class BatchIDFieldRenderer(fa.FieldRenderer):
|
||||||
|
"""
|
||||||
|
Renderer for batch ID fields.
|
||||||
|
"""
|
||||||
|
def render_readonly(self, **kwargs):
|
||||||
|
batch_id = self.raw_value
|
||||||
|
if batch_id:
|
||||||
|
return '{:08d}'.format(batch_id)
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
# TODO: make this inherit from `tailbone.forms.renderers.files.FileFieldRenderer`
|
# TODO: make this inherit from `tailbone.forms.renderers.files.FileFieldRenderer`
|
||||||
class FileFieldRenderer(fsblob.FileFieldRenderer):
|
class FileFieldRenderer(fsblob.FileFieldRenderer):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -126,6 +126,9 @@ class BatchMasterView(MasterView):
|
||||||
'rows_grid': grid.render_complete(allow_save_defaults=False),
|
'rows_grid': grid.render_complete(allow_save_defaults=False),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def get_instance_title(self, batch):
|
||||||
|
return batch.id_str or unicode(batch)
|
||||||
|
|
||||||
def _preconfigure_grid(self, g):
|
def _preconfigure_grid(self, g):
|
||||||
"""
|
"""
|
||||||
Apply some commonly-useful pre-configuration to the main batch grid.
|
Apply some commonly-useful pre-configuration to the main batch grid.
|
||||||
|
@ -144,6 +147,7 @@ class BatchMasterView(MasterView):
|
||||||
g.default_sortkey = 'created'
|
g.default_sortkey = 'created'
|
||||||
g.default_sortdir = 'desc'
|
g.default_sortdir = 'desc'
|
||||||
|
|
||||||
|
g.id.set(label="ID", renderer=forms.renderers.BatchIDFieldRenderer)
|
||||||
g.created_by.set(label="Created by", renderer=forms.renderers.UserFieldRenderer)
|
g.created_by.set(label="Created by", renderer=forms.renderers.UserFieldRenderer)
|
||||||
g.cognized_by.set(renderer=forms.renderers.UserFieldRenderer)
|
g.cognized_by.set(renderer=forms.renderers.UserFieldRenderer)
|
||||||
g.executed_by.set(label="Executed by", renderer=forms.renderers.UserFieldRenderer)
|
g.executed_by.set(label="Executed by", renderer=forms.renderers.UserFieldRenderer)
|
||||||
|
@ -155,6 +159,7 @@ class BatchMasterView(MasterView):
|
||||||
"""
|
"""
|
||||||
g.configure(
|
g.configure(
|
||||||
include=[
|
include=[
|
||||||
|
g.id,
|
||||||
g.created,
|
g.created,
|
||||||
g.created_by,
|
g.created_by,
|
||||||
g.executed,
|
g.executed,
|
||||||
|
@ -167,6 +172,8 @@ class BatchMasterView(MasterView):
|
||||||
Apply some commonly-useful pre-configuration to the main batch
|
Apply some commonly-useful pre-configuration to the main batch
|
||||||
fieldset.
|
fieldset.
|
||||||
"""
|
"""
|
||||||
|
fs.id.set(label="ID", readonly=True, renderer=forms.renderers.BatchIDFieldRenderer)
|
||||||
|
|
||||||
fs.created.set(readonly=True)
|
fs.created.set(readonly=True)
|
||||||
fs.created_by.set(label="Created by", renderer=forms.renderers.UserFieldRenderer,
|
fs.created_by.set(label="Created by", renderer=forms.renderers.UserFieldRenderer,
|
||||||
readonly=True)
|
readonly=True)
|
||||||
|
@ -193,6 +200,7 @@ class BatchMasterView(MasterView):
|
||||||
if batch.executed:
|
if batch.executed:
|
||||||
fs.configure(
|
fs.configure(
|
||||||
include=[
|
include=[
|
||||||
|
fs.id,
|
||||||
fs.created,
|
fs.created,
|
||||||
fs.created_by,
|
fs.created_by,
|
||||||
fs.executed,
|
fs.executed,
|
||||||
|
@ -201,6 +209,7 @@ class BatchMasterView(MasterView):
|
||||||
else:
|
else:
|
||||||
fs.configure(
|
fs.configure(
|
||||||
include=[
|
include=[
|
||||||
|
fs.id,
|
||||||
fs.created,
|
fs.created,
|
||||||
fs.created_by,
|
fs.created_by,
|
||||||
])
|
])
|
||||||
|
@ -832,6 +841,7 @@ class FileBatchMasterView(BatchMasterView):
|
||||||
if batch.executed:
|
if batch.executed:
|
||||||
fs.configure(
|
fs.configure(
|
||||||
include=[
|
include=[
|
||||||
|
fs.id,
|
||||||
fs.created,
|
fs.created,
|
||||||
fs.created_by,
|
fs.created_by,
|
||||||
fs.filename,
|
fs.filename,
|
||||||
|
@ -841,6 +851,7 @@ class FileBatchMasterView(BatchMasterView):
|
||||||
else:
|
else:
|
||||||
fs.configure(
|
fs.configure(
|
||||||
include=[
|
include=[
|
||||||
|
fs.id,
|
||||||
fs.created,
|
fs.created,
|
||||||
fs.created_by,
|
fs.created_by,
|
||||||
fs.filename,
|
fs.filename,
|
||||||
|
|
Loading…
Reference in a new issue