예제 #1
0
        data = {}
        showFields = getattr(self, 'showFields', []) or self.getColumnNames()
        for f in fields:
            if f not in showFields:
                continue
            data[f] = fields[f]

        if self.ExtraData:
            for f in self.ExtraData:
                if f == 'dt':
                    data[f] = str(DateTime())
                else:
                    data[f] = getattr(request, f, '')

        self.addDataRow(data)


MailerAction = ActionFactory(Mailer,
                             _(u'label_mailer_action', default=u'Mailer'),
                             'collective.easyform.AddMailers')
CustomScriptAction = ActionFactory(
    CustomScript, _(u'label_customscript_action', default=u'Custom Script'),
    'collective.easyform.AddCustomScripts')
SaveDataAction = ActionFactory(
    SaveData, _(u'label_savedata_action', default=u'Daten sammeln'),
    'collective.easyform.AddDataSavers')

MailerHandler = BaseHandler(Mailer)
CustomScriptHandler = BaseHandler(CustomScript)
SaveDataHandler = BaseHandler(SaveData)
예제 #2
0
@implementer(IFromUnicode, IRichTextLabel)
class RichTextLabel(Field):
    """A rich text field
    """

    text = u''

    def __init__(self, text=u'', **kw):
        self.text = text
        super(RichTextLabel, self).__init__(**kw)

    def validate(self, value):
        pass

    def fromUnicode(self, s):
        pass


RichTextLabelFactory = FieldFactory(RichTextLabel, _(u'Instruction'))
RichTextLabelHandler = BaseHandler(RichTextLabel)

configure.utility(
    name=u'collective.flow.fields.RichTextLabel',
    component=u'collective.flow.fields.RichTextLabelFactory',
)

configure.utility(
    name=u'collective.flow.fields.RichTextLabel',
    component=u'collective.flow.fields.RichTextLabelHandler',
)
예제 #3
0
파일: handler.py 프로젝트: eea/plone.schema
from plone.supermodel.exportimport import BaseHandler
from zope.schema import URI
from plone.schema.email import Email
from plone.schema.jsonfield import JSONField

URIHandler = BaseHandler(URI)
EmailHandler = BaseHandler(Email)
JSONHandler = BaseHandler(JSONField)
예제 #4
0
            title_or_id = mappings['title']

        chooser = INameChooser(location)
        item_id = chooser.chooseName(title_or_id, location)

        api.content.create(
            container=location,
            type=self.content_type,
            id=item_id,
            **mappings  # noqa C815
        )

    def onSuccess(self, fields, request):
        """Create item on successful form submission
        """
        context = get_context(self)
        current_user = api.user.get_current()

        with api.env.adopt_user(user=current_user):
            with api.env.adopt_roles(roles=['Contributor']):
                self.createDXItem(fields, request, context)


CreateDXAction = ActionFactory(
    CreateDX,
    _(u'label_create_dexterity_content', default=u'Create dexterity content'),
    'collective.easyform.AddDXContent',
)

CreateDXHandler = BaseHandler(CreateDX)
예제 #5
0
            del attributes['portal_type']

        if not portal_type:
            attributes['source'] = CatalogSource()
        else:
            attributes['source'] = CatalogSource(portal_type=portal_type)

        return super(RelationChoiceBaseHandler,
                     self)._constructField(attributes)

    def write(self, field, name, type, elementName='field'):
        element = super(RelationChoiceBaseHandler,
                        self).write(field, name, type, elementName)
        portal_type = []

        portal_type.extend(field.source.query.get('portal_type') or [])

        if portal_type:
            attributeField = self.fieldAttributes['portal_type']
            child = valueToElement(attributeField,
                                   portal_type,
                                   name='portal_type',
                                   force=True)
            element.append(child)

        return element


RelationChoiceHandler = RelationChoiceBaseHandler(RelationChoice)
RelationListHandler = BaseHandler(RelationList)
    def __init__(self, rich_label=u"", checkbox_label=u"", **kw):
        if not isinstance(rich_label, RichTextValue):
            rich_label = RichTextValue(rich_label)
        self.rich_label = rich_label
        self.checkbox_label = checkbox_label
        super(Consent, self).__init__(**kw)

    def validate(self, value):
        if self.required:
            res = isChecked(value)
            if res:
                raise Invalid(res)
        super(Consent, self).validate(value)


ConsentFactory = FieldFactory(
    Consent, _(u"label_consent_field", default=u"Einwilligung")
)
ConsentHandler = BaseHandler(Consent)


