Merge branch 'bbmaster' of ssh://git.cy55.de/home/git/cybertools into bbmaster
This commit is contained in:
commit
1a58bb60c6
4 changed files with 22 additions and 14 deletions
|
@ -82,6 +82,7 @@ class Report(Template):
|
||||||
queryCriteria = None
|
queryCriteria = None
|
||||||
outputFields = ()
|
outputFields = ()
|
||||||
sortCriteria = ()
|
sortCriteria = ()
|
||||||
|
limits = None
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
|
|
|
@ -53,6 +53,7 @@ class Row(BaseRow):
|
||||||
def getGroupFields(self):
|
def getGroupFields(self):
|
||||||
return [self.getRawValue(f.name) for f in
|
return [self.getRawValue(f.name) for f in
|
||||||
self.parent.context.fields if 'group' in f.executionSteps]
|
self.parent.context.fields if 'group' in f.executionSteps]
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def displayedColumns(self):
|
def displayedColumns(self):
|
||||||
return self.parent.context.getActiveOutputFields()
|
return self.parent.context.getActiveOutputFields()
|
||||||
|
@ -78,15 +79,17 @@ class GroupHeaderRow(BaseRow):
|
||||||
|
|
||||||
class ResultSet(object):
|
class ResultSet(object):
|
||||||
|
|
||||||
def __init__(self, context, data, rowFactory=Row, headerRowFactory=GroupHeaderRow,
|
def __init__(self, context, data,
|
||||||
sortCriteria=None, queryCriteria=BaseQueryCriteria()):
|
rowFactory=Row, headerRowFactory=GroupHeaderRow,
|
||||||
|
sortCriteria=None, queryCriteria=BaseQueryCriteria(),
|
||||||
|
limits=None):
|
||||||
self.context = context # the report or report instance
|
self.context = context # the report or report instance
|
||||||
self.data = data
|
self.data = data
|
||||||
self.rowFactory = rowFactory
|
self.rowFactory = rowFactory
|
||||||
self.headerRowFactory = headerRowFactory
|
self.headerRowFactory = headerRowFactory
|
||||||
self.sortCriteria = sortCriteria
|
self.sortCriteria = sortCriteria
|
||||||
self.queryCriteria = queryCriteria
|
self.queryCriteria = queryCriteria
|
||||||
|
self.limits = limits
|
||||||
self.totals = BaseRow(None, self)
|
self.totals = BaseRow(None, self)
|
||||||
|
|
||||||
def getHeaderRow(self, row, columns):
|
def getHeaderRow(self, row, columns):
|
||||||
|
@ -105,7 +108,8 @@ class ResultSet(object):
|
||||||
result = [self.rowFactory(item, self) for item in self.data]
|
result = [self.rowFactory(item, self) for item in self.data]
|
||||||
result = [row for row in result if self.queryCriteria.check(row)]
|
result = [row for row in result if self.queryCriteria.check(row)]
|
||||||
if self.sortCriteria:
|
if self.sortCriteria:
|
||||||
result.sort(key=lambda x: [f.getSortValue(x) for f in self.sortCriteria])
|
result.sort(key=lambda x:
|
||||||
|
[f.getSortValue(x) for f in self.sortCriteria])
|
||||||
if self.groupColumns:
|
if self.groupColumns:
|
||||||
res = []
|
res = []
|
||||||
groupValues = [None for f in self.groupColumns]
|
groupValues = [None for f in self.groupColumns]
|
||||||
|
@ -117,6 +121,9 @@ class ResultSet(object):
|
||||||
res.append(self.getHeaderRow(row, (f,) + f.outputWith))
|
res.append(self.getHeaderRow(row, (f,) + f.outputWith))
|
||||||
res.append(row)
|
res.append(row)
|
||||||
result = res
|
result = res
|
||||||
|
if self.limits:
|
||||||
|
start, stop = self.limits
|
||||||
|
result = result[start:stop]
|
||||||
for idx, row in enumerate(result):
|
for idx, row in enumerate(result):
|
||||||
row.sequenceNumber = idx + 1
|
row.sequenceNumber = idx + 1
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
</tal:errors>
|
</tal:errors>
|
||||||
<tr>
|
<tr>
|
||||||
<tal:field>
|
<tal:field>
|
||||||
<td style="padding: 4px; border-top: none; vertical-align: top"
|
<td style="padding: 4px; border-top: none; vertical-align: top; width: 155px"
|
||||||
tal:attributes="title field/description">
|
tal:attributes="title field/description">
|
||||||
<b tal:content="field/title">...</b><span
|
<b tal:content="field/title">...</b><span
|
||||||
tal:condition="field/required"> *</span>
|
tal:condition="field/required"> *</span>
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
tal:define="width field/width|nothing"
|
tal:define="width field/width|nothing"
|
||||||
tal:attributes="name name; id name;
|
tal:attributes="name name; id name;
|
||||||
style python:
|
style python:
|
||||||
('width: %s;;' % (width and str(width)+'px' or '600px')) +
|
('width: %s;;' % (width and str(width)+'px' or '555px')) +
|
||||||
'height: 1.5em;;';
|
'height: 1.5em;;';
|
||||||
value data/?name|string:;
|
value data/?name|string:;
|
||||||
xxrequired field/required_js;" />
|
xxrequired field/required_js;" />
|
||||||
|
@ -119,7 +119,7 @@
|
||||||
tal:define="width field/width|nothing"
|
tal:define="width field/width|nothing"
|
||||||
tal:attributes="name name;
|
tal:attributes="name name;
|
||||||
style python:
|
style python:
|
||||||
'width: %s' % (width and str(width)+'px' or '600px');
|
'width: %s' % (width and str(width)+'px' or '555px');
|
||||||
value data/?name|string:" />
|
value data/?name|string:" />
|
||||||
</metal:password>
|
</metal:password>
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@
|
||||||
tal:attributes="name name;
|
tal:attributes="name name;
|
||||||
rows python: height or 3;
|
rows python: height or 3;
|
||||||
style python:
|
style python:
|
||||||
'width: %s' % (width and str(width)+'px' or '600px');"
|
'width: %s' % (width and str(width)+'px' or '545px');"
|
||||||
tal:content="data/?name|string:">
|
tal:content="data/?name|string:">
|
||||||
</textarea>
|
</textarea>
|
||||||
</metal:textarea>
|
</metal:textarea>
|
||||||
|
@ -178,7 +178,7 @@
|
||||||
tal:attributes="name name;
|
tal:attributes="name name;
|
||||||
rows python: height or 3;
|
rows python: height or 3;
|
||||||
style python:
|
style python:
|
||||||
'width: %s' % (width and str(width)+'px' or '600px');"
|
'width: %s' % (width and str(width)+'px' or '555px');"
|
||||||
tal:content="data/?name|string:" />
|
tal:content="data/?name|string:" />
|
||||||
</metal:list>
|
</metal:list>
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<td><a tal:define="userUrl view/userUrl|nothing"
|
<td><a tal:define="userUrl view/userUrl|nothing"
|
||||||
tal:omit-tag="not:userUrl"
|
tal:omit-tag="not:userUrl"
|
||||||
tal:attributes="href userUrl"
|
tal:attributes="href userUrl"
|
||||||
tal:content="view/userTitle" /></td></tr>
|
tal:content="view/userTitle|string:???" /></td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Timestamp:</td>
|
<td>Timestamp:</td>
|
||||||
<td tal:content="view/timeStamp"></td></tr>
|
<td tal:content="view/timeStamp"></td></tr>
|
||||||
|
|
Loading…
Add table
Reference in a new issue