src/pyams_content/shared/form/interfaces.py
changeset 1346 88b5ce31afdc
parent 1344 646ec926f14a
child 1370 87bcbf37ad6d
equal deleted inserted replaced
1345:9b406fb98cfa 1346:88b5ce31afdc
    17 from zope.schema import Bool, Choice, TextLine
    17 from zope.schema import Bool, Choice, TextLine
    18 
    18 
    19 from pyams_content.component.paragraph import IBaseParagraph
    19 from pyams_content.component.paragraph import IBaseParagraph
    20 from pyams_content.shared.common.interfaces import ISharedContent, ISharedToolPortalContext, \
    20 from pyams_content.shared.common.interfaces import ISharedContent, ISharedToolPortalContext, \
    21     IWfSharedContentPortalContext
    21     IWfSharedContentPortalContext
    22 from pyams_i18n.schema import I18nTextField, I18nTextLineField, I18nHTMLField
    22 from pyams_i18n.schema import I18nHTMLField, I18nTextField, I18nTextLineField
    23 from pyams_utils.schema import MailAddressField, TextLineListField
    23 from pyams_utils.schema import MailAddressField, TextLineListField
    24 
    24 
    25 
    25 
    26 __docformat__ = 'restructuredtext'
    26 __docformat__ = 'restructuredtext'
    27 
    27 
    97 
    97 
    98     def get_schema_field(self, field):
    98     def get_schema_field(self, field):
    99         """Get schema field matching given form field"""
    99         """Get schema field matching given form field"""
   100 
   100 
   101 
   101 
       
   102 class IFormFieldDataConverter(Interface):
       
   103     """Interface of a converter adapter which can be used to convert form data"""
       
   104 
       
   105     def convert(self, value):
       
   106         """Convert given input value"""
       
   107 
       
   108 
   102 FORM_FIELDS_PARAGRAPH_TYPE = 'form-fields'
   109 FORM_FIELDS_PARAGRAPH_TYPE = 'form-fields'
   103 FORM_FIELDS_PARAGRAPH_NAME = _("Form fields")
   110 FORM_FIELDS_PARAGRAPH_NAME = _("Form fields")
   104 FORM_FIELDS_PARAGRAPH_RENDERERS = 'PyAMS.paragraph.formfields.renderers'
   111 FORM_FIELDS_PARAGRAPH_RENDERERS = 'PyAMS.paragraph.formfields.renderers'
   105 
   112 
   106 
   113 
   143     form_header = I18nTextField(title=_("Form header"),
   150     form_header = I18nTextField(title=_("Form header"),
   144                                 description=_("This header is displayed just above form fields"),
   151                                 description=_("This header is displayed just above form fields"),
   145                                 required=False)
   152                                 required=False)
   146 
   153 
   147     user_title = I18nTextLineField(title=_("Form title"),
   154     user_title = I18nTextLineField(title=_("Form title"),
       
   155                                    description=_("If set, this title will be displayed above input "
       
   156                                                  "fields"),
   148                                    required=False)
   157                                    required=False)
   149 
   158 
   150     auth_only = Bool(title=_("Authenticated only?"),
   159     auth_only = Bool(title=_("Authenticated only?"),
   151                      description=_("If 'yes', only authenticated users will be able to see and "
   160                      description=_("If 'yes', only authenticated users will be able to see and "
   152                                    "submit form"),
   161                                    "submit form"),
   185                              description=_("If your server is behind a proxy, please set it's "
   194                              description=_("If your server is behind a proxy, please set it's "
   186                                            "address here; captcha verification requires HTTPS "
   195                                            "address here; captcha verification requires HTTPS "
   187                                            "support..."),
   196                                            "support..."),
   188                              required=False)
   197                              required=False)
   189 
   198 
       
   199     rgpd_consent = Bool(title=_("Required RGPD consent?"),
       
   200                         description=_("If 'yes', an RGPD compliance warning will be displayed "
       
   201                                       "above form's submit button; form can't be submitted as long "
       
   202                                       "as the associated checkbox will not be checked explicitly "
       
   203                                       "by the user"),
       
   204                         required=True,
       
   205                         default=True)
       
   206 
       
   207     rgpd_warning = I18nTextField(title=_("RGPD consent text"),
       
   208                                  description=_("User consent must be explicit, and user must be "
       
   209                                                "warned about usage which will be made of submitted "
       
   210                                                "data; text samples are given below"),
       
   211                                  required=False)
       
   212 
       
   213     rgpd_user_rights = I18nHTMLField(title=_("RGPD user rights"),
       
   214                                      description=_("The internet user must be able to easily "
       
   215                                                    "revoke his consent later on, so it is "
       
   216                                                    "important to inform him how to proceed; below "
       
   217                                                    "are examples of possible formulations"),
       
   218                                      required=False)
       
   219 
   190     def query_handler(self, handler=None):
   220     def query_handler(self, handler=None):
   191         """Get form handler utility"""
   221         """Get form handler utility"""
   192 
   222 
   193 
   223 
   194 class IWfFormFactory(Interface):
   224 class IWfFormFactory(Interface):
   208 
   238 
   209     label = Attribute("Handler label")
   239     label = Attribute("Handler label")
   210     target_interface = Attribute("Handler target marker interface")
   240     target_interface = Attribute("Handler target marker interface")
   211     handler_info = Attribute("Handler info interface")
   241     handler_info = Attribute("Handler info interface")
   212 
   242 
   213     def handle(self, form, data):
   243     def handle(self, form, data, user_data):
   214         """Handle entered data"""
   244         """Handle entered data
       
   245 
       
   246         :param form: input form
       
   247         :param data: raw form data
       
   248         :param user_data: user friendly form input data
       
   249         """
   215 
   250 
   216 
   251 
   217 class IFormHandlerInfo(Interface):
   252 class IFormHandlerInfo(Interface):
   218     """Base handler info interface"""
   253     """Base handler info interface"""
   219 
   254