@implementer(IDivider)
class Divider(Label):
    """ A custom label field that uses a different widget template. Intended as an
    alternative to the use of fieldsets."""


DividerFactory = FieldFactory(Divider, _(u"label_divider_field", default=u"Trenner"))
DividerHandler = BaseHandler(Divider)
예제 #7
0
from plone.supermodel.exportimport import BaseHandler
from zope.schema import URI
from plone.schema.email import Email

URIHandler = BaseHandler(URI)
EmailHandler = BaseHandler(Email)
        }
        return names


    def onSuccess(self, fields, request):
        context = get_context(self)
        annotations = IAnnotations(context)
        singleSubmission = annotations.get(CEFPSS, False)
        voters = annotations.get(CEFPSV, [])
        if not api.user.is_anonymous():
            auth_user = api.user.get_current()
            if singleSubmission and auth_user.id in voters:
                return False
            voters.append(auth_user.id)
            annotations[CEFPSV] = voters
        super(PollSaveData, self).onSuccess(fields, request)
        


PollAction = ActionFactory(
    PollTrigger, _(u'PollTrigger'),
    'collective.easyformplugin.poll.easyform.PollTrigger'
)

PollSaveDataAction = ActionFactory(
    PollSaveData, _(u'PollSaveData'),
    'collective.easyformplugin.poll.easyform.PollSaveData'
)

PollHandler = BaseHandler(PollTrigger)
PollSaveDataHandler = BaseHandler(PollSaveData)
예제 #9
0
# -*- coding: utf-8 -*-
try:
    from plone.formwidget.geolocation.field import GeolocationField
    from plone.supermodel.exportimport import BaseHandler
    GeolocationHandler = BaseHandler(GeolocationField)
except ImportError:
    pass
class ISectionBreakWidget(ITextWidget):
    """ """


@implementer(ISectionBreak)
class SectionBreak(TextLine):

    def __init__(self, *args, **kw):
        kw['readonly'] = False  # BBB: ...
        kw['required'] = False
        super(SectionBreak, self).__init__(*args, **kw)


# plone.supermodel export/import handler
SectionBreakHandler = BaseHandler(SectionBreak)


@implementer_only(ISectionBreakWidget)
class SectionBreakWidget(text.TextWidget):
    """Input type sectionbreak widget implementation."""
    klass = u'text-widget'
    css = u'text'
    value = u''


@adapter(IField, IFormLayer)
@implementer(IFieldWidget)
def SectionBreakFieldWidget(field, request):
    """IFieldWidget factory for SectionBreak."""
    if not field.title:
예제 #11
0
from zope.interface import implementer
from zope.schema.interfaces import ITextLine
from zope.schema._field import TextLine
from Products.CMFDefault.utils import checkEmailAddress
from plone.supermodel.exportimport import BaseHandler


class IEmail(ITextLine):
    pass


@implementer(IEmail)
class Email(TextLine):
    def constraint(self, value):
        checkEmailAddress(value)
        return super(Email, self).constraint(value)


# plone.supermodel export/import handler
EmailHandler = BaseHandler(Email)
예제 #12
0
        for tup in columns:
            if tup[1] in ('Float', 'Decimal') and self.decimal_separator:
                # treat both '.' and ',' as decimal separator
                # overriding form widget behaviour, convenient for forms on mobile!
                val = request.form['form.widgets.{}'.format(tup[0])].replace(
                    ',', '.'
                )
                if val == u'':
                    val = None
                else:
                    val = float(val)
            else:
                val = fields[tup[0]]
            data[tup[0]] = (val, tup[1])
        if self.ExtraData:
            for f in self.ExtraData:
                if f == 'dt':
                    data[f] = (str(DateTime()), 'Datetime')
                else:
                    data[f] = (getattr(request, f, ''), 'Text')
        context = get_context(self)
        ret = self.InsertDB(context, data)


PostgresDataAction = ActionFactory(
    PostgresData,
    _(u'label_postgresdata_action', default=u'Postgres Data'),
    'collective.easyform.AddPostgresData',
)
PostgresDataHandler = BaseHandler(PostgresData)
예제 #13
0
class RichLabel(Label):
    """A Rich Label field
    """

    rich_label = u""

    def __init__(self, rich_label=u"", **kw):
        self.rich_label = rich_label
        super(RichLabel, self).__init__(**kw)


