improve (sort of customize) presentation of person data

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2391 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2008-02-12 11:41:36 +00:00
parent 5271981119
commit 695a717448
6 changed files with 100 additions and 15 deletions

View file

@ -241,12 +241,14 @@ class ConceptView(BaseView):
def data(self): def data(self):
return self.getData() return self.getData()
def getFields(self, omit=('title', 'description')):
fields = Jeep(self.schema.fields)
fields.remove(*omit)
return fields
@Lazy @Lazy
def instance(self): def fields(self):
instance = IInstance(self.adapted) return self.getFields()
instance.template = self.schema
instance.view = self
return instance
@Lazy @Lazy
def schema(self): def schema(self):
@ -254,6 +256,13 @@ class ConceptView(BaseView):
schemaFactory = component.getAdapter(self.adapted, ISchemaFactory) schemaFactory = component.getAdapter(self.adapted, ISchemaFactory)
return schemaFactory(ti, manager=self, request=self.request) return schemaFactory(ti, manager=self, request=self.request)
@Lazy
def instance(self):
instance = IInstance(self.adapted)
instance.template = self.schema
instance.view = self
return instance
def getChildren(self, topLevelOnly=True, sort=True): def getChildren(self, topLevelOnly=True, sort=True):
cm = self.loopsRoot.getConceptManager() cm = self.loopsRoot.getConceptManager()
hasType = cm.getTypePredicate() hasType = cm.getTypePredicate()

View file

@ -21,18 +21,37 @@
<metal:fields define-macro="conceptfields"> <metal:fields define-macro="conceptfields">
<fieldset class="box" <fieldset class="box"
tal:define="data python: list(item.fieldData())" tal:define="data item/data;
tal:condition="data"> values python: [v for v in data.values() if v];
fields item/fields"
tal:condition="values">
<table tal:attributes="ondblclick item/openEditWindow"> <table tal:attributes="ondblclick item/openEditWindow">
<tr tal:repeat="field data"> <tal:row repeat="field fields">
<td><b tal:content="field/title" i18n:translate="" />:</td> <tr tal:define="fieldName field/name;
<td tal:content="structure field/widget"></td> value nocall:data/?fieldName;
</tr> renderer field/displayRenderer"
tal:condition="nocall:value">
<td><b tal:content="field/title" i18n:translate="" />:</td>
<td><span metal:use-macro="item/template/macros/?renderer" /></td>
</tr>
</tal:row>
</table> </table>
</fieldset> </fieldset>
</metal:fields> </metal:fields>
<metal:textline define-macro="display_textline">
<span tal:content="nocall:value"></span>
</metal:textline>
<metal:textline define-macro="display_email">
<a href="#"
tal:attributes="href string:mailto:$value"
tal:content="value"></a>
</metal:textline>
<metal:parents define-macro="conceptparents"> <metal:parents define-macro="conceptparents">
<div tal:attributes="class string:content-$level; <div tal:attributes="class string:content-$level;
ondblclick python: item.openEditWindow('configure.html')"> ondblclick python: item.openEditWindow('configure.html')">
@ -117,7 +136,7 @@
tal:attributes="href string:${view/url}/.target${related/uniqueId}?loops.viewName=listversions">1.1</a> tal:attributes="href string:${view/url}/.target${related/uniqueId}?loops.viewName=listversions">1.1</a>
</td> </td>
</tal:version> </tal:version>
<td style="text-align: right"> <td style="text-align: right; white-space: nowrap">
<span tal:replace="related/context/sizeForDisplay">Type</span> <span tal:replace="related/context/sizeForDisplay">Type</span>
</td> </td>
<td><span tal:replace="related/modified">2007-03-30</span></td> <td><span tal:replace="related/modified">2007-03-30</span></td>

5
external/README.txt vendored
View file

@ -72,8 +72,9 @@ Writing object information to the external storage
>>> writer = PyWriter() >>> writer = PyWriter()
>>> writer.write(elements, output) >>> writer.write(elements, output)
>>> print output.getvalue() >>> print output.getvalue()
type(u'customer', u'Customer', viewName=u'')... type(u'customer', u'Customer', options=u'', viewName=u'')...
type(u'query', u'Query', typeInterface='loops.query.IQueryConcept', viewName=u'')... type(u'query', u'Query', options=u'', typeInterface='loops.query.IQueryConcept',
viewName=u'')...
concept(u'myquery', u'My Query', u'query', viewName='mystuff.html')... concept(u'myquery', u'My Query', u'query', viewName='mystuff.html')...
child(u'projects', u'customer', u'standard')... child(u'projects', u'customer', u'standard')...

View file

@ -93,6 +93,11 @@
<!-- other adapters --> <!-- other adapters -->
<zope:adapter factory="loops.organize.schema.PersonSchemaFactory" />
<zope:adapter factory="loops.organize.schema.SimpleListFieldInstance"
name="simplelist" />
<zope:adapter <zope:adapter
for="loops.interfaces.ILoopsObject for="loops.interfaces.ILoopsObject
zope.publisher.interfaces.browser.IBrowserRequest" zope.publisher.interfaces.browser.IBrowserRequest"

51
organize/schema.py Normal file
View file

@ -0,0 +1,51 @@
#
# Copyright (c) 2005 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
"""
Specialized schema factories
$Id$
"""
from zope.component import adapts
from cybertools.composer.schema.factory import SchemaFactory
from cybertools.composer.schema.field import FieldInstance
from cybertools.composer.schema.interfaces import FieldType
from cybertools.organize.interfaces import SimpleList
from loops.organize.interfaces import IPerson, UserId
class PersonSchemaFactory(SchemaFactory):
adapts(IPerson)
def __call__(self, interface, **kw):
schema = super(PersonSchemaFactory, self).__call__(interface, **kw)
schema.fields.phoneNumbers.instance_name ='simplelist'
schema.fields.birthDate.display_format = ('date', 'long')
schema.fields.email.display_renderer = 'display_email'
return schema
class SimpleListFieldInstance(FieldInstance):
def display(self, value):
if not value:
return ''
return ' | '.join(value)

View file

@ -81,7 +81,7 @@
tal:attributes="href string:${view/url}/.target${row/uniqueId}?loops.viewName=listversions">1.1</a> tal:attributes="href string:${view/url}/.target${row/uniqueId}?loops.viewName=listversions">1.1</a>
</td> </td>
</tal:version> </tal:version>
<td style="text-align: right"> <td style="text-align: right; white-space: nowrap">
<span tal:replace="row/context/sizeForDisplay|string:">Size</span> <span tal:replace="row/context/sizeForDisplay|string:">Size</span>
</td> </td>
<td><span tal:replace="row/modified">modified</span></td> <td><span tal:replace="row/modified">modified</span></td>