Added task_details view

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@92 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2004-08-29 08:21:41 +00:00
parent 097e6a0837
commit 9d65e615b9
4 changed files with 47 additions and 16 deletions

View file

@ -42,4 +42,13 @@
add="zope.ManageContent" add="zope.ManageContent"
/> />
<page
name="details.html"
for="src.loops.interfaces.ITask"
class=".task.TaskDetails"
template="task_details.pt"
permission="zope.View"
menu="zmi_views" title="Details"
/>
</configure> </configure>

View file

@ -19,7 +19,7 @@
""" """
loops interface definitions. loops interface definitions.
$Id: interfaces.py $ $Id$
""" """
from zope.app.container.interfaces import IOrderedContainer from zope.app.container.interfaces import IOrderedContainer
@ -29,6 +29,7 @@ from zope.schema import TextLine
class IEntity(IOrderedContainer): class IEntity(IOrderedContainer):
""" Common base class of the Task and Resource classes. """ Common base class of the Task and Resource classes.
(Not sure if we really need it...)
""" """
def getRelations(relationships=None): def getRelations(relationships=None):
@ -65,7 +66,7 @@ class DummyIEntity:
""" """
class ITask(IEntity): class ITask(IOrderedContainer):
""" A Task is a scheduled piece of work. """ A Task is a scheduled piece of work.
Resources may be allocated to a Task. Resources may be allocated to a Task.
A Task may depend on subtasks. A Task may depend on subtasks.
@ -77,12 +78,22 @@ class ITask(IEntity):
default=u'', default=u'',
required=True) required=True)
class DummyITask:
def getSubtasks(taskTypes=None): def getSubtasks(taskTypes=None):
""" Return a list of subtasks of self, """ Return a list of subtasks of self,
possibly restricted to the task types given. possibly restricted to the task types given.
""" """
def assignSubtask(task):
""" Assign an existing task to self as a subtask.
Return the relation object that leads to the subtask (Really?).
"""
def getParentTasks():
""" Return a list of tasks to which self has a subtask relationship.
"""
class DummyITask:
def createSubtask(taskType=None, container=None, id=None, **props): def createSubtask(taskType=None, container=None, id=None, **props):
""" Create a new task with id in container and assign it to self as a subtask. """ Create a new task with id in container and assign it to self as a subtask.
container defaults to parent of self. container defaults to parent of self.
@ -91,19 +102,10 @@ class DummyITask:
(fetch the subtask via relation.getTarget()). (fetch the subtask via relation.getTarget()).
""" """
def assignSubtask(task):
""" Assign an existing task to self as a subtask.
Return the relation object that leads to the subtask.
"""
def deassignSubtask(task): def deassignSubtask(task):
""" Remove the subtask relation to task from self. """ Remove the subtask relation to task from self.
""" """
def getParentTasks():
""" Return a list of tasks to which self has a subtask relationship.
"""
def getAllocatedResources(allocTypes=None, resTypes=None): def getAllocatedResources(allocTypes=None, resTypes=None):
""" Return a list of resources allocated to self, """ Return a list of resources allocated to self,
possibly restricted to the allocation types and possibly restricted to the allocation types and

13
task.py
View file

@ -39,3 +39,16 @@ class Task(Entity):
title = u'' title = u''
#title = property(_getTitle, _setTitle) #title = property(_getTitle, _setTitle)
_subtasks = []
_parentTasks = []
def getSubtasks(self, taskTypes=None):
return tuple(self._subtasks)
def getParentTasks(self, taskTypes=None):
return tuple(self._parentTasks)
def assignSubtask(self, task):
self._subtasks.append(task)
task._parentTasks.append(self)
return task

View file

@ -1,4 +1,4 @@
# $Id: test_task.py $ # $Id$
import unittest import unittest
from zope.testing.doctestunit import DocTestSuite from zope.testing.doctestunit import DocTestSuite
@ -12,9 +12,6 @@ from src.loops.interfaces import ITask
class Test(unittest.TestCase): class Test(unittest.TestCase):
"Test methods of the Task class." "Test methods of the Task class."
def makeTestObject(self):
return Task()
def testInterface(self): def testInterface(self):
self.assert_(ITask.providedBy(Task()), 'Interface ITask is not implemented by class Task.') self.assert_(ITask.providedBy(Task()), 'Interface ITask is not implemented by class Task.')
verifyClass(ITask, Task) verifyClass(ITask, Task)
@ -25,6 +22,16 @@ class Test(unittest.TestCase):
t.title = u'First Task' t.title = u'First Task'
self.assertEqual(u'First Task', t.title) self.assertEqual(u'First Task', t.title)
def testSubtasks(self):
t1 = Task()
self.assertEquals((), t1.getSubtasks())
t2 = Task()
self.assertEquals((), t2.getSubtasks())
self.assertEquals((), t2.getParentTasks())
t1.assignSubtask(t2)
self.assertEquals((t2,), t1.getSubtasks())
self.assertEquals((t1,), t2.getParentTasks())
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
#DocTestSuite('src.loops.task'), #DocTestSuite('src.loops.task'),