more on person; provide address, task
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1225 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
6ab11a50e9
commit
98c195492e
5 changed files with 110 additions and 9 deletions
|
@ -28,6 +28,7 @@ from zope.app.catalog.interfaces import ICatalog
|
|||
from zope.app.event.objectevent import ObjectCreatedEvent, ObjectModifiedEvent
|
||||
from zope.app.container.contained import ObjectRemovedEvent
|
||||
from zope.app.form.browser.interfaces import ITerms
|
||||
from zope.app.form.interfaces import IDisplayWidget
|
||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||
from zope.cachedescriptors.property import Lazy
|
||||
from zope.dottedname.resolve import resolve
|
||||
|
@ -74,12 +75,15 @@ class ConceptView(BaseView):
|
|||
ti = IType(self.context).typeInterface
|
||||
if not ti: return
|
||||
adapter = ti(self.context)
|
||||
for f in ti:
|
||||
title = getattr(ti[f], 'title', '')
|
||||
value = getattr(adapter, f, '')
|
||||
if not (value and title):
|
||||
for n, f in schema.getFieldsInOrder(ti):
|
||||
value = getattr(adapter, n, '')
|
||||
if not value:
|
||||
continue
|
||||
yield {'title': title, 'value': value, 'id': f}
|
||||
bound = f.bind(adapter)
|
||||
widget = component.getMultiAdapter(
|
||||
(bound, self.request), IDisplayWidget)
|
||||
widget.setRenderedValue(value)
|
||||
yield dict(title=f.title, value=value, id=n, widget=widget)
|
||||
|
||||
def children(self):
|
||||
for r in self.context.getChildRelations():
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<tr tal:repeat="field item/fieldData">
|
||||
<td><span tal:content="field/title"
|
||||
i18n:translate="" />:</td>
|
||||
<td tal:content="nocall:field/value"></td>
|
||||
<td tal:content="structure field/widget"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<metal:listing use-macro="item/template/macros/conceptlisting2" />
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
i18n_domain="zope"
|
||||
>
|
||||
|
||||
<!-- party: person, ... -->
|
||||
<!-- party: person, address, task, ... -->
|
||||
|
||||
<zope:adapter factory="loops.organize.party.Person"
|
||||
provides="loops.organize.interfaces.IPerson"
|
||||
|
@ -25,6 +25,26 @@
|
|||
handler="loops.organize.party.removePersonReferenceFromPrincipal"
|
||||
/>
|
||||
|
||||
<zope:adapter factory="loops.organize.party.Address"
|
||||
trusted="True" />
|
||||
|
||||
<zope:class class="loops.organize.party.Address">
|
||||
<require permission="zope.View"
|
||||
interface="cybertools.organize.interfaces.IAddress" />
|
||||
<require permission="zope.ManageContent"
|
||||
set_schema="cybertools.organize.interfaces.IAddress" />
|
||||
</zope:class>
|
||||
|
||||
<zope:adapter factory="loops.organize.task.Task"
|
||||
trusted="True" />
|
||||
|
||||
<zope:class class="loops.organize.task.Task">
|
||||
<require permission="zope.View"
|
||||
interface="cybertools.organize.interfaces.ITask" />
|
||||
<require permission="zope.ManageContent"
|
||||
set_schema="cybertools.organize.interfaces.ITask" />
|
||||
</zope:class>
|
||||
|
||||
<!-- my stuff and other views -->
|
||||
|
||||
<zope:adapter
|
||||
|
@ -35,6 +55,17 @@
|
|||
factory="loops.organize.browser.MyStuff"
|
||||
permission="zope.View"
|
||||
/>
|
||||
|
||||
<!-- widget(s) -->
|
||||
|
||||
<zope:view
|
||||
type="zope.publisher.interfaces.browser.IBrowserRequest"
|
||||
for="cybertools.organize.interfaces.SimpleList
|
||||
zope.schema.interfaces.ITextLine"
|
||||
provides="zope.app.form.interfaces.IDisplayWidget"
|
||||
factory="cybertools.browser.widget.SimpleListDisplayWidget"
|
||||
permission="zope.Public"
|
||||
/>
|
||||
|
||||
<!-- member registration -->
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ from zope.schema.interfaces import ValidationError
|
|||
from zope.app.form.interfaces import WidgetInputError
|
||||
from zope.security.proxy import removeSecurityProxy
|
||||
|
||||
from cybertools.organize.interfaces import IAddress
|
||||
from cybertools.organize.party import Person as BasePerson
|
||||
from cybertools.typology.interfaces import IType
|
||||
from loops.interfaces import IConcept
|
||||
|
@ -42,7 +43,7 @@ from loops.type import TypeInterfaceSourceList, AdapterBase
|
|||
|
||||
# register IPerson as a type interface - (TODO: use a function for this)
|
||||
|
||||
TypeInterfaceSourceList.typeInterfaces += (IPerson,)
|
||||
TypeInterfaceSourceList.typeInterfaces += (IPerson, IAddress)
|
||||
|
||||
|
||||
class Person(AdapterBase, BasePerson):
|
||||
|
@ -51,7 +52,7 @@ class Person(AdapterBase, BasePerson):
|
|||
|
||||
implements(IPerson)
|
||||
|
||||
_attributes = ('context', '__parent__', 'userId',)
|
||||
_attributes = ('context', '__parent__', 'userId', 'phoneNumbers')
|
||||
_schemas = list(IPerson) + list(IConcept)
|
||||
|
||||
def getUserId(self):
|
||||
|
@ -79,6 +80,12 @@ class Person(AdapterBase, BasePerson):
|
|||
pa = annotations(principal)
|
||||
pa[ANNOTATION_KEY] = None
|
||||
|
||||
def getPhoneNumbers(self):
|
||||
return getattr(self.context, '_phoneNumbers', [])
|
||||
def setPhoneNumbers(self, value):
|
||||
self.context._phoneNumbers = value
|
||||
phoneNumbers = property(getPhoneNumbers, setPhoneNumbers)
|
||||
|
||||
@Lazy
|
||||
def authentication(self):
|
||||
return getAuthenticationUtility(self.context)
|
||||
|
@ -125,3 +132,19 @@ def removePersonReferenceFromPrincipal(context, event):
|
|||
person = IPerson(context)
|
||||
person.removeReferenceFromPrincipal(person.userId)
|
||||
|
||||
|
||||
class Address(AdapterBase):
|
||||
""" typeInterface adapter for concepts of type 'address'.
|
||||
"""
|
||||
|
||||
implements(IAddress)
|
||||
|
||||
_attributes = ('context', '__parent__', 'lines')
|
||||
_schemas = list(IAddress) + list(IConcept)
|
||||
|
||||
def getLines(self):
|
||||
return getattr(self.context, '_lines', [])
|
||||
def setLines(self, value):
|
||||
self.context._lines = value
|
||||
lines = property(getLines, setLines)
|
||||
|
||||
|
|
43
organize/task.py
Normal file
43
organize/task.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
#
|
||||
# Copyright (c) 2006 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
|
||||
#
|
||||
|
||||
"""
|
||||
Adapters for IConcept providing interfaces from the cybertools.organize package.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from zope.interface import implements
|
||||
|
||||
from cybertools.organize.interfaces import ITask
|
||||
from loops.interfaces import IConcept
|
||||
from loops.type import TypeInterfaceSourceList, AdapterBase
|
||||
|
||||
|
||||
TypeInterfaceSourceList.typeInterfaces += (ITask,)
|
||||
|
||||
|
||||
class Task(AdapterBase):
|
||||
""" typeInterface adapter for concepts of type 'task' or 'project'.
|
||||
"""
|
||||
|
||||
implements(ITask)
|
||||
|
||||
_attributes = ('context', '__parent__',)
|
||||
_schemas = list(ITask) + list(IConcept)
|
||||
|
Loading…
Add table
Reference in a new issue