src/pyams_skin/extension.py
changeset 240 007e0e70ef13
parent 145 c7ec73c1d8be
child 294 ca2b091ad80d
equal deleted inserted replaced
239:36268865b9bf 240:007e0e70ef13
    16 # import standard library
    16 # import standard library
    17 
    17 
    18 # import interfaces
    18 # import interfaces
    19 from pyams_skin.interfaces.extension import \
    19 from pyams_skin.interfaces.extension import \
    20     IGoogleAnalyticsInfo, GOOGLE_ANALYTICS_INFO_KEY, \
    20     IGoogleAnalyticsInfo, GOOGLE_ANALYTICS_INFO_KEY, \
    21     IUserReportInfo, USER_REPORT_INFO_KEY
    21     IUserReportInfo, USER_REPORT_INFO_KEY, IGoogleTagManagerInfo, GOOGLE_TAGS_INFO_KEY
    22 from pyams_utils.interfaces.site import ISiteRoot
    22 from pyams_utils.interfaces.site import ISiteRoot
    23 from zope.annotation.interfaces import IAnnotations
    23 from zope.annotation.interfaces import IAnnotations
    24 
    24 
    25 # import packages
    25 # import packages
    26 from persistent import Persistent
    26 from persistent import Persistent
    27 from pyams_utils.adapter import adapter_config
    27 from pyams_utils.adapter import adapter_config
    28 from zope.interface import implementer
    28 from zope.interface import implementer
    29 from zope.schema.fieldproperty import FieldProperty
    29 from zope.schema.fieldproperty import FieldProperty
       
    30 
       
    31 
       
    32 @implementer(IGoogleTagManagerInfo)
       
    33 class GoogleTagManagerInfo(Persistent):
       
    34     """Google tag manager settings class"""
       
    35 
       
    36     enabled = FieldProperty(IGoogleTagManagerInfo['enabled'])
       
    37     container_id = FieldProperty(IGoogleTagManagerInfo['container_id'])
       
    38     activation_mode = FieldProperty(IGoogleTagManagerInfo['activation_mode'])
       
    39 
       
    40 
       
    41 @adapter_config(context=ISiteRoot, provides=IGoogleTagManagerInfo)
       
    42 def GoogleTagManagerInfoFactory(context):
       
    43     """Google Tag Manager settings factory"""
       
    44     annotations = IAnnotations(context)
       
    45     info = annotations.get(GOOGLE_TAGS_INFO_KEY)
       
    46     if info is None:
       
    47         info = annotations[GOOGLE_TAGS_INFO_KEY] = GoogleTagManagerInfo()
       
    48     return info
    30 
    49 
    31 
    50 
    32 @implementer(IGoogleAnalyticsInfo)
    51 @implementer(IGoogleAnalyticsInfo)
    33 class GoogleAnalyticsInfo(Persistent):
    52 class GoogleAnalyticsInfo(Persistent):
    34     """Google Analytics settings class"""
    53     """Google Analytics settings class"""