Esempio n. 1
0
class ISimpleMenuItem(IViewlet):
    """Simple menu item."""

    title = zope.schema.TextLine(
        title=_(u'Title'),
        description=_(u'The menu title.'),
        default=u'',
        readonly=True,
        required=False)

    url = zope.schema.TextLine(
        title=_(u'URL'),
        description=_(u'The url the menu points to.'),
        default=u'',
        readonly=True,
        required=False)

    extras = zope.schema.Dict(
        title=_(u'Extras'),
        description=_(u'Extra values usefull for custom attributes.'),
        key_type=zope.schema.TextLine(title=u'Key'),
        value_type=zope.schema.TextLine(title=u'Value')
    )

    selected = zope.schema.Bool(
        title=_(u"Required"),
        default=False,
        required=False)

    css = zope.schema.TextLine(
        title=_(u'CSS'),
        description=_(u'The css class depending on the selected stati.'),
        default=u'',
        readonly=True,
        required=False)
Esempio n. 2
0
 def getInputValue(self):
     """See zope.app.form.interfaces.IInputWidget"""
     self._error = None
     try:
         return u'-'.join((self.widgets['first'].getInputValue(),
                           self.widgets['second'].getInputValue(),
                           self.widgets['third'].getInputValue()))
     except ValueError, v:
         self._error = WidgetInputError(self.context.__name__, self.label,
                                        _(v))
         raise self._error
Esempio n. 3
0
 def getInputValue(self):
     """See zope.app.form.interfaces.IInputWidget"""
     self._error = None
     year = self.widgets['year'].getInputValue()
     month = self.widgets['month'].getInputValue()
     day = self.widgets['day'].getInputValue()
     try:
         return datetime.date(year, month, day)
     except ValueError, v:
         self._error = WidgetInputError(self.context.__name__, self.label,
                                        _(v))
         raise self._error
Esempio n. 4
0
 def getInputValue(self):
     """See zope.app.form.interfaces.IInputWidget"""
     self._error = None
     year = self.widgets['year'].getInputValue()
     month = self.widgets['month'].getInputValue()
     day = self.widgets['day'].getInputValue()
     try:
         return datetime.date(year, month, day)
     except ValueError, v:
         self._error = WidgetInputError(
             self.context.__name__, self.label, _(v))
         raise self._error
Esempio n. 5
0
 def getInputValue(self):
     """See zope.app.form.interfaces.IInputWidget"""
     self._error = None
     try:
         return u'-'.join((
             self.widgets['first'].getInputValue(),
             self.widgets['second'].getInputValue(),
             self.widgets['third'].getInputValue() ))
     except ValueError, v:
         self._error = WidgetInputError(
             self.context.__name__, self.label, _(v))
         raise self._error
Esempio n. 6
0
class IPhoneData(zope.interface.Interface):
    """A schema used to generate a Phone widget."""

    first = zope.schema.TextLine(
        title=_('Area Code'),
        description=_('The area code of the phone number.'),
        min_length=3,
        max_length=3,
        constraint=re.compile(r'^[0-9]{3}$').search,
        required=True)

    second = zope.schema.TextLine(
        title=_('Three Digits'),
        description=_('The first three digits of the phone number.'),
        min_length=3,
        max_length=3,
        constraint=re.compile(r'^[0-9]{3}$').search,
        required=True)

    third = zope.schema.TextLine(
        title=_('Four Digits'),
        description=_('The second four digits of the phone number.'),
        min_length=4,
        max_length=4,
        constraint=re.compile(r'^[0-9]{4}$').search,
        required=True)
Esempio n. 7
0
class ISSNData(zope.interface.Interface):
    """A schema used to generate a SSN widget."""

    first = zope.schema.TextLine(
        title=_('Frst three digits'),
        description=_('The first three digits of the SSN.'),
        min_length=3,
        max_length=3,
        constraint=re.compile(r'^[0-9]{3}$').search,
        required=True)

    second = zope.schema.TextLine(
        title=_('Second two digits'),
        description=_('The second two digits of the SSN.'),
        min_length=2,
        max_length=2,
        constraint=re.compile(r'^[0-9]{2}$').search,
        required=True)

    third = zope.schema.TextLine(
        title=_('Third four digits'),
        description=_('The third four digits of the SSN.'),
        min_length=4,
        max_length=4,
        constraint=re.compile(r'^[0-9]{4}$').search,
        required=True)
Esempio n. 8
0
class IDateSelectData(zope.interface.Interface):
    """A schema used to generate a date widget."""

    year = zope.schema.Choice(title=_('Year'),
                              description=_('The year.'),
                              source=WidgetDataSource(),
                              required=True)

    month = zope.schema.Choice(title=_('Month'),
                               description=_('The month.'),
                               values=range(1, 13),
                               required=True)

    day = zope.schema.Choice(title=_('Day'),
                             description=_('The day.'),
                             values=range(1, 32),
                             required=True)

    yearRange = zope.interface.Attribute(u"Year range.")
Esempio n. 9
0
 def title(self):
     return _(self.__name__)