work in progress: task management with work items

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3094 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2008-12-28 21:25:42 +00:00
parent 92bacf05d4
commit 07c98536e7
2 changed files with 45 additions and 1 deletions

View file

@ -31,6 +31,15 @@ Work Items - Plannning and Recording Activities for Tasks
>>> loopsRoot = concepts.getLoopsRoot()
>>> records = loopsRoot.getRecordManager()
>>> from cybertools.organize.work import WorkItems
>>> component.provideAdapter(WorkItems)
>>> from cybertools.organize.interfaces import IWorkItems
>>> workItems = IWorkItems(records['work'])
>>> from cybertools.organize.work import workItemStates
>>> component.provideUtility(workItemStates(), name='organize.workItemStates')
More setup
----------
@ -42,6 +51,11 @@ and a pluggable authentication utility with a principal folder.
>>> setupData = setupObjectsForTesting(site, concepts)
>>> johnC = setupData.johnC
>>> from zope.app.authentication.principalfolder import Principal
>>> pJohn = Principal('users.john', 'xxx', u'John')
>>> from loops.tests.auth import login
>>> login(pJohn)
We also assign a task as a target to the home node so that we are able
to assign work items to this task.
@ -65,8 +79,14 @@ When this form is submitted, a form controller is automatically created
for the view on the currently shown node. The data from the form is processed
by calling the form controller's update method
>>> input = {'form.action': 'create_workitem', 'workitem.action': 'finish'}
>>> #input = {'form.action': 'create_workitem', 'workitem.action': 'finish'}
>>> input = {u'comment': u'Comment', u'workitem.action': u'finish',
... u'description': u'Description', u'start_time': u'T19:24:00',
... u'form.action': u'create_workitem', u'end_time': u'T19:24:00',
... u'duration': u'1:15', u'effort': u'0:15', u'start_date': u'2008-12-28'}
>>> request = TestRequest(form=input)
>>> request.setPrincipal(pJohn)
>>> from loops.browser.node import NodeView
>>> view = NodeView(home, request)
>>> cwiController = CreateWorkItem(view, request)

View file

@ -31,8 +31,10 @@ from zope.traversing.browser import absoluteURL
from zope.traversing.api import getName
from cybertools.browser.action import actions
from cybertools.organize.interfaces import IWorkItems
from loops.browser.action import DialogAction
from loops.browser.form import ObjectForm, EditObject
from loops.organize.party import getPersonForUser
from loops.organize.tracking.browser import BaseTrackView
from loops import util
from loops.util import _
@ -65,7 +67,29 @@ class CreateWorkItemForm(ObjectForm, BaseTrackView):
class CreateWorkItem(EditObject, BaseTrackView):
@Lazy
def personId(self):
p = getPersonForUser(self.context, self.request)
if p is not None:
return util.getUidForObject(p)
return self.request.principal.id
@Lazy
def object(self):
return self.view.virtualTargetObject
@Lazy
def data(self):
result = {}
form = self.request.form
#print '***', form
return result
def update(self):
rm = self.view.loopsRoot.getRecordManager()
workItems = IWorkItems(rm.get('work'))
wi = workItems.add(util.getUidForObject(self.object), self.personId)
wi.doAction('finish', **self.data)
url = self.view.virtualTargetUrl + '?version=this'
self.request.response.redirect(url)
return False