Always strip whitespace from label profile 'spec' field input
Otherwise we can't properly load (import) the spec object...
This commit is contained in:
parent
35d4d35fd6
commit
e0bd20ee23
|
@ -28,7 +28,7 @@ from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
from .core import CustomFieldRenderer, DateFieldRenderer
|
from .core import CustomFieldRenderer, DateFieldRenderer
|
||||||
|
|
||||||
from .common import (AutocompleteFieldRenderer,
|
from .common import (StrippedTextFieldRenderer, AutocompleteFieldRenderer,
|
||||||
DecimalFieldRenderer, CurrencyFieldRenderer,
|
DecimalFieldRenderer, CurrencyFieldRenderer,
|
||||||
DateTimeFieldRenderer, DateTimePrettyFieldRenderer, TimeFieldRenderer,
|
DateTimeFieldRenderer, DateTimePrettyFieldRenderer, TimeFieldRenderer,
|
||||||
EnumFieldRenderer, YesNoFieldRenderer)
|
EnumFieldRenderer, YesNoFieldRenderer)
|
||||||
|
|
|
@ -40,6 +40,18 @@ from pyramid.renderers import render
|
||||||
from tailbone.util import pretty_datetime, raw_datetime
|
from tailbone.util import pretty_datetime, raw_datetime
|
||||||
|
|
||||||
|
|
||||||
|
class StrippedTextFieldRenderer(formalchemy.TextFieldRenderer):
|
||||||
|
"""
|
||||||
|
Standard text field renderer, which strips whitespace from either end of
|
||||||
|
the input value on deserialization.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def deserialize(self):
|
||||||
|
value = super(StrippedTextFieldRenderer, self).deserialize()
|
||||||
|
if value is not None:
|
||||||
|
return value.strip()
|
||||||
|
|
||||||
|
|
||||||
class AutocompleteFieldRenderer(FieldRenderer):
|
class AutocompleteFieldRenderer(FieldRenderer):
|
||||||
"""
|
"""
|
||||||
Custom renderer for an autocomplete field.
|
Custom renderer for an autocomplete field.
|
||||||
|
|
|
@ -32,6 +32,7 @@ import formalchemy
|
||||||
from webhelpers.html import HTML
|
from webhelpers.html import HTML
|
||||||
from pyramid.httpexceptions import HTTPFound
|
from pyramid.httpexceptions import HTTPFound
|
||||||
|
|
||||||
|
from tailbone import forms
|
||||||
from tailbone.db import Session
|
from tailbone.db import Session
|
||||||
from tailbone.views import MasterView
|
from tailbone.views import MasterView
|
||||||
from tailbone.views.continuum import VersionView, version_defaults
|
from tailbone.views.continuum import VersionView, version_defaults
|
||||||
|
@ -70,6 +71,8 @@ class ProfilesView(MasterView):
|
||||||
readonly=True)
|
readonly=True)
|
||||||
|
|
||||||
def configure_fieldset(self, fs):
|
def configure_fieldset(self, fs):
|
||||||
|
fs.printer_spec.set(renderer=forms.renderers.StrippedTextFieldRenderer)
|
||||||
|
fs.formatter_spec.set(renderer=forms.renderers.StrippedTextFieldRenderer)
|
||||||
fs.format.set(renderer=FormatFieldRenderer)
|
fs.format.set(renderer=FormatFieldRenderer)
|
||||||
fs.configure(
|
fs.configure(
|
||||||
include=[
|
include=[
|
||||||
|
|
Loading…
Reference in a new issue