added simple task and event handling
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2419 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
0d2bd0334a
commit
3b5132b0f6
15 changed files with 279 additions and 71 deletions
|
@ -1,4 +1,4 @@
|
|||
<!-- ZPT macros for loops.knowledge.glossary views
|
||||
<!-- ZPT macros for loops.compound.blog views
|
||||
$Id$ -->
|
||||
|
||||
<metal:block define-macro="blog">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2004 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2008 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,7 +33,7 @@ from zope.i18nmessageid import MessageFactory
|
|||
from cybertools.typology.interfaces import IType
|
||||
from loops.browser.common import BaseView
|
||||
from loops.knowledge.interfaces import IPerson, ITask
|
||||
from loops.organize.browser import getPersonForUser
|
||||
from loops.organize.party import getPersonForUser
|
||||
|
||||
_ = MessageFactory('zope')
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ from zope.security.proxy import removeSecurityProxy
|
|||
|
||||
from cybertools.knowledge.interfaces import IKnowing, IRequirementProfile
|
||||
from cybertools.knowledge.interfaces import IKnowledgeElement
|
||||
from cybertools.organize.interfaces import ITask as IBaseTask
|
||||
from loops.interfaces import IConceptSchema
|
||||
from loops.organize.interfaces import IPerson as IBasePerson
|
||||
from loops.organize.interfaces import ITask as IBaseTask
|
||||
|
||||
_ = MessageFactory('zope')
|
||||
|
||||
|
@ -43,7 +43,7 @@ class IPerson(IBasePerson, IKnowing):
|
|||
"""
|
||||
|
||||
|
||||
class ITask(IConceptSchema, IBaseTask, IRequirementProfile):
|
||||
class ITask(IBaseTask, IRequirementProfile):
|
||||
""" A task, also acting as a knowledge requirement profile.
|
||||
"""
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ and register it.
|
|||
|
||||
>>> from zope.publisher.browser import TestRequest
|
||||
>>> request = TestRequest(form=data)
|
||||
>>> from loops.organize.browser import MemberRegistration
|
||||
>>> from loops.organize.browser.member import MemberRegistration
|
||||
>>> regView = MemberRegistration(menu, request)
|
||||
>>> regView.update()
|
||||
False
|
||||
|
@ -223,7 +223,7 @@ We need a principal for testing the login stuff:
|
|||
>>> principal = InternalPrincipal('scott', 'tiger', 'Scotty')
|
||||
>>> request.setPrincipal(principal)
|
||||
|
||||
>>> from loops.organize.browser import PasswordChange
|
||||
>>> from loops.organize.browser.member import PasswordChange
|
||||
>>> pwcView = PasswordChange(menu, request)
|
||||
>>> pwcView.update()
|
||||
False
|
||||
|
@ -316,6 +316,46 @@ again to edit it...
|
|||
False
|
||||
|
||||
|
||||
Tasks and Events
|
||||
================
|
||||
|
||||
Task view with edit action
|
||||
--------------------------
|
||||
|
||||
>>> from loops.setup import addAndConfigureObject
|
||||
>>> from loops.organize.interfaces import ITask
|
||||
>>> task = addAndConfigureObject(concepts, Concept, 'task', title=u'Task',
|
||||
... conceptType=type, typeInterface=ITask)
|
||||
|
||||
>>> from loops.organize.task import Task
|
||||
>>> component.provideAdapter(Task)
|
||||
|
||||
>>> task01 = addAndConfigureObject(concepts, Concept, 'task01',
|
||||
... title=u'Task #1', conceptType=task)
|
||||
|
||||
>>> from loops.organize.browser.task import TaskView
|
||||
>>> view = TaskView(task01, TestRequest())
|
||||
>>> view.getActions('portlet')
|
||||
[<loops.browser.action.DialogAction ...>]
|
||||
|
||||
Events listing
|
||||
--------------
|
||||
|
||||
>>> event = addAndConfigureObject(concepts, Concept, 'event', title=u'Event',
|
||||
... conceptType=type, typeInterface=ITask)
|
||||
>>> event01 = addAndConfigureObject(concepts, Concept, 'event01',
|
||||
... title=u'Event #1', conceptType=event,
|
||||
... )
|
||||
|
||||
>>> from loops.organize.browser.event import Events
|
||||
>>> listing = Events(johnC, TestRequest())
|
||||
>>> listing.getActions('portlet')
|
||||
[<loops.browser.action.DialogAction ...>]
|
||||
|
||||
>>> list(listing.events())
|
||||
[<loops.browser.concept.ConceptRelationView ...>]
|
||||
|
||||
|
||||
Fin de partie
|
||||
=============
|
||||
|
||||
|
|
3
organize/browser/__init__.py
Normal file
3
organize/browser/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
"""
|
||||
$Id$
|
||||
"""
|
58
organize/browser/configure.zcml
Normal file
58
organize/browser/configure.zcml
Normal file
|
@ -0,0 +1,58 @@
|
|||
<!-- $Id$ -->
|
||||
|
||||
<configure
|
||||
xmlns:zope="http://namespaces.zope.org/zope"
|
||||
xmlns:browser="http://namespaces.zope.org/browser"
|
||||
i18n_domain="loops">
|
||||
|
||||
<zope:adapter
|
||||
name="mystuff"
|
||||
for="loops.interfaces.IConcept
|
||||
zope.publisher.interfaces.browser.IBrowserRequest"
|
||||
provides="zope.interface.Interface"
|
||||
factory="loops.organize.browser.member.MyStuff"
|
||||
permission="zope.View"
|
||||
/>
|
||||
|
||||
<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"
|
||||
/>
|
||||
|
||||
<browser:page
|
||||
for="loops.interfaces.INode"
|
||||
name="register_user.html"
|
||||
class="loops.organize.browser.member.MemberRegistration"
|
||||
permission="zope.Public"
|
||||
/>
|
||||
|
||||
<browser:page
|
||||
for="loops.interfaces.INode"
|
||||
name="change_password.html"
|
||||
class="loops.organize.browser.member.PasswordChange"
|
||||
permission="zope.Public"
|
||||
/>
|
||||
|
||||
<zope:adapter
|
||||
name="task.html"
|
||||
for="loops.interfaces.IConcept
|
||||
zope.publisher.interfaces.browser.IBrowserRequest"
|
||||
provides="zope.interface.Interface"
|
||||
factory="loops.organize.browser.task.TaskView"
|
||||
permission="zope.View"
|
||||
/>
|
||||
|
||||
<zope:adapter
|
||||
name="list_events.html"
|
||||
for="loops.interfaces.IConcept
|
||||
zope.publisher.interfaces.browser.IBrowserRequest"
|
||||
provides="zope.interface.Interface"
|
||||
factory="loops.organize.browser.event.Events"
|
||||
permission="zope.View"
|
||||
/>
|
||||
|
||||
</configure>
|
65
organize/browser/event.py
Normal file
65
organize/browser/event.py
Normal file
|
@ -0,0 +1,65 @@
|
|||
#
|
||||
# Copyright (c) 2008 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
|
||||
#
|
||||
|
||||
"""
|
||||
Definition of view classes and other browser related stuff for tasks.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from zope import interface, component
|
||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||
from zope.cachedescriptors.property import Lazy
|
||||
|
||||
from loops.browser.action import DialogAction
|
||||
from loops.browser.concept import ConceptView
|
||||
from loops.common import adapted
|
||||
from loops.util import _
|
||||
|
||||
|
||||
organize_macros = ViewPageTemplateFile('view_macros.pt')
|
||||
|
||||
|
||||
class Events(ConceptView):
|
||||
|
||||
@Lazy
|
||||
def macro(self):
|
||||
return organize_macros.macros['events']
|
||||
|
||||
def getActions(self, category='object', page=None):
|
||||
actions = []
|
||||
if category == 'portlet':
|
||||
actions.append(DialogAction(self, title=_(u'Create Event...'),
|
||||
description=_(u'Create a new event.'),
|
||||
viewName='create_concept.html',
|
||||
dialogName='createEvent',
|
||||
typeToken='.loops/concepts/event',
|
||||
fixedType=True,
|
||||
innerForm='inner_concept_form.html',
|
||||
page=page))
|
||||
self.registerDojoDateWidget()
|
||||
return actions
|
||||
|
||||
def events(self):
|
||||
cm = self.loopsRoot.getConceptManager()
|
||||
tEvent = cm['event']
|
||||
hasType = cm.getTypePredicate()
|
||||
sort = lambda x: adapted(x.second).start
|
||||
for r in tEvent.getChildRelations([hasType], sort=sort):
|
||||
yield self.childViewFactory(r, self.request, contextIsSecond=True)
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2004 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2008 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
|
||||
|
@ -17,8 +17,8 @@
|
|||
#
|
||||
|
||||
"""
|
||||
Definition of view classes and other browser related stuff for the
|
||||
loops.organize package.
|
||||
Definition of view classes and other browser related stuff for
|
||||
members (persons).
|
||||
|
||||
$Id$
|
||||
"""
|
48
organize/browser/task.py
Normal file
48
organize/browser/task.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
#
|
||||
# Copyright (c) 2008 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
|
||||
#
|
||||
|
||||
"""
|
||||
Definition of view classes and other browser related stuff for tasks.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from zope import interface, component
|
||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||
from zope.cachedescriptors.property import Lazy
|
||||
|
||||
from loops.browser.action import DialogAction
|
||||
from loops.browser.concept import ConceptView
|
||||
from loops.util import _
|
||||
|
||||
|
||||
organize_macros = ViewPageTemplateFile('view_macros.pt')
|
||||
|
||||
|
||||
class TaskView(ConceptView):
|
||||
|
||||
def getActions(self, category='object', page=None):
|
||||
actions = []
|
||||
if category == 'portlet':
|
||||
actions.append(DialogAction(self, title=_(u'Edit Task...'),
|
||||
description=_(u'Modify task.'),
|
||||
viewName='edit_concept.html',
|
||||
dialogName='editTask',
|
||||
page=page))
|
||||
self.registerDojoDateWidget()
|
||||
return actions
|
36
organize/browser/view_macros.pt
Normal file
36
organize/browser/view_macros.pt
Normal file
|
@ -0,0 +1,36 @@
|
|||
<!-- $Id$ -->
|
||||
|
||||
|
||||
<metal:data define-macro="conceptdata">
|
||||
<tal:person condition="item/person">
|
||||
<metal:block use-macro="item/concept_macros/macros/conceptdata" />
|
||||
</tal:person>
|
||||
<tal:person condition="not:item/person">
|
||||
<metal:block use-macro="item/concept_macros/macros/concepttitle" /><br />
|
||||
<div i18n:translate="">No Person object associated with your user account.</div>
|
||||
</tal:person>
|
||||
</metal:data>
|
||||
|
||||
|
||||
<metal:block define-macro="events">
|
||||
<metal:title use-macro="item/conceptMacros/concepttitle" />
|
||||
<div tal:repeat="related item/events">
|
||||
<tal:child define="data related/data">
|
||||
<h2 class="headline">
|
||||
<a href="#"
|
||||
tal:content="related/title"
|
||||
tal:attributes="href python: view.getUrlForTarget(related);">Event</a>
|
||||
</h2>
|
||||
<div class="description"
|
||||
tal:define="description data/description"
|
||||
tal:condition="description">
|
||||
<span tal:content="structure python:
|
||||
item.renderText(description, 'text/restructured')">Description</span>
|
||||
</div>
|
||||
<div class="text">
|
||||
<span tal:content="data/start">2008-02-28</span> -
|
||||
<span tal:content="data/end">2008-02-29</span>
|
||||
</div>
|
||||
</tal:child>
|
||||
</div>
|
||||
</metal:block>
|
|
@ -3,15 +3,13 @@
|
|||
<configure
|
||||
xmlns:zope="http://namespaces.zope.org/zope"
|
||||
xmlns:browser="http://namespaces.zope.org/browser"
|
||||
i18n_domain="zope"
|
||||
>
|
||||
i18n_domain="loops">
|
||||
|
||||
<!-- party: person, address, task, ... -->
|
||||
|
||||
<zope:adapter factory="loops.organize.party.Person"
|
||||
provides="loops.organize.interfaces.IPerson"
|
||||
trusted="True" />
|
||||
|
||||
<zope:class class="loops.organize.party.Person">
|
||||
<require permission="zope.View"
|
||||
interface="loops.organize.interfaces.IPerson" />
|
||||
|
@ -25,9 +23,7 @@
|
|||
handler="loops.organize.party.removePersonReferenceFromPrincipal"
|
||||
/>
|
||||
|
||||
<zope:adapter factory="loops.organize.party.Address"
|
||||
trusted="True" />
|
||||
|
||||
<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" />
|
||||
|
@ -35,38 +31,14 @@
|
|||
set_schema="cybertools.organize.interfaces.IAddress" />
|
||||
</zope:class>
|
||||
|
||||
<zope:adapter factory="loops.organize.task.Task"
|
||||
trusted="True" />
|
||||
|
||||
<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" />
|
||||
interface="loops.organize.interfaces.ITask" />
|
||||
<require permission="zope.ManageContent"
|
||||
set_schema="cybertools.organize.interfaces.ITask" />
|
||||
set_schema="loops.organize.interfaces.ITask" />
|
||||
</zope:class>
|
||||
|
||||
<!-- my stuff and other views -->
|
||||
|
||||
<zope:adapter
|
||||
name="mystuff"
|
||||
for="loops.interfaces.IConcept
|
||||
zope.publisher.interfaces.browser.IBrowserRequest"
|
||||
provides="zope.interface.Interface"
|
||||
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 -->
|
||||
|
||||
<zope:adapter factory="loops.organize.member.MemberRegistrationManager"
|
||||
|
@ -77,20 +49,6 @@
|
|||
interface="loops.organize.interfaces.IMemberRegistrationManager" />
|
||||
</zope:class>
|
||||
|
||||
<browser:page
|
||||
for="loops.interfaces.INode"
|
||||
name="register_user.html"
|
||||
class="loops.organize.browser.MemberRegistration"
|
||||
permission="zope.Public"
|
||||
/>
|
||||
|
||||
<browser:page
|
||||
for="loops.interfaces.INode"
|
||||
name="change_password.html"
|
||||
class="loops.organize.browser.PasswordChange"
|
||||
permission="zope.Public"
|
||||
/>
|
||||
|
||||
<!-- other adapters -->
|
||||
|
||||
<zope:adapter factory="loops.organize.schema.PersonSchemaFactory" />
|
||||
|
@ -110,6 +68,7 @@
|
|||
|
||||
<!-- include -->
|
||||
|
||||
<include package=".browser" />
|
||||
<include package=".personal" />
|
||||
|
||||
</configure>
|
||||
|
|
|
@ -30,6 +30,7 @@ from zope.app.security.interfaces import IAuthentication, PrincipalLookupError
|
|||
from zope.security.proxy import removeSecurityProxy
|
||||
|
||||
from cybertools.organize.interfaces import IPerson as IBasePerson
|
||||
from cybertools.organize.interfaces import ITask
|
||||
from loops.interfaces import IConceptSchema
|
||||
from loops.organize.util import getPrincipalFolder
|
||||
from loops.util import _
|
||||
|
@ -147,3 +148,10 @@ class IMemberRegistrationManager(Interface):
|
|||
Raise a Validation Error (?) if the oldPw does not match the
|
||||
current password.
|
||||
"""
|
||||
|
||||
# task
|
||||
|
||||
class ITask(IConceptSchema, ITask):
|
||||
|
||||
pass
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ $Id$
|
|||
|
||||
from zope.interface import implements
|
||||
|
||||
from cybertools.organize.interfaces import ITask
|
||||
from loops.organize.interfaces import ITask
|
||||
from loops.interfaces import IConcept
|
||||
from loops.common import AdapterBase
|
||||
from loops.type import TypeInterfaceSourceList
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<metal:data define-macro="conceptdata">
|
||||
<tal:person condition="item/person">
|
||||
<metal:block use-macro="item/concept_macros/macros/conceptdata" />
|
||||
</tal:person>
|
||||
<tal:person condition="not:item/person">
|
||||
<metal:block use-macro="item/concept_macros/macros/concepttitle" /><br />
|
||||
<div i18n:translate="">No Person object associated with your user account.</div>
|
||||
</tal:person>
|
||||
</metal:data>
|
8
view.py
8
view.py
|
@ -66,12 +66,12 @@ class View(object):
|
|||
description = property(getDescription, setDescription)
|
||||
|
||||
_viewName = u''
|
||||
def getViewName(self): return self._viewName or getattr(self, '_viewer', u'')
|
||||
def setViewName(self, viewName): self._viewName = viewName
|
||||
def getViewName(self): return self._viewName #or getattr(self, '_viewer', u'')
|
||||
def setViewName(self, viewName):
|
||||
self._viewName = viewName
|
||||
#self._viewer = u'' # BBB
|
||||
viewName = property(getViewName, setViewName)
|
||||
|
||||
viewer = property(getViewName, setViewName) # BBB
|
||||
|
||||
def getTarget(self):
|
||||
rels = getRelations(first=self, relationships=[TargetRelation])
|
||||
if len(rels) == 0:
|
||||
|
|
Loading…
Add table
Reference in a new issue