src/pyams_content/component/paragraph/contact.py
changeset 495 512c874493b9
parent 423 7dd6cb55f5c7
child 515 a1d5eb955e54
equal deleted inserted replaced
494:2cb12774d441 495:512c874493b9
    15 
    15 
    16 # import standard library
    16 # import standard library
    17 
    17 
    18 # import interfaces
    18 # import interfaces
    19 from pyams_content.component.paragraph.interfaces import IParagraphFactory
    19 from pyams_content.component.paragraph.interfaces import IParagraphFactory
    20 from pyams_content.component.paragraph.interfaces.contact import IContactParagraph, CONTACT_PARAGRAPH_TYPE, \
    20 from pyams_content.component.paragraph.interfaces.contact import have_gis, IContactParagraph, CONTACT_PARAGRAPH_TYPE, \
    21     CONTACT_PARAGRAPH_RENDERERS
    21     CONTACT_PARAGRAPH_RENDERERS
    22 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
    22 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
    23 from pyams_file.interfaces import IImage, IResponsiveImage
    23 from pyams_file.interfaces import IImage, IResponsiveImage
    24 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
    24 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
    25 
    25 
    47     icon_hint = _("Contact card")
    47     icon_hint = _("Contact card")
    48 
    48 
    49     name = FieldProperty(IContactParagraph['name'])
    49     name = FieldProperty(IContactParagraph['name'])
    50     charge = FieldProperty(IContactParagraph['charge'])
    50     charge = FieldProperty(IContactParagraph['charge'])
    51     _photo = FileProperty(IContactParagraph['photo'])
    51     _photo = FileProperty(IContactParagraph['photo'])
    52     gps_location = FieldProperty(IContactParagraph['gps_location'])
    52 
       
    53     if have_gis:
       
    54         gps_location = FieldProperty(IContactParagraph['gps_location'])
       
    55 
    53     address = FieldProperty(IContactParagraph['address'])
    56     address = FieldProperty(IContactParagraph['address'])
    54     renderer = FieldProperty(IContactParagraph['renderer'])
    57     renderer = FieldProperty(IContactParagraph['renderer'])
    55 
    58 
    56     @property
    59     @property
    57     def photo(self):
    60     def photo(self):
    93                 field_title = translate(IContactParagraph['charge'].title)
    96                 field_title = translate(IContactParagraph['charge'].title)
    94                 if len(langs) == 1:
    97                 if len(langs) == 1:
    95                     output.append(translate(MISSING_VALUE).format(field=field_title))
    98                     output.append(translate(MISSING_VALUE).format(field=field_title))
    96                 else:
    99                 else:
    97                     output.append(translate(MISSING_LANG_VALUE).format(field=field_title, lang=lang))
   100                     output.append(translate(MISSING_LANG_VALUE).format(field=field_title, lang=lang))
    98         for attr in ('name', 'photo', 'gps_location', 'address'):
   101         attrs = ('name', 'photo', 'address')
       
   102         if have_gis:
       
   103             attrs += ('gps_location', )
       
   104         for attr in attrs:
    99             value = getattr(self.context, attr, None)
   105             value = getattr(self.context, attr, None)
   100             if not value:
   106             if not value:
   101                 field_title = translate(IContactParagraph[attr].title)
   107                 field_title = translate(IContactParagraph[attr].title)
   102                 output.append(translate(MISSING_VALUE).format(field=field_title))
   108                 output.append(translate(MISSING_VALUE).format(field=field_title))
   103         return output
   109         return output