
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2582 fd906abe-77d9-0310-91a1-e0d9ade77398
94 lines
2.4 KiB
Python
94 lines
2.4 KiB
Python
#
|
|
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
#
|
|
|
|
"""
|
|
View class(es) for tracking storage and tracks.
|
|
|
|
$Id$
|
|
"""
|
|
|
|
from zope import component
|
|
from zope.app.pagetemplate import ViewPageTemplateFile
|
|
from zope.cachedescriptors.property import Lazy
|
|
from zope.security.proxy import removeSecurityProxy
|
|
from zope.traversing.api import getName
|
|
from zope.traversing.browser import absoluteURL
|
|
|
|
from cybertools.container.base import ContainerView, contents_template
|
|
from cybertools.tracking.btree import timeStamp2ISO
|
|
|
|
|
|
tracking_template = ViewPageTemplateFile('tracking.pt')
|
|
|
|
|
|
class TrackingStorageView(ContainerView):
|
|
|
|
contents_template = contents_template
|
|
template = tracking_template
|
|
|
|
def __call__(self):
|
|
return self.template()
|
|
|
|
def getTracks(self):
|
|
for tr in reversed(removeSecurityProxy(self.context.values())):
|
|
view = component.queryMultiAdapter((tr, self.request))
|
|
if view:
|
|
yield view
|
|
else:
|
|
yield TrackView(tr, self.request)
|
|
|
|
|
|
class TrackView(object):
|
|
|
|
def __init__(self, context, request):
|
|
self.context = context
|
|
self.request = request
|
|
|
|
@Lazy
|
|
def id(self):
|
|
return getName(self.context)
|
|
|
|
@Lazy
|
|
def url(self):
|
|
return absoluteURL(self.context, self.request)
|
|
|
|
@Lazy
|
|
def metadata(self):
|
|
return self.context.metadata
|
|
|
|
@Lazy
|
|
def task(self):
|
|
return self.metadata['taskId']
|
|
|
|
taskTitle = task
|
|
taskUrl = None
|
|
|
|
@Lazy
|
|
def run(self):
|
|
return self.metadata['runId']
|
|
|
|
@Lazy
|
|
def user(self):
|
|
return self.metadata['userName']
|
|
|
|
userTitle = user
|
|
userUrl = None
|
|
|
|
@Lazy
|
|
def timeStamp(self):
|
|
return timeStamp2ISO(self.metadata['timeStamp'])
|