Пример #1
0
from bungeni.alchemist import Session

from bungeni.models import domain
from bungeni.models import schema as model_schema
from bungeni.core.i18n import _
from bungeni.ui.forms import validations
from bungeni.ui.forms.common import ReorderForm
from bungeni.ui.forms.common import PageForm
from bungeni.ui.forms.common import AddForm
from bungeni.ui.forms.common import EditForm
from bungeni.ui.forms.common import DeleteForm


FormTemplate = namedtemplate.NamedTemplateImplementation(
    ViewPageTemplateFile('templates/form.pt')
)

ContentTemplate = namedtemplate.NamedTemplateImplementation(
    ViewPageTemplateFile('templates/content.pt')
)

def hasDeletePermission(context):
    """Generic check if the user has rights to delete the object. The
    permission must follow the convention:
    ``bungeni.<classname>.Delete`` where 'classname' is the lowercase
    of the name of the python class.
    """
    
    interaction = zope.security.management.getInteraction()
    class_name = context.__class__.__name__ 
Пример #2
0
from zope.app.pagetemplate import ViewPageTemplateFile
from zope.formlib import namedtemplate

FormTemplate = namedtemplate.NamedTemplateImplementation(
    ViewPageTemplateFile('templates/form.pt'))

SubFormTemplate = namedtemplate.NamedTemplateImplementation(
    ViewPageTemplateFile('templates/subform.pt'))
Пример #3
0
                if selected:
                    widget.setRenderedValue(value)
                elif self._renderedValueSet():
                    if field.use_default_for_not_selected:
                        widget.setRenderedValue(inner.default)
                    else:
                        widget.setRenderedValue(inner.missing_value)
            widget.setPrefix(self.name)
            choices.append({
                'selected': selected,
                'identifier': identifier,
                'widget': widget,
                'value': six.text_type(ix)
            })
        if not field.required:
            ix += 1
            selected = chosen_field is None
            identifier = "%s-%02d" % (self.name, ix)
            widget = NotChosenWidget(self.no_value_label, self.no_value_hint)
            choices.append({
                'selected': selected,
                'identifier': identifier,
                'widget': widget,
                'value': six.text_type(ix)
            })
        return self.template(choices=choices)


default_template = namedtemplate.NamedTemplateImplementation(
    ViewPageTemplateFile('unionwidget.pt'), UnionWidget)
Пример #4
0
# Licensed under GNU GPL v2 - http://www.gnu.org/licenses/gpl-2.0.txt

"""Specific forms for Bungeni user interface

$Id$
"""
log = __import__("logging").getLogger("bungeni.ui.forms.forms")

from zope.formlib import namedtemplate
from zope import interface
from zope.app.pagetemplate import ViewPageTemplateFile

from bungeni.ui.forms.common import DisplayForm

FormTemplate = namedtemplate.NamedTemplateImplementation(
    ViewPageTemplateFile("templates/form.pt")
)
SubFormTemplate = namedtemplate.NamedTemplateImplementation(
    ViewPageTemplateFile("templates/subform.pt")
)
ContentTemplate = namedtemplate.NamedTemplateImplementation(
    ViewPageTemplateFile("templates/content.pt")
)

def set_widget_errors(widgets, errors):
    """Display invariant errors / custom validation errors in the
    context of the field."""

    for widget in widgets:
        name = widget.context.getName()
        for error in errors: