Skip to content

Commit

Permalink
Merge pull request #74 from collective/PM-3826_display_photo_label
Browse files Browse the repository at this point in the history
Added parameter `display_photo_label_on_views` that will display the field photo `label` instead of default behavior that is only displaying the photo without label.
  • Loading branch information
sgeulette committed Jan 28, 2022
2 parents 2730f78 + 0f4b87f commit a80200d
Show file tree
Hide file tree
Showing 20 changed files with 668 additions and 562 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Changelog
- Removed useless imports in collective.contact.core.schema.
Import ContactList or ContactChoice should be done from collective.contact.widget.schema
[odelaere]

- Added parameter `display_photo_label_on_views` that will display the field photo
`label` instead of default behavior that is only displaying the photo without label.
[gbastien]

1.37 (2021-10-20)
-----------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
tal:condition="python: view.display_below_content_title() and not ajax_load" />

<div class="field" tal:condition="context/photo">
<label tal:condition="view/display_photo_label"><tal:block i18n:translate="">Photo</tal:block>:</label>
<img tal:replace="structure context/@@images/photo/thumb" />
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

<h1 class="org"><img tal:attributes="src context/getIconURL" /> <span tal:content="view/name" /></h1>

<div id="viewlet-below-content-title" tal:content="structure provider:plone.belowcontenttitle"
tal:condition="python: view.display_below_content_title() and not ajax_load" />

<div metal:use-macro="context/kss_generic_macros/macros/generic_description_view">
Generic KSS Description. Is rendered with class="documentDescription".
</div>
Expand All @@ -18,9 +21,6 @@
tal:on-error="string:Bad logo format" />
</div>

<div id="viewlet-below-content-title" tal:content="structure provider:plone.belowcontenttitle"
tal:condition="python: view.display_below_content_title() and not ajax_load" />

<div id="type" class="field">
<label><tal:block i18n:translate="">Organization type</tal:block>:</label>
<span tal:content="view/type"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
tal:condition="python: view.display_below_content_title() and not ajax_load" />

<div id="photo" class="field" tal:condition="context/photo">
<label tal:condition="view/display_photo_label"><tal:block i18n:translate="">Photo</tal:block>:</label>
<img tal:define="scales nocall:context/@@images"
tal:replace="structure python:scales.tag('photo', 'thumb', css_class='photo')"
tal:on-error="string:Bad photo format" />
Expand Down
18 changes: 16 additions & 2 deletions src/collective/contact/core/browser/basefields/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
class BaseFields(object):

def display_below_content_title(self):
return api.portal.get_registry_record('display_below_content_title_on_views', interface=IContactCoreParameters,
default=False)
return api.portal.get_registry_record(
'display_below_content_title_on_views',
interface=IContactCoreParameters,
default=False)


class PersonBaseFields(grok.View, BaseFields):
Expand All @@ -32,6 +34,12 @@ class PersonBaseFields(grok.View, BaseFields):
person_title = ''
gender = ''

def display_photo_label(self):
return api.portal.get_registry_record(
'display_photo_label_on_views',
interface=IContactCoreParameters,
default=False)

def update(self):
self.person = self.context
person = self.person
Expand Down Expand Up @@ -106,6 +114,12 @@ class HeldPositionBaseFields(grok.View, BaseFields):
position = None
organizations = []

def display_photo_label(self):
return api.portal.get_registry_record(
'display_photo_label_on_views',
interface=IContactCoreParameters,
default=False)

def update(self):
held_position = self.context

Expand Down
5 changes: 5 additions & 0 deletions src/collective/contact/core/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ class IContactCoreParameters(Interface):
description=u"",
required=False, default=False)

display_photo_label_on_views = schema.Bool(
title=_(u"Display the \"Photo\" label before the photo image on contact views."),
description=u"",
required=False, default=False)

contact_source_metadata_content = schema.TextLine(
title=_(u"Choose information displayed after a search in contact widget."),
description=u"Format string containing variables like : {gft} (full title) , {number} , {street} , "
Expand Down

0 comments on commit a80200d

Please sign in to comment.