work in progress: editing forms/dialogs for concepts
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2111 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
a5847a6fb2
commit
330c86bb48
5 changed files with 60 additions and 29 deletions
|
@ -557,6 +557,13 @@
|
||||||
permission="zope.ManageContent"
|
permission="zope.ManageContent"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<page
|
||||||
|
name="edit_concept.html"
|
||||||
|
for="loops.interfaces.INode"
|
||||||
|
class="loops.browser.form.EditConceptForm"
|
||||||
|
permission="zope.ManageContent"
|
||||||
|
/>
|
||||||
|
|
||||||
<page
|
<page
|
||||||
name="inner_form.html"
|
name="inner_form.html"
|
||||||
for="loops.interfaces.INode"
|
for="loops.interfaces.INode"
|
||||||
|
|
|
@ -33,7 +33,7 @@ from zope.app.form.browser.textwidgets import FileWidget, TextAreaWidget
|
||||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope.contenttype import guess_content_type
|
from zope.contenttype import guess_content_type
|
||||||
from zope.formlib.form import Form, EditForm, FormFields
|
#from zope.formlib.form import Form, EditForm, FormFields
|
||||||
from zope.publisher.browser import FileUpload
|
from zope.publisher.browser import FileUpload
|
||||||
from zope.publisher.interfaces import BadRequest
|
from zope.publisher.interfaces import BadRequest
|
||||||
from zope.security.proxy import isinstance, removeSecurityProxy
|
from zope.security.proxy import isinstance, removeSecurityProxy
|
||||||
|
@ -67,17 +67,26 @@ class ObjectForm(NodeView):
|
||||||
|
|
||||||
template = ViewPageTemplateFile('form_macros.pt')
|
template = ViewPageTemplateFile('form_macros.pt')
|
||||||
formState = FormState() # dummy, don't update!
|
formState = FormState() # dummy, don't update!
|
||||||
|
isInnerHtml = True
|
||||||
|
|
||||||
def __init__(self, context, request):
|
def __init__(self, context, request):
|
||||||
super(ObjectForm, self).__init__(context, request)
|
super(ObjectForm, self).__init__(context, request)
|
||||||
|
# target is the object the view acts upon - this is not necessarily
|
||||||
|
# the same object as the context (the object the view was created for)
|
||||||
|
self.target = context
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def item(self):
|
||||||
|
# show this view on the page instead of the node's view
|
||||||
|
return self
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def adapted(self):
|
def adapted(self):
|
||||||
return adapted(self.context)
|
return adapted(self.target)
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def typeInterface(self):
|
def typeInterface(self):
|
||||||
return IType(self.context).typeInterface or ITextDocument
|
return IType(self.target).typeInterface or ITextDocument
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def fieldRenderers(self):
|
def fieldRenderers(self):
|
||||||
|
@ -110,13 +119,16 @@ class ObjectForm(NodeView):
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def instance(self):
|
def instance(self):
|
||||||
return IInstance(adapted(self.context))
|
return IInstance(self.adapted)
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
response = self.request.response
|
if self.isInnerHtml:
|
||||||
response.setHeader('Expires', 'Sat, 1 Jan 2000 00:00:00 GMT')
|
response = self.request.response
|
||||||
response.setHeader('Pragma', 'no-cache')
|
response.setHeader('Expires', 'Sat, 1 Jan 2000 00:00:00 GMT')
|
||||||
return innerHtml(self)
|
response.setHeader('Pragma', 'no-cache')
|
||||||
|
return innerHtml(self)
|
||||||
|
else:
|
||||||
|
return super(ObjectForm, self).__call__()
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def defaultPredicate(self):
|
def defaultPredicate(self):
|
||||||
|
@ -128,7 +140,7 @@ class ObjectForm(NodeView):
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def typeManager(self):
|
def typeManager(self):
|
||||||
return ITypeManager(self.context)
|
return ITypeManager(self.target)
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def presetTypesForAssignment(self):
|
def presetTypesForAssignment(self):
|
||||||
|
@ -147,9 +159,9 @@ class ObjectForm(NodeView):
|
||||||
for o in result])
|
for o in result])
|
||||||
|
|
||||||
|
|
||||||
class EditObjectForm(ObjectForm, EditForm):
|
class EditObjectForm(ObjectForm):
|
||||||
|
|
||||||
@property
|
@Lazy
|
||||||
def macro(self):
|
def macro(self):
|
||||||
return self.template.macros['edit']
|
return self.template.macros['edit']
|
||||||
|
|
||||||
|
@ -159,18 +171,36 @@ class EditObjectForm(ObjectForm, EditForm):
|
||||||
|
|
||||||
def __init__(self, context, request):
|
def __init__(self, context, request):
|
||||||
super(EditObjectForm, self).__init__(context, request)
|
super(EditObjectForm, self).__init__(context, request)
|
||||||
self.url = self.url # keep virtual target URL (???)
|
#self.url = self.url # keep virtual target URL (???)
|
||||||
self.context = self.virtualTargetObject
|
self.target = self.virtualTargetObject
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def assignments(self):
|
def assignments(self):
|
||||||
for c in self.context.getConceptRelations():
|
for c in self.target.getConceptRelations():
|
||||||
r = ConceptRelationView(c, self.request)
|
r = ConceptRelationView(c, self.request)
|
||||||
if r.isProtected: continue
|
if r.isProtected: continue
|
||||||
yield r
|
yield r
|
||||||
|
|
||||||
|
|
||||||
class CreateObjectForm(ObjectForm, Form):
|
class EditConceptForm(EditObjectForm):
|
||||||
|
|
||||||
|
title = _(u'Edit Concept')
|
||||||
|
form_action = 'edit_concept'
|
||||||
|
isInnerHtml = False
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def typeInterface(self):
|
||||||
|
return IType(self.target).typeInterface or IConcept
|
||||||
|
|
||||||
|
@property
|
||||||
|
def assignments(self):
|
||||||
|
for c in self.target.getParentRelations():
|
||||||
|
r = ConceptRelationView(c, self.request)
|
||||||
|
if not r.isProtected:
|
||||||
|
yield r
|
||||||
|
|
||||||
|
|
||||||
|
class CreateObjectForm(ObjectForm):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def macro(self): return self.template.macros['create']
|
def macro(self): return self.template.macros['create']
|
||||||
|
@ -200,6 +230,7 @@ class CreateObjectForm(ObjectForm, Form):
|
||||||
@property
|
@property
|
||||||
def assignments(self):
|
def assignments(self):
|
||||||
target = self.virtualTargetObject
|
target = self.virtualTargetObject
|
||||||
|
#target = self.target
|
||||||
if (IConcept.providedBy(target) and
|
if (IConcept.providedBy(target) and
|
||||||
target.conceptType !=
|
target.conceptType !=
|
||||||
self.loopsRoot.getConceptManager().getTypeConcept()):
|
self.loopsRoot.getConceptManager().getTypeConcept()):
|
||||||
|
|
|
@ -403,7 +403,7 @@ class InlineEdit(NodeView):
|
||||||
return 'OK'
|
return 'OK'
|
||||||
|
|
||||||
|
|
||||||
class CreateObject(NodeView, Form):
|
class xxxCreateObject(NodeView, Form):
|
||||||
|
|
||||||
template = ViewPageTemplateFile('form_macros.pt')
|
template = ViewPageTemplateFile('form_macros.pt')
|
||||||
|
|
||||||
|
|
|
@ -64,19 +64,6 @@ class MyStuff(ConceptView):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
#class PasswordWidget(BasePasswordWidget):
|
|
||||||
#
|
|
||||||
# def getInputValue(self):
|
|
||||||
# value = super(PasswordWidget, self).getInputValue()
|
|
||||||
# confirm = self.request.get('form.passwordConfirm')
|
|
||||||
# if confirm != value:
|
|
||||||
# v = _(u'Password and password confirmation do not match.')
|
|
||||||
# self._error = WidgetInputError(
|
|
||||||
# self.context.__name__, self.label, v)
|
|
||||||
# raise self._error
|
|
||||||
# return value
|
|
||||||
|
|
||||||
|
|
||||||
class MemberRegistration(NodeView, CreateForm):
|
class MemberRegistration(NodeView, CreateForm):
|
||||||
|
|
||||||
interface = IMemberRegistration
|
interface = IMemberRegistration
|
||||||
|
|
|
@ -47,6 +47,9 @@ def raiseValidationError(info):
|
||||||
|
|
||||||
|
|
||||||
class UserId(schema.TextLine):
|
class UserId(schema.TextLine):
|
||||||
|
""" Obsolete, as member registration does not use zope.formlib any more.
|
||||||
|
TODO: transfer validation to loops.organize.browser.
|
||||||
|
"""
|
||||||
|
|
||||||
def _validate(self, userId):
|
def _validate(self, userId):
|
||||||
from loops.organize.party import getPersonForUser
|
from loops.organize.party import getPersonForUser
|
||||||
|
@ -68,6 +71,9 @@ class UserId(schema.TextLine):
|
||||||
|
|
||||||
|
|
||||||
class LoginName(schema.TextLine):
|
class LoginName(schema.TextLine):
|
||||||
|
""" Obsolete, as member registration does not use zope.formlib any more.
|
||||||
|
TODO: transfer validation to loops.organize.browser.
|
||||||
|
"""
|
||||||
|
|
||||||
def _validate(self, userId):
|
def _validate(self, userId):
|
||||||
super(LoginName, self)._validate(userId)
|
super(LoginName, self)._validate(userId)
|
||||||
|
|
Loading…
Add table
Reference in a new issue