src/pyams_content/shared/form/interfaces.py
changeset 1343 530cbb970243
parent 1337 a5b80a5c43de
child 1344 646ec926f14a
equal deleted inserted replaced
1342:999fa08d99c2 1343:530cbb970243
    14 from zope.container.constraints import containers, contains
    14 from zope.container.constraints import containers, contains
    15 from zope.container.interfaces import IContained, IContainer
    15 from zope.container.interfaces import IContained, IContainer
    16 from zope.interface import Attribute, Interface
    16 from zope.interface import Attribute, Interface
    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.shared.common.interfaces import ISharedContent, ISharedToolPortalContext, \
    20 from pyams_content.shared.common.interfaces import ISharedContent, ISharedToolPortalContext, \
    20     IWfSharedContentPortalContext
    21     IWfSharedContentPortalContext
    21 from pyams_i18n.schema import I18nTextField, I18nTextLineField, I18nHTMLField
    22 from pyams_i18n.schema import I18nTextField, I18nTextLineField, I18nHTMLField
    22 from pyams_utils.schema import MailAddressField, TextLineListField
    23 from pyams_utils.schema import MailAddressField, TextLineListField
    23 
    24 
    62     description = I18nTextField(title=_("Description"),
    63     description = I18nTextField(title=_("Description"),
    63                                 description=_("Field description can be displayed as hint"),
    64                                 description=_("Field description can be displayed as hint"),
    64                                 required=False)
    65                                 required=False)
    65 
    66 
    66     placeholder = TextLine(title=_("Placeholder"),
    67     placeholder = TextLine(title=_("Placeholder"),
    67                            description=_("Some field types like textline can display a placeholder"),
    68                            description=_("Some field types like textline can display a "
       
    69                                          "placeholder"),
    68                            required=False)
    70                            required=False)
    69 
    71 
    70     values = TextLineListField(title=_("Optional values"),
    72     values = TextLineListField(title=_("Optional values"),
    71                                description=_("List of available values (for 'choice' and 'list' field types)"),
    73                                description=_("List of available values (for 'choice' and 'list' "
       
    74                                              "field types)"),
    72                                required=False)
    75                                required=False)
    73 
    76 
    74     default = I18nTextLineField(title=_("Default value"),
    77     default = I18nTextLineField(title=_("Default value"),
    75                                 description=_("Give default value if field type can use it"),
    78                                 description=_("Give default value if field type can use it"),
    76                                 required=False)
    79                                 required=False)
    94 
    97 
    95     def get_schema_field(self, field):
    98     def get_schema_field(self, field):
    96         """Get schema field matching given form field"""
    99         """Get schema field matching given form field"""
    97 
   100 
    98 
   101 
       
   102 FORM_FIELDS_PARAGRAPH_TYPE = 'form-fields'
       
   103 FORM_FIELDS_PARAGRAPH_NAME = _("Form fields")
       
   104 FORM_FIELDS_PARAGRAPH_RENDERERS = 'PyAMS.paragraph.formfields.renderers'
       
   105 
       
   106 
       
   107 class IFormFieldsParagraph(IBaseParagraph):
       
   108     """Form fields paragraph"""
       
   109 
       
   110     renderer = Choice(title=_("Form fields template"),
       
   111                       description=_("Presentation template used for this paaragraph"),
       
   112                       vocabulary=FORM_FIELDS_PARAGRAPH_RENDERERS,
       
   113                       default='default')
       
   114 
       
   115 
    99 class IFormFieldContainer(IContainer):
   116 class IFormFieldContainer(IContainer):
   100     """Form fields container interface"""
   117     """Form fields container interface"""
   101 
   118 
   102     contains(IFormField)
   119     contains(IFormField)
   103 
   120 
   116 
   133 
   117 
   134 
   118 class IWfForm(IWfSharedContentPortalContext):
   135 class IWfForm(IWfSharedContentPortalContext):
   119     """Form interface"""
   136     """Form interface"""
   120 
   137 
   121     user_title = I18nTextLineField(title=_("Form title"),
   138     alt_title = I18nTextLineField(title=_("Alternate title"),
   122                                    required=True)
   139                                   description=_("If set, this title will be displayed in "
   123 
   140                                                 "front-office instead of original title"),
   124     auth_only = Bool(title=_("Authenticated only?"),
   141                                   required=False)
   125                      description=_("If 'yes', only authenticated users will be able to see and submit form"),
       
   126                      required=True,
       
   127                      default=False)
       
   128 
   142 
   129     form_header = I18nTextField(title=_("Form header"),
   143     form_header = I18nTextField(title=_("Form header"),
   130                                 description=_("This header is displayed just above form fields"),
   144                                 description=_("This header is displayed just above form fields"),
   131                                 required=False)
   145                                 required=False)
   132 
   146 
       
   147     user_title = I18nTextLineField(title=_("Form title"),
       
   148                                    required=False)
       
   149 
       
   150     auth_only = Bool(title=_("Authenticated only?"),
       
   151                      description=_("If 'yes', only authenticated users will be able to see and "
       
   152                                    "submit form"),
       
   153                      required=True,
       
   154                      default=False)
       
   155 
   133     submit_label = I18nTextLineField(title=_("Submit button"),
   156     submit_label = I18nTextLineField(title=_("Submit button"),
   134                                      description=_("Label of form submit button"),
   157                                      description=_("Label of form submit button"),
   135                                      required=True)
   158                                      required=True)
   136 
   159 
   137     submit_message = I18nHTMLField(title=_("Submit message"),
   160     submit_message = I18nHTMLField(title=_("Submit message"),
   138                                    description=_("This message will be displayed after form submission"),
   161                                    description=_("This message will be displayed after form "
       
   162                                                  "submission"),
   139                                    required=True)
   163                                    required=True)
   140 
   164 
   141     handler = Choice(title=_("Form handler"),
   165     handler = Choice(title=_("Form handler"),
   142                      description=_("Select how form data is transmitted"),
   166                      description=_("Select how form data is transmitted"),
   143                      vocabulary='PyAMS form handlers')
   167                      vocabulary='PyAMS form handlers')
   146                        description=_("If 'yes', a captcha will be added automatically to the form"),
   170                        description=_("If 'yes', a captcha will be added automatically to the form"),
   147                        required=False,
   171                        required=False,
   148                        default=True)
   172                        default=True)
   149 
   173 
   150     client_captcha_key = TextLine(title=_("Site key"),
   174     client_captcha_key = TextLine(title=_("Site key"),
   151                                   description=_("This key is included into HTML code and submitted with form data"),
   175                                   description=_("This key is included into HTML code and submitted "
       
   176                                                 "with form data"),
   152                                   required=False)
   177                                   required=False)
   153 
   178 
   154     server_captcha_key = TextLine(title=_("Secret key"),
   179     server_captcha_key = TextLine(title=_("Secret key"),
   155                                   description=_("This key is used to communicate with Google's reCaptcha services"),
   180                                   description=_("This key is used to communicate with Google's "
       
   181                                                 "reCaptcha services"),
   156                                   required=False)
   182                                   required=False)
   157 
   183 
   158     captcha_proxy = TextLine(title=_("Recaptcha proxy"),
   184     captcha_proxy = TextLine(title=_("Recaptcha proxy"),
   159                              description=_("If your server is behind a proxy, please set it's address here; "
   185                              description=_("If your server is behind a proxy, please set it's "
   160                                            "captcha verification requires HTTPS support..."),
   186                                            "address here; captcha verification requires HTTPS "
       
   187                                            "support..."),
   161                              required=False)
   188                              required=False)
   162 
   189 
   163     def query_handler(self, handler=None):
   190     def query_handler(self, handler=None):
   164         """Get form handler utility"""
   191         """Get form handler utility"""
   165 
   192