first steps towards assigning subtasks through the web

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@367 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2005-05-21 11:33:10 +00:00
parent 3e4f65cac3
commit 10d9d20403
7 changed files with 94 additions and 9 deletions

View file

@ -1,4 +1,4 @@
"""
$Id: __init__.py $
$Id$
"""

View file

@ -39,13 +39,37 @@
add="zope.ManageContent"
/>
<defaultView
for="loops.interfaces.ITask"
name="details.html"
/>
<page
name="details.html"
for="loops.interfaces.ITask"
class=".task.TaskDetails"
class=".task.Details"
template="task_details.pt"
permission="zope.View"
menu="zmi_views" title="Details"
/>
<pages
for="loops.interfaces.ITask"
class=".task.SubtaskAssignments"
permission="zope.ManageContent"
>
<page
name="subtasks.html"
template="subtasks_assign.pt"
menu="zmi_views" title="Subtasks"
/>
<page
name="subtask_assign"
attribute="assignSubtask"
/>
</pages>
</configure>

View file

@ -0,0 +1,47 @@
<html metal:use-macro="views/standard_macros/view">
<head>
<style metal:fill-slot="style_slot">
</style>
</head>
<body>
<div metal:fill-slot="body">
<h1 tal:content="context/title">Task Title</h1>
<div class="row">
<span class="label">Subtasks</span>:
<span class="field"
tal:repeat="task context/getSubtasks">
<span tal:content="task/title">subtask</span>
<span class="field" tal:condition="not:repeat/task/end"> - </span>
</span>
</div>
<div class="row">
<span class="label">Parent Tasks</span>:
<span class="field"
tal:repeat="task context/getParentTasks">
<span tal:content="task/title">parent task</span>
<span class="field" tal:condition="not:repeat/task/end"> - </span>
</span>
</div>
<div class="row">
<span class="label">Last Modified</span>:
<span class="field" tal:content="view/modified">2004-08-28</span>
</div>
<form action="." method="post"
tal:attributes="action context/@@absolute_url">
<div class="row">
<span class="label">Subtasks</span>:
<span class="field">
<input type="test" name="subtaskPath" />
</span>
</div>
<div class="row">
<input type="submit" name="subtask_assign:method" value="Assign Subtask" />
</div>
</form>
</div>
</body>
</html>

View file

@ -24,10 +24,11 @@ $Id$
from zope.app import zapi
from zope.app.dublincore.interfaces import ICMFDublinCore
from zope.security.proxy import removeSecurityProxy
from loops.interfaces import ITask
class TaskDetails:
class Details:
def modified(self):
""" get date/time of last modification
@ -36,3 +37,16 @@ class TaskDetails:
d = dc.modified or dc.created
return d and d.strftime('%Y-%m-%d %H:%M') or ''
class SubtaskAssignments(Details):
def assignSubtask(self):
""" Add a subtask denoted by the path given in the
request variable subtaskPath.
"""
subtaskPath = self.request.get('subtaskPath')
#if subtaskPath:
subtask = zapi.traverse(zapi.getRoot(self.context), subtaskPath, None, self.request)
#if subtask:
self.context.assignSubtask(removeSecurityProxy(subtask))
self.request.response.redirect('.')

View file

@ -59,8 +59,8 @@ class Task(OrderedContainer):
return tuple(self._parentTasks)
def assignSubtask(self, task):
self._subtasks.append(task)
task._parentTasks.append(self)
self._subtasks = self._subtasks + [task]
task._parentTasks = task._parentTasks + [self]
def createSubtask(self, taskType=None, container=None, name=None):
container = container or zapi.getParent(self)

View file

@ -1,4 +1,4 @@
"""
$Id: __init__.py $
$Id$
"""

View file

@ -1,10 +1,10 @@
# $Id$
import unittest
#from zope.testing.doctestunit import DocTestSuite
from zope.testing.doctestunit import DocTestSuite
from zope.interface.verify import verifyClass
#from zope.app.tests.setup import placelessSetUp
from zope.app.tests.setup import placefulSetUp
from zope.app.testing.setup import placefulSetUp
#from zope.app.container.tests.test_icontainer import TestSampleContainer
from zope.app.container.interfaces import IContained
from zope.app.folder import Folder
@ -244,7 +244,7 @@ class TestTaskCopy(unittest.TestCase):
def test_suite():
return unittest.TestSuite((
# DocTestSuite('loops.tests.doctests'),
DocTestSuite('loops.tests.doctests'),
unittest.makeSuite(TestTask),
unittest.makeSuite(TestTaskResource),
unittest.makeSuite(TestTaskResourceConstraints),