two type option for restricting qualifier 'assign' settings
This commit is contained in:
parent
a13f2218db
commit
1cec746423
1 changed files with 27 additions and 1 deletions
|
@ -212,15 +212,37 @@ class ObjectForm(NodeView):
|
|||
def typeManager(self):
|
||||
return ITypeManager(self.target)
|
||||
|
||||
@Lazy
|
||||
def targetType(self):
|
||||
return self.target.getType()
|
||||
|
||||
@Lazy
|
||||
def presetTypesForAssignment(self):
|
||||
types = list(self.typeManager.listTypes(include=('assign',)))
|
||||
types = []
|
||||
tn = getName(self.targetType)
|
||||
for t in self.typeManager.listTypes(include=('assign',)):
|
||||
# check if type is appropriate for the object to be created
|
||||
opt = IOptions(adapted(t.context))('qualifier_assign_to')
|
||||
#print '***', t.context.__name__, opt, tn
|
||||
if not opt or tn in opt:
|
||||
types.append(t)
|
||||
assigned = [r.context.conceptType for r in self.assignments]
|
||||
types = [t for t in types if t.typeProvider not in assigned]
|
||||
return [dict(title=t.title, token=t.tokenForSearch) for t in types]
|
||||
|
||||
def conceptsForType(self, token):
|
||||
result = ConceptQuery(self).query(type=token)
|
||||
# check typeOption: include only matching instances
|
||||
include = []
|
||||
type = self.conceptManager[token.split(':')[-1]]
|
||||
#print '###', token, repr(type)
|
||||
opt = IOptions(adapted(type))('qualifier_assign_check_parents')
|
||||
if opt:
|
||||
for p in self.target.getAllParents([self.defaultPredicate]):
|
||||
for c in p.object.getChildren([self.defaultPredicate]):
|
||||
include.append(c)
|
||||
if include:
|
||||
result = [c for c in result if c in include]
|
||||
fv = FilterView(self.context, self.request)
|
||||
result = fv.apply(result)
|
||||
result.sort(key=lambda x: x.title)
|
||||
|
@ -325,6 +347,10 @@ class CreateObjectForm(ObjectForm):
|
|||
if typeToken:
|
||||
return self.loopsRoot.loopsTraverse(typeToken)
|
||||
|
||||
@Lazy
|
||||
def targetType(self):
|
||||
return self.typeConcept
|
||||
|
||||
@Lazy
|
||||
def adapted(self):
|
||||
ad = self.typeInterface(Resource())
|
||||
|
|
Loading…
Add table
Reference in a new issue