src/pyams_skin/interfaces/extension.py
changeset 508 eb708d0e9298
parent 506 08196fe15f4a
child 576 998a3b7cac64
equal deleted inserted replaced
507:1c7bd4ccfb32 508:eb708d0e9298
    10 # FOR A PARTICULAR PURPOSE.
    10 # FOR A PARTICULAR PURPOSE.
    11 #
    11 #
    12 
    12 
    13 __docformat__ = 'restructuredtext'
    13 __docformat__ = 'restructuredtext'
    14 
    14 
    15 from zope.interface import Interface
    15 from zope.interface import Interface, invariant, Invalid
    16 from zope.schema import Bool, Choice, TextLine
    16 from zope.schema import Bool, Choice, TextLine
    17 from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
    17 from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
    18 
    18 
    19 from pyams_skin import _
    19 from pyams_skin import _
    20 
    20 
    26 ACTIVATION_MODES_LABELS = {ACTIVATED_ON_FRONT: _("Front-office only"),
    26 ACTIVATION_MODES_LABELS = {ACTIVATED_ON_FRONT: _("Front-office only"),
    27                            ACTIVATED_ON_BACK: _("Back-office only"),
    27                            ACTIVATED_ON_BACK: _("Back-office only"),
    28                            ACTIVATED_ON_BOTH: _("Front-office and back-office")}
    28                            ACTIVATED_ON_BOTH: _("Front-office and back-office")}
    29 
    29 
    30 ACTIVATION_MODES = SimpleVocabulary([SimpleTerm(k, title=v) for k, v in ACTIVATION_MODES_LABELS.items()])
    30 ACTIVATION_MODES = SimpleVocabulary([SimpleTerm(k, title=v) for k, v in ACTIVATION_MODES_LABELS.items()])
    31 
       
    32 
    31 
    33 GOOGLE_TAGS_INFO_KEY = 'pyams_skin.tagmanager_info'
    32 GOOGLE_TAGS_INFO_KEY = 'pyams_skin.tagmanager_info'
    34 
    33 
    35 
    34 
    36 class IGoogleTagManagerInfo(Interface):
    35 class IGoogleTagManagerInfo(Interface):
    51                            required=False)
    50                            required=False)
    52 
    51 
    53     rejected_cookie_value = TextLine(title=_("Rejected cookie value"),
    52     rejected_cookie_value = TextLine(title=_("Rejected cookie value"),
    54                                      description=_("Cookie value matching user's cookies reject"),
    53                                      description=_("Cookie value matching user's cookies reject"),
    55                                      required=False)
    54                                      required=False)
       
    55 
       
    56     @invariant
       
    57     def check_cookie(self):
       
    58         if self.on_accepted_cookie and not (self.cookie_name and self.rejected_cookie_value):
       
    59             raise Invalid(_("You must specify cookie name and reject value !!"))
    56 
    60 
    57     container_id = TextLine(title=_("Container ID"),
    61     container_id = TextLine(title=_("Container ID"),
    58                             description=_("Google Tag Manager container ID (may start with 'GTM-')"),
    62                             description=_("Google Tag Manager container ID (may start with 'GTM-')"),
    59                             required=False)
    63                             required=False)
    60 
    64 
    91 
    95 
    92     rejected_cookie_value = TextLine(title=_("Rejected cookie value"),
    96     rejected_cookie_value = TextLine(title=_("Rejected cookie value"),
    93                                      description=_("Cookie value matching user's cookies reject"),
    97                                      description=_("Cookie value matching user's cookies reject"),
    94                                      required=False)
    98                                      required=False)
    95 
    99 
       
   100     @invariant
       
   101     def check_cookie(self):
       
   102         if self.on_accepted_cookie and not (self.cookie_name and self.rejected_cookie_value):
       
   103             raise Invalid(_("You must specify cookie name and reject value !!"))
       
   104 
    96     website_id = TextLine(title=_("Web site ID"),
   105     website_id = TextLine(title=_("Web site ID"),
    97                           description=_("Google Analytics web site ID"),
   106                           description=_("Google Analytics web site ID"),
    98                           required=False)
   107                           required=False)
    99 
   108 
   100     activation_mode = Choice(title=_("Activation mode"),
   109     activation_mode = Choice(title=_("Activation mode"),
   126 
   135 
   127     rejected_cookie_value = TextLine(title=_("Rejected cookie value"),
   136     rejected_cookie_value = TextLine(title=_("Rejected cookie value"),
   128                                      description=_("Cookie value matching user's cookies reject"),
   137                                      description=_("Cookie value matching user's cookies reject"),
   129                                      required=False)
   138                                      required=False)
   130 
   139 
       
   140     @invariant
       
   141     def check_cookie(self):
       
   142         if self.on_accepted_cookie and not (self.cookie_name and self.rejected_cookie_value):
       
   143             raise Invalid(_("You must specify cookie name and reject value !!"))
       
   144 
   131     account_id = TextLine(title=_("Account ID"),
   145     account_id = TextLine(title=_("Account ID"),
   132                           description=_("UserReport account ID, available in 'initSite' code snippet"),
   146                           description=_("UserReport account ID, available in 'initSite' code snippet"),
   133                           required=False)
   147                           required=False)
   134 
   148 
   135     activation_mode = Choice(title=_("Activation mode"),
   149     activation_mode = Choice(title=_("Activation mode"),