merge branch 'master'
This commit is contained in:
commit
fdb51f6b1a
4 changed files with 30 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -18,8 +18,6 @@
|
|||
|
||||
"""
|
||||
Implementation of report field definitions.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
|
@ -93,6 +91,14 @@ class Field(Component):
|
|||
#return self.getValue(row)
|
||||
|
||||
|
||||
class CalculatedField(Field):
|
||||
|
||||
def getRawValue(self, row):
|
||||
return getattr(row, self.name)
|
||||
|
||||
|
||||
# sample field
|
||||
|
||||
label = Field('label', u'Label',
|
||||
u'A short text that identifies a row for humans.')
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2010 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -33,6 +33,7 @@ class BaseRow(object):
|
|||
self.context = context
|
||||
self.parent = parent
|
||||
self.data = {}
|
||||
self.sequenceNumber = 0
|
||||
|
||||
def __getattr__(self, attr):
|
||||
f = self.parent.context.fields[attr]
|
||||
|
@ -54,7 +55,6 @@ class Row(BaseRow):
|
|||
return getattr(obj.context, attr)
|
||||
|
||||
|
||||
|
||||
class ResultSet(object):
|
||||
|
||||
def __init__(self, context, data, rowFactory=Row,
|
||||
|
@ -71,6 +71,8 @@ class ResultSet(object):
|
|||
result = [row for row in result if self.queryCriteria.check(row)]
|
||||
if self.sortCriteria:
|
||||
result.sort(key=lambda x: [f.getSortValue(x) for f in self.sortCriteria])
|
||||
for idx, row in enumerate(result):
|
||||
row.sequenceNumber = idx + 1
|
||||
return result
|
||||
|
||||
def __iter__(self):
|
||||
|
|
|
@ -42,37 +42,43 @@
|
|||
tal:define="fieldInstance python: field.getFieldInstance(view.instance);
|
||||
columns fieldInstance/columnTypes;
|
||||
rows data/?name">
|
||||
<table class="records">
|
||||
<table class="records" style="width: auto">
|
||||
<thead>
|
||||
<tr>
|
||||
<tal:header repeat="column columns">
|
||||
<th tal:attributes="field column/name;"
|
||||
<th tal:attributes="class string:${column/baseField/cssClass|string:}"
|
||||
tal:content="column/title">Column Title</th>
|
||||
</tal:header>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody tal:attributes="id string:tbody.$name">
|
||||
<tr tal:repeat="row rows">
|
||||
<td tal:repeat="column columns">
|
||||
<input type="text"
|
||||
<td tal:repeat="column columns"
|
||||
tal:attributes="class string:${column/baseField/cssClass|string:}">
|
||||
<input type="text" style="width: auto"
|
||||
tal:define="cname column/name"
|
||||
tal:attributes="value row/?cname;
|
||||
name string:$name.$cname:records;" /></td>
|
||||
name string:$name.$cname:records;
|
||||
style string:width: ${column/baseField/width|string:auto};" /></td>
|
||||
</tr>
|
||||
<tal:empty condition="python: not field.cardinality
|
||||
or field.cardinality > len(rows)">
|
||||
<tr>
|
||||
<td tal:repeat="column columns">
|
||||
<td tal:repeat="column columns"
|
||||
tal:attributes="class string:${column/baseField/cssClass|string:}">
|
||||
<input type="text"
|
||||
tal:define="cname column/name"
|
||||
tal:attributes="name string:$name.$cname:records" /></td>
|
||||
tal:attributes="name string:$name.$cname:records;
|
||||
style string:width: ${column/baseField/width|string:auto};" /></td>
|
||||
</tr>
|
||||
<tr style="display: none"
|
||||
tal:attributes="id string:$name.empty">
|
||||
<td tal:repeat="column columns">
|
||||
<input type="text"
|
||||
<td tal:repeat="column columns"
|
||||
tal:attributes="class string:${column/baseField/cssClass|string:}">
|
||||
<input type="text" style="width: auto"
|
||||
tal:define="cname column/name"
|
||||
tal:attributes="name string:$name.$cname:records" /></td>
|
||||
tal:attributes="name string:$name.$cname:records;
|
||||
style string:width: ${column/baseField/width|string:auto};" /></td>
|
||||
</tr>
|
||||
</tal:empty>
|
||||
</tbody>
|
||||
|
|
|
@ -46,6 +46,7 @@ class Records(Grid):
|
|||
__typeInfo__ = ('records',
|
||||
FieldType('records', 'records',
|
||||
u'A series of records or rows.',
|
||||
displayRenderer='display_records',
|
||||
instanceName='records',))
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue