src/pyams_content/component/paragraph/map.py
changeset 861 36f6bb152718
child 1157 ffb751b038cc
equal deleted inserted replaced
860:9d1653c0e04d 861:36f6bb152718
       
     1 #
       
     2 # Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
       
     3 # All Rights Reserved.
       
     4 #
       
     5 # This software is subject to the provisions of the Zope Public License,
       
     6 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
       
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    10 # FOR A PARTICULAR PURPOSE.
       
    11 #
       
    12 
       
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 
       
    16 from pyams_content.component.paragraph.interfaces.map import have_gis
       
    17 if have_gis:
       
    18 
       
    19     # import standard library
       
    20 
       
    21     # import interfaces
       
    22     from pyams_content.component.paragraph.interfaces import IParagraphFactory
       
    23     from pyams_content.component.paragraph.interfaces.map import IMapParagraph, MAP_PARAGRAPH_NAME, have_gis, \
       
    24         MAP_PARAGRAPH_TYPE, MAP_PARAGRAPH_RENDERERS
       
    25 
       
    26     # import packages
       
    27     from pyams_content.component.paragraph import BaseParagraph, BaseParagraphFactory
       
    28     from pyams_content.features.renderer import RenderersVocabulary
       
    29     from pyams_utils.factory import factory_config
       
    30     from pyams_utils.registry import utility_config
       
    31     from pyams_utils.vocabulary import vocabulary_config
       
    32     from zope.interface import implementer
       
    33     from zope.schema.fieldproperty import FieldProperty
       
    34 
       
    35 
       
    36     @implementer(IMapParagraph)
       
    37     @factory_config(provided=IMapParagraph)
       
    38     class MapParagraph(BaseParagraph):
       
    39         """Map paragraph"""
       
    40 
       
    41         icon_class = 'fa-map-marker'
       
    42         icon_hint = MAP_PARAGRAPH_NAME
       
    43 
       
    44         if have_gis:
       
    45             gps_location = FieldProperty(IMapParagraph['gps_location'])
       
    46             display_marker = FieldProperty(IMapParagraph['display_marker'])
       
    47 
       
    48         renderer = FieldProperty(IMapParagraph['renderer'])
       
    49 
       
    50 
       
    51     @utility_config(name=MAP_PARAGRAPH_TYPE, provides=IParagraphFactory)
       
    52     class MapParagraphFactory(BaseParagraphFactory):
       
    53         """Map paragraph factory"""
       
    54 
       
    55         name = MAP_PARAGRAPH_NAME
       
    56         content_type = MapParagraph
       
    57         secondary_menu = True
       
    58 
       
    59 
       
    60     @vocabulary_config(name=MAP_PARAGRAPH_RENDERERS)
       
    61     class MapParagraphRenderersVocabulary(RenderersVocabulary):
       
    62         """Map paragraph renderers vocabulary"""
       
    63 
       
    64         content_interface = IMapParagraph