Merge branch 'master' into bbmaster
This commit is contained in:
commit
5fc606bbd3
4 changed files with 33 additions and 5 deletions
|
@ -69,7 +69,8 @@ class Report(Template):
|
||||||
|
|
||||||
implements(IReport)
|
implements(IReport)
|
||||||
|
|
||||||
name = identifier = title = description = u''
|
name = identifier = u''
|
||||||
|
#title = description = u''
|
||||||
type = 'generic'
|
type = 'generic'
|
||||||
manager = None
|
manager = None
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
<metal:fields define-macro="fields">
|
<metal:fields define-macro="fields">
|
||||||
<tal:define define="manageMode manageMode|view/manageMode|nothing;
|
<tal:define define="manageMode manageMode|view/manageMode|nothing;
|
||||||
fields view/fields;
|
fields view/fields;
|
||||||
|
instance view/instance;
|
||||||
data view/data;
|
data view/data;
|
||||||
state view/formState">
|
state view/formState">
|
||||||
<table style="width: 100%">
|
<table style="width: 100%">
|
||||||
|
@ -160,7 +161,8 @@
|
||||||
tal:attributes="name name;
|
tal:attributes="name name;
|
||||||
style python:
|
style python:
|
||||||
'width: %s' % (width and str(width)+'px' or '');">
|
'width: %s' % (width and str(width)+'px' or '');">
|
||||||
<option tal:repeat="item field/getVocabularyItems"
|
<option tal:repeat="item python:
|
||||||
|
field.getVocabularyItems(instance.context, request)"
|
||||||
tal:content="item/title"
|
tal:content="item/title"
|
||||||
tal:attributes="value item/token;
|
tal:attributes="value item/token;
|
||||||
selected python:
|
selected python:
|
||||||
|
|
|
@ -25,12 +25,14 @@ $Id$
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from time import strptime, strftime
|
from time import strptime, strftime
|
||||||
|
from zope.app.form.browser.interfaces import ITerms
|
||||||
from zope.interface import implements
|
from zope.interface import implements
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope.component import adapts
|
from zope.component import adapts
|
||||||
from zope import component
|
from zope import component
|
||||||
from zope.i18n.format import DateTimeParseError
|
from zope.i18n.format import DateTimeParseError
|
||||||
from zope.i18n.locales import locales
|
from zope.i18n.locales import locales
|
||||||
|
from zope.schema.interfaces import IVocabularyFactory
|
||||||
from zope.tales.engine import Engine
|
from zope.tales.engine import Engine
|
||||||
from zope.tales.tales import Context
|
from zope.tales.tales import Context
|
||||||
|
|
||||||
|
@ -129,14 +131,29 @@ class Field(Component):
|
||||||
def getTitleValue(self):
|
def getTitleValue(self):
|
||||||
return self.title or self.name
|
return self.title or self.name
|
||||||
|
|
||||||
def getVocabularyItems(self):
|
def getVocabularyItems(self, context=None, request=None):
|
||||||
voc = (self.vocabulary or '')
|
voc = (self.vocabulary or '')
|
||||||
if isinstance(voc, basestring):
|
if isinstance(voc, basestring):
|
||||||
|
terms = self.getVocabularyTerms(voc, context, request)
|
||||||
|
if terms is not None:
|
||||||
|
return terms
|
||||||
voc = voc.splitlines()
|
voc = voc.splitlines()
|
||||||
return [dict(token=t, title=t) for t in voc if t.strip()]
|
return [dict(token=t, title=t) for t in voc if t.strip()]
|
||||||
else:
|
else:
|
||||||
return [dict(token=t.token, title=t.title or t.value) for t in voc]
|
return [dict(token=t.token, title=t.title or t.value) for t in voc]
|
||||||
|
|
||||||
|
def getVocabularyTerms(self, name, context, request):
|
||||||
|
if context is None or request is None:
|
||||||
|
return None
|
||||||
|
source = component.queryUtility(IVocabularyFactory, name=name)
|
||||||
|
if source is not None:
|
||||||
|
source = source(context)
|
||||||
|
terms = component.queryMultiAdapter((source, request), ITerms)
|
||||||
|
if terms is not None:
|
||||||
|
termsList = [terms.getTerm(value) for value in source]
|
||||||
|
return [dict(token=t.token, title=t.title) for t in termsList]
|
||||||
|
return None
|
||||||
|
|
||||||
def getFieldTypeInfo(self):
|
def getFieldTypeInfo(self):
|
||||||
return self.fieldTypeInfo or fieldTypes.getTerm(self.fieldType)
|
return self.fieldTypeInfo or fieldTypes.getTerm(self.fieldType)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2010 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -68,7 +68,15 @@ class Track(Persistent):
|
||||||
def metadata(self):
|
def metadata(self):
|
||||||
return dict((attr, getattr(self, attr)) for attr in self.metadata_attributes)
|
return dict((attr, getattr(self, attr)) for attr in self.metadata_attributes)
|
||||||
|
|
||||||
indexdata = metadata
|
@property
|
||||||
|
def indexdata(self):
|
||||||
|
data = {}
|
||||||
|
for attr in self.index_attributes:
|
||||||
|
if attr in self.metadata_attributes:
|
||||||
|
data[attr] = getattr(self, attr)
|
||||||
|
else:
|
||||||
|
data[attr] = self.data[attr]
|
||||||
|
return data
|
||||||
|
|
||||||
def __init__(self, taskId, runId, userName, data=None):
|
def __init__(self, taskId, runId, userName, data=None):
|
||||||
self.taskId = taskId
|
self.taskId = taskId
|
||||||
|
|
Loading…
Add table
Reference in a new issue