LabelFactory = FieldFactory(Label, _(u"label_label_field", default=u"Label"))
RichLabelFactory = FieldFactory(
    RichLabel, _(u"label_richlabel_field", default=u"Rich Label"))

LabelHandler = BaseHandler(Label)
RichLabelHandler = BaseHandler(RichLabel)


@implementer(IReCaptcha)
class ReCaptcha(TextLine):
    """A ReCaptcha field
    """


ReCaptchaFactory = FieldFactory(
    ReCaptcha, _(u"label_recaptcha_field", default=u"ReCaptcha"))
ReCaptchaHandler = BaseHandler(ReCaptcha)


@implementer(INorobotCaptcha)
예제 #14
0
        # IFTTTActionExecutor
        timeout = 120
        ifttt_trigger_url = 'https://maker.ifttt.com/trigger/' + \
                            self.ifttt_event_name + '/with/key/' + secret_key

        # request handler
        r = queryMultiAdapter((self, getRequest()),
                              IRequestsLibrary,
                              default=requests)

        logger.info('Calling Post request to IFTTT')
        try:

            r.post(ifttt_trigger_url, data=payload, timeout=timeout)

            logger.info('Successful Post request to IFTTT applet {0}'.format(
                self.ifttt_event_name))

        except TypeError:
            logger.exception('Error calling IFTTT Trigger {0}'.format(
                self.ifttt_event_name))

        return True


IFTTTAction = ActionFactory(IFTTTTrigger, _(u'IFTTTTrigger'),
                            'collective.ifttt.easyformadapter')

IFTTTHandler = BaseHandler(IFTTTTrigger)
예제 #15
0

class RichLabel(Label):
    """A Rich Label field
    """
    implements(IRichLabel)
    rich_label = u''

    def __init__(self, rich_label=u'', **kw):
        self.rich_label = rich_label
        super(RichLabel, self).__init__(**kw)


LabelFactory = FieldFactory(Label, _(u'label_label_field', default=u'Label'))
RichLabelFactory = FieldFactory(
    RichLabel, _(u'label_richlabel_field', default=u'Rich Label'))

LabelHandler = BaseHandler(Label)
RichLabelHandler = BaseHandler(RichLabel)


class ReCaptcha(TextLine):
    """A ReCaptcha field
    """
    implements(IReCaptcha)


ReCaptchaFactory = FieldFactory(
    ReCaptcha, _(u'label_recaptcha_field', default=u'ReCaptcha'))
ReCaptchaHandler = BaseHandler(ReCaptcha)
예제 #16
0
from zope.schema.interfaces import IChoice
from zope.schema.interfaces import IList
from zope.schema import Choice
from zope.schema import List
from zope.schema.interfaces import IFromUnicode
from plone.supermodel.exportimport import ChoiceHandler
from plone.supermodel.exportimport import BaseHandler


class IRadiobutton(IChoice):
    pass


@implementer(IRadiobutton, IFromUnicode)
class Radiobutton(Choice):
    pass


class ICheckbox(IList):
    pass


@implementer(ICheckbox, IFromUnicode)
class Checkbox(List):
    pass


# plone.supermodel export/import handler
RadiobuttonHandler = ChoiceHandler(Radiobutton)
CheckboxHandler = BaseHandler(Checkbox)
예제 #17
0
# -*- coding: utf-8 -*-
# try:
from smdu.participacao.browser.field import MapaField
from plone.supermodel.exportimport import BaseHandler
MapaHandler = BaseHandler(MapaField)
# except ImportError:
#     pass
예제 #18
0
class EmailField(schema.TextLine):
    def __init__(self, *args, **kwargs):
        super(schema.TextLine, self).__init__(*args, **kwargs)

    def _validate(self, value):
        super(schema.TextLine, self)._validate(value)
        validate_email(value)


# referenced by configuration.zcml to register the Email fields
from plone.schemaeditor.fields import FieldFactory
EmailFieldFactory = FieldFactory(EmailField, _(u'Email'))

from plone.supermodel.exportimport import BaseHandler
EmailFieldHandler = BaseHandler(EmailField)


class IOverview(Interface):
    """ Views implementing this interface may use the OverviewletManager to
    display an overview of a list of resources.

    The OverviewletManager displays viewlets which work with a list of
    resources in a folderish view. Those resources are not required to actually
    be stored in that folder. They just need to be defined using this
    interface.

    The result may be something like this, with the part on the right side
    being the work of the overview:

    Resources Overivew