From 9d65e615b983bdad59fb304c14706109e189f1cc Mon Sep 17 00:00:00 2001 From: helmutm Date: Sun, 29 Aug 2004 08:21:41 +0000 Subject: [PATCH] Added task_details view git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@92 fd906abe-77d9-0310-91a1-e0d9ade77398 --- browser/configure.zcml | 9 +++++++++ interfaces.py | 26 ++++++++++++++------------ task.py | 13 +++++++++++++ tests/test_task.py | 15 +++++++++++---- 4 files changed, 47 insertions(+), 16 deletions(-) diff --git a/browser/configure.zcml b/browser/configure.zcml index 8f53956..f3b5676 100644 --- a/browser/configure.zcml +++ b/browser/configure.zcml @@ -42,4 +42,13 @@ add="zope.ManageContent" /> + + diff --git a/interfaces.py b/interfaces.py index edb33eb..f43b864 100644 --- a/interfaces.py +++ b/interfaces.py @@ -19,7 +19,7 @@ """ loops interface definitions. -$Id: interfaces.py $ +$Id$ """ from zope.app.container.interfaces import IOrderedContainer @@ -29,6 +29,7 @@ from zope.schema import TextLine class IEntity(IOrderedContainer): """ Common base class of the Task and Resource classes. + (Not sure if we really need it...) """ def getRelations(relationships=None): @@ -65,7 +66,7 @@ class DummyIEntity: """ -class ITask(IEntity): +class ITask(IOrderedContainer): """ A Task is a scheduled piece of work. Resources may be allocated to a Task. A Task may depend on subtasks. @@ -77,12 +78,22 @@ class ITask(IEntity): default=u'', required=True) -class DummyITask: def getSubtasks(taskTypes=None): """ Return a list of subtasks of self, 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): """ Create a new task with id in container and assign it to self as a subtask. container defaults to parent of self. @@ -91,19 +102,10 @@ class DummyITask: (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): """ 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): """ Return a list of resources allocated to self, possibly restricted to the allocation types and diff --git a/task.py b/task.py index c941bc2..3e40caa 100644 --- a/task.py +++ b/task.py @@ -39,3 +39,16 @@ class Task(Entity): title = u'' #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 diff --git a/tests/test_task.py b/tests/test_task.py index b2314ea..7054dd0 100755 --- a/tests/test_task.py +++ b/tests/test_task.py @@ -1,4 +1,4 @@ -# $Id: test_task.py $ +# $Id$ import unittest from zope.testing.doctestunit import DocTestSuite @@ -12,9 +12,6 @@ from src.loops.interfaces import ITask class Test(unittest.TestCase): "Test methods of the Task class." - def makeTestObject(self): - return Task() - def testInterface(self): self.assert_(ITask.providedBy(Task()), 'Interface ITask is not implemented by class Task.') verifyClass(ITask, Task) @@ -25,6 +22,16 @@ class Test(unittest.TestCase): t.title = u'First Task' 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(): return unittest.TestSuite(( #DocTestSuite('src.loops.task'),