work in progress: task management: creation of work items OK
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3097 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
07c98536e7
commit
a77166dfee
4 changed files with 67 additions and 23 deletions
|
@ -79,11 +79,10 @@ 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 = {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'}
|
||||
>>> input = {u'form.action': u'create_workitem', u'workitem.action': u'finish',
|
||||
... u'description': u'Description', u'comment': u'Comment',
|
||||
... u'start_date': u'2008-12-28', u'start_time': u'T19:00:00',
|
||||
... u'end_time': u'T20:15:00', u'duration': u'1:15', u'effort': u'0:15'}
|
||||
>>> request = TestRequest(form=input)
|
||||
>>> request.setPrincipal(pJohn)
|
||||
|
||||
|
@ -94,6 +93,18 @@ by calling the form controller's update method
|
|||
>>> cwiController.update()
|
||||
False
|
||||
|
||||
>>> list(workItems)
|
||||
[<WorkItem ['36', 1, '33', '2008-12-28 19:15', 'finished']:
|
||||
{'comment': u'Comment', 'end': 1230491700, 'description': u'Description',
|
||||
'created': ..., 'creator': '33', 'assigned': ...,
|
||||
'start': 1230487200, 'duration': 4500, 'effort': 900}>]
|
||||
|
||||
>>> from loops.organize.work.browser import WorkItemView
|
||||
>>> wi01 = workItems['0000001']
|
||||
>>> view = WorkItemView(wi01, TestRequest())
|
||||
>>> view.taskUrl
|
||||
'http://127.0.0.1/loops/concepts/loops_dev/@@SelectedManagementView.html'
|
||||
|
||||
|
||||
Fin de partie
|
||||
=============
|
||||
|
|
|
@ -78,18 +78,41 @@ class CreateWorkItem(EditObject, BaseTrackView):
|
|||
def object(self):
|
||||
return self.view.virtualTargetObject
|
||||
|
||||
@Lazy
|
||||
def data(self):
|
||||
result = {}
|
||||
def processForm(self):
|
||||
form = self.request.form
|
||||
#print '***', form
|
||||
return result
|
||||
action = form.get('workitem.action')
|
||||
if not action:
|
||||
return None, {}
|
||||
result = dict()
|
||||
def setValue(k):
|
||||
v = form.get(k)
|
||||
if v:
|
||||
result[k] = v
|
||||
for k in ('description', 'comment'):
|
||||
setValue(k)
|
||||
startDate = form.get('start_date')
|
||||
startTime = form.get('start_time')
|
||||
endTime = form.get('end_time')
|
||||
if startDate and startTime:
|
||||
result['start'] = parseDateTime(startDate + startTime)
|
||||
if startDate and endTime:
|
||||
result['end'] = parseDateTime(startDate + endTime)
|
||||
duration = form.get('duration')
|
||||
if duration:
|
||||
result['duration'] = parseTime(duration)
|
||||
effort = form.get('effort')
|
||||
if effort:
|
||||
result['effort'] = parseTime(effort)
|
||||
return action, result
|
||||
|
||||
def update(self):
|
||||
rm = self.view.loopsRoot.getRecordManager()
|
||||
workItems = IWorkItems(rm.get('work'))
|
||||
action, data = self.processForm()
|
||||
if not action:
|
||||
return True
|
||||
wi = workItems.add(util.getUidForObject(self.object), self.personId)
|
||||
wi.doAction('finish', **self.data)
|
||||
wi.doAction(action, **data)
|
||||
url = self.view.virtualTargetUrl + '?version=this'
|
||||
self.request.response.redirect(url)
|
||||
return False
|
||||
|
@ -104,3 +127,16 @@ actions.register('createWorkitem', 'portlet', DialogAction,
|
|||
dialogName='createWorkitem',
|
||||
prerequisites=['registerDojoDateWidget', 'registerDojoNumberWidget'],
|
||||
)
|
||||
|
||||
|
||||
# auxiliary functions
|
||||
|
||||
def parseTime(s):
|
||||
if ':' in s:
|
||||
h, m = [int(v) for v in s.split(':')]
|
||||
else:
|
||||
h, m = int(s), 0
|
||||
return h * 3600 + m * 60
|
||||
|
||||
def parseDateTime(s):
|
||||
return int(time.mktime(time.strptime(s, '%Y-%m-%dT%H:%M:%S')))
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
<zope:class class="loops.organize.work.base.WorkItem">
|
||||
<require permission="zope.View"
|
||||
interface="cybertools.organize.work.IWorkItem" />
|
||||
<require permission="zope.View"
|
||||
attributes="getName" />
|
||||
<require permission="zope.ManageContent"
|
||||
set_schema="cybertools.organize.work.IWorkItem" />
|
||||
</zope:class>
|
||||
|
|
|
@ -21,29 +21,24 @@
|
|||
<label i18n:translate=""
|
||||
for="start-end">Start - End</label>
|
||||
<div id="start-end">
|
||||
<input type="text" style="width: 8em"
|
||||
<input type="text" name="start_date" style="width: 8em"
|
||||
dojoType="dijit.form.DateTextBox"
|
||||
name="start_date" required="true"
|
||||
tal:attributes="value view/defaultDate" />
|
||||
<input type="text" style="width: 6em"
|
||||
<input type="text" name="start_time" style="width: 6em"
|
||||
dojoType="dijit.form.TimeTextBox"
|
||||
name="start_time" required="true"
|
||||
tal:attributes="value view/defaultTime" /> -
|
||||
<input type="text" style="width: 6em"
|
||||
<input type="text" name="end_time" style="width: 6em"
|
||||
dojoType="dijit.form.TimeTextBox"
|
||||
name="end_time" required="true"
|
||||
tal:attributes="value view/defaultTime" /></div>
|
||||
<label i18n:translate=""
|
||||
for="duration-effort">Duration / Effort (hh:mm)</label>
|
||||
<div id="duration-effort">
|
||||
<input type="text" style="width: 5em"
|
||||
<input type="text" name="duration" style="width: 5em"
|
||||
dojoType="dijit.form.ValidationTextBox"
|
||||
regexp="[0-9]{1,2}(:[0-5][0-9]){0,1}"
|
||||
name="duration" /> /
|
||||
<input type="text" style="width: 5em"
|
||||
regexp="[0-9]{1,2}(:[0-5][0-9]){0,1}" /> /
|
||||
<input type="text" name="effort" style="width: 5em"
|
||||
dojoType="dijit.form.ValidationTextBox"
|
||||
regexp="[0-9]{1,2}(:[0-5][0-9]){0,1}"
|
||||
name="effort" /></div>
|
||||
regexp="[0-9]{1,2}(:[0-5][0-9]){0,1}" /></div>
|
||||
</div>
|
||||
<div>
|
||||
<label i18n:translate=""
|
||||
|
|
Loading…
Add table
Reference in a new issue