# HG changeset patch # User Thierry Florac # Date 1521742411 -3600 # Node ID bdd0b79668a12ef9e968b26c3ce1007528d37836 # Parent 03ded2b94efcae64b33b0219417396127d3a5a74 Added checks for "pyams_gis" package availability to enable GPS coordinates attributes diff -r 03ded2b94efc -r bdd0b79668a1 src/pyams_default_theme/component/paragraph/contact.py --- a/src/pyams_default_theme/component/paragraph/contact.py Tue Mar 20 17:56:05 2018 +0100 +++ b/src/pyams_default_theme/component/paragraph/contact.py Thu Mar 22 19:13:31 2018 +0100 @@ -17,7 +17,7 @@ from persistent import Persistent # import interfaces -from pyams_content.component.paragraph.interfaces.contact import IContactParagraph +from pyams_content.component.paragraph.interfaces.contact import have_gis, IContactParagraph from pyams_content.features.renderer.interfaces import IContentRenderer from pyams_default_theme.component.paragraph.interfaces.contact import IContactParagraphDefaultRendererSettings from pyams_skin.layer import IPyAMSLayer @@ -50,13 +50,17 @@ display_map = FieldProperty(IContactParagraphDefaultRendererSettings['display_map']) map_position = FieldProperty(IContactParagraphDefaultRendererSettings['map_position']) + @property def can_display_photo(self): contact = IContactParagraph(self.__parent__) if not contact.photo: return False return self.display_photo + @property def can_display_map(self): + if not have_gis: + return False contact = IContactParagraph(self.__parent__) if not contact.gps_location: return False @@ -87,5 +91,8 @@ settings_interface = IContactParagraphDefaultRendererSettings - context_attrs = ('name', 'photo', 'gps_location', 'address') + if have_gis: + context_attrs = ('name', 'photo', 'gps_location', 'address') + else: + context_attrs = ('name', 'photo', 'address') i18n_context_attrs = ('title', 'charge', ) diff -r 03ded2b94efc -r bdd0b79668a1 src/pyams_default_theme/component/paragraph/interfaces/contact.py --- a/src/pyams_default_theme/component/paragraph/interfaces/contact.py Tue Mar 20 17:56:05 2018 +0100 +++ b/src/pyams_default_theme/component/paragraph/interfaces/contact.py Thu Mar 22 19:13:31 2018 +0100 @@ -18,7 +18,7 @@ # import interfaces # import packages -from zope.interface import Interface +from zope.interface import Interface, Attribute from zope.schema import Bool, Choice from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm @@ -47,8 +47,7 @@ vocabulary=CONTENT_POSITIONS_VOCABULARY, default='left') - def can_display_photo(self): - """Check if photo can be displayed""" + can_display_photo = Attribute("Check if photo can be displayed") display_map = Bool(title=_("Show location map?"), description=_("If 'no', location map will not be displayed"), @@ -60,5 +59,4 @@ vocabulary=CONTENT_POSITIONS_VOCABULARY, default='right') - def can_display_map(self): - """Check if location map can be displayed""" + can_display_map = Attribute("Check if location map can be displayed") diff -r 03ded2b94efc -r bdd0b79668a1 src/pyams_default_theme/component/paragraph/templates/contact-default.pt --- a/src/pyams_default_theme/component/paragraph/templates/contact-default.pt Tue Mar 20 17:56:05 2018 +0100 +++ b/src/pyams_default_theme/component/paragraph/templates/contact-default.pt Thu Mar 22 19:13:31 2018 +0100 @@ -1,11 +1,11 @@

Contact title

-
-
Location map