Skip to content

Commit

Permalink
WEB-3985 : Add orientation (portrait / landscape) behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
laulaz committed Sep 15, 2023
1 parent 7882b8c commit 3c8d5d1
Show file tree
Hide file tree
Showing 25 changed files with 195 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/imio/smartweb/core/behaviors/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

<include package="plone.behavior" file="meta.zcml"/>

<plone:behavior
name="imio.smartweb.orientation"
title="Image orientation"
description="Allow to choose images orientation for current context."
provides=".orientation.IOrientation"
/>

<plone:behavior
name="imio.smartweb.listing"
title="Parent listing"
Expand Down
18 changes: 18 additions & 0 deletions src/imio/smartweb/core/behaviors/orientation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-

from imio.smartweb.locales import SmartwebMessageFactory as _
from plone.autoform.interfaces import IFormFieldProvider
from plone.supermodel import model
from zope import schema
from zope.interface import provider


@provider(IFormFieldProvider)
class IOrientation(model.Schema):
model.fieldset("layout", label=_("Layout"), fields=["orientation"])
orientation = schema.Choice(
title=_("Orientation"),
required=True,
vocabulary="imio.smartweb.vocabulary.Orientation",
default="portrait",
)
2 changes: 1 addition & 1 deletion src/imio/smartweb/core/contents/rest/directory/view.pt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
query-filter-url view/local_filters_query_url;
batch-size view/batch_size;
propose-url view/propose_url;
current-language view/get_current_language;"></smartweb-annuaire>
current-language view/current_language;"></smartweb-annuaire>
</div>
</metal:main>
</body>
Expand Down
2 changes: 1 addition & 1 deletion src/imio/smartweb/core/contents/rest/events/view.pt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
query-filter-url view/local_filters_query_url;
batch-size view/batch_size;
propose-url view/propose_url;
current-language view/get_current_language;"></smartweb-events>
current-language view/current_language;"></smartweb-events>
</div>
</metal:main>
</body>
Expand Down
2 changes: 1 addition & 1 deletion src/imio/smartweb/core/contents/rest/news/view.pt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
query-filter-url view/local_filters_query_url;
batch-size view/batch_size;
propose-url view/propose_url;
current-language view/get_current_language;"></smartweb-news>
current-language view/current_language;"></smartweb-news>
</div>
</metal:main>
</body>
Expand Down
3 changes: 2 additions & 1 deletion src/imio/smartweb/core/contents/rest/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ def local_filters_query_url(self):
base_url = self.context.absolute_url()
return f"{base_url}/@results-filters"

def get_current_language(self):
@property
def current_language(self):
return api.portal.get_current_language()[:2]
2 changes: 1 addition & 1 deletion src/imio/smartweb/core/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<metadata>
<version>1045</version>
<version>1046</version>
<dependencies>
<dependency>profile-plone.app.dexterity:default</dependency>
<dependency>profile-plone.app.imagecropping:default</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<element value="plone.leadimage"/>
<element value="plone.imagecropping"/>
<element value="plone.constraintypes"/>
<element value="imio.smartweb.orientation"/>
<element value="imio.smartweb.listing"/>
<element value="imio.smartweb.quickaccessselection"/>
<element value="collective.autopublishing.behavior.IAutoPublishing"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<element value="plone.namefromtitle"/>
<element value="plone.locking"/>
<element value="plone.shortname"/>
<element value="imio.smartweb.orientation"/>
</property>

<!-- View information -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<element value="plone.namefromtitle"/>
<element value="plone.locking"/>
<element value="plone.shortname"/>
<element value="imio.smartweb.orientation"/>
</property>

</object>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<element value="plone.namefromtitle"/>
<element value="plone.locking"/>
<element value="plone.shortname"/>
<element value="imio.smartweb.orientation"/>
</property>

<!-- View information -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<element value="plone.namefromtitle"/>
<element value="plone.locking"/>
<element value="plone.shortname"/>
<element value="imio.smartweb.orientation"/>
</property>

<!-- View information -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<element value="plone.namefromtitle"/>
<element value="plone.locking"/>
<element value="plone.shortname"/>
<element value="imio.smartweb.orientation"/>
</property>

<!-- View information -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<element value="plone.namefromtitle"/>
<element value="plone.locking"/>
<element value="plone.shortname"/>
<element value="imio.smartweb.orientation"/>
</property>

<!-- View information -->
Expand Down
3 changes: 3 additions & 0 deletions src/imio/smartweb/core/tests/test_vocabularies.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def test_procedure_error_values(self, m):
def test_bootstrap_css(self):
self.assertVocabularyLen("imio.smartweb.vocabulary.BootstrapCSS", 6)

def test_orientation(self):
self.assertVocabularyLen("imio.smartweb.vocabulary.Orientation", 2)

def test_subsite_display_mode(self):
self.assertVocabularyLen("imio.smartweb.vocabulary.SubsiteDisplayMode", 3)

Expand Down
18 changes: 18 additions & 0 deletions src/imio/smartweb/core/upgrades/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@
provides="Products.GenericSetup.interfaces.EXTENSION"
/>

<genericsetup:registerProfile
name="upgrade_1045_to_1046"
title="Upgrade core from 1045 to 1046"
directory="profiles/1045_to_1046"
description="Add orientation behavior on elected types"
provides="Products.GenericSetup.interfaces.EXTENSION"
/>

<genericsetup:upgradeStep
title="Configure first official release"
description="Run needed profiles steps and reindex catalog"
Expand Down Expand Up @@ -633,4 +641,14 @@
profile="imio.smartweb.core:default"
/>

<genericsetup:upgradeSteps
source="1045"
destination="1046"
profile="imio.smartweb.core:default">
<genericsetup:upgradeDepends
title="Add orientation behavior on elected types"
import_profile="imio.smartweb.core.upgrades:upgrade_1045_to_1046"
/>
</genericsetup:upgradeSteps>

</configure>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
name="imio.smartweb.Folder"
meta_type="Dexterity FTI"
i18n:domain="imio.smartweb">

<!-- Enabled behaviors -->
<property name="behaviors" purge="true">
<element value="plone.categorization"/>
<element value="plone.namefromtitle"/>
<element value="plone.excludefromnavigation"/>
<element value="plone.shortname"/>
<element value="plone.basic"/>
<element value="plone.locking"/>
<element value="plone.leadimage"/>
<element value="plone.imagecropping"/>
<element value="plone.constraintypes"/>
<element value="imio.smartweb.orientation"/>
<element value="imio.smartweb.listing"/>
<element value="imio.smartweb.quickaccessselection"/>
<element value="collective.autopublishing.behavior.IAutoPublishing"/>
</property>

</object>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
name="imio.smartweb.SectionCollection"
meta_type="Dexterity FTI"
i18n:domain="imio.smartweb">

<!-- Enabled behaviors -->
<property name="behaviors" purge="true">
<element value="plone.namefromtitle"/>
<element value="plone.locking"/>
<element value="plone.shortname"/>
<element value="imio.smartweb.orientation"/>
</property>

</object>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
name="imio.smartweb.SectionContact"
meta_type="Dexterity FTI"
i18n:domain="imio.smartweb">

<!-- Enabled behaviors -->
<property name="behaviors" purge="true">
<element value="plone.namefromtitle"/>
<element value="plone.locking"/>
<element value="plone.shortname"/>
<element value="imio.smartweb.orientation"/>
</property>

</object>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
name="imio.smartweb.SectionEvents"
meta_type="Dexterity FTI"
i18n:domain="imio.smartweb">

<!-- Enabled behaviors -->
<property name="behaviors" purge="true">
<element value="plone.namefromtitle"/>
<element value="plone.locking"/>
<element value="plone.shortname"/>
<element value="imio.smartweb.orientation"/>
</property>

</object>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
name="imio.smartweb.SectionLinks"
meta_type="Dexterity FTI"
i18n:domain="imio.smartweb">

<!-- Enabled behaviors -->
<property name="behaviors" purge="true">
<element value="plone.namefromtitle"/>
<element value="plone.locking"/>
<element value="plone.shortname"/>
<element value="imio.smartweb.orientation"/>
</property>

</object>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
name="imio.smartweb.SectionNews"
meta_type="Dexterity FTI"
i18n:domain="imio.smartweb">

<!-- Enabled behaviors -->
<property name="behaviors" purge="true">
<element value="plone.namefromtitle"/>
<element value="plone.locking"/>
<element value="plone.shortname"/>
<element value="imio.smartweb.orientation"/>
</property>

</object>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
name="imio.smartweb.SectionSelections"
meta_type="Dexterity FTI"
i18n:domain="imio.smartweb">

<!-- Enabled behaviors -->
<property name="behaviors" purge="true">
<element value="plone.namefromtitle"/>
<element value="plone.locking"/>
<element value="plone.shortname"/>
<element value="imio.smartweb.orientation"/>
</property>

</object>
16 changes: 16 additions & 0 deletions src/imio/smartweb/core/vocabularies.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,22 @@ def __call__(self, context=None):
BootstrapCSSVocabulary = BootstrapCSSVocabularyFactory()


class OrientationVocabularyFactory:
def __call__(self, context=None):
values = [
("portrait", _("Portrait")),
("landscape", _("Landscape")),
]
terms = [
SimpleVocabulary.createTerm(value[0], value[0], value[1])
for value in values
]
return SimpleVocabulary(terms)


OrientationVocabulary = OrientationVocabularyFactory()


class SubsiteDisplayModeVocabularyFactory:
def __call__(self, context=None):
display_mode = [
Expand Down
6 changes: 6 additions & 0 deletions src/imio/smartweb/core/vocabularies.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
provides="zope.schema.interfaces.IVocabularyFactory"
/>

<utility
name="imio.smartweb.vocabulary.Orientation"
component=".vocabularies.OrientationVocabulary"
provides="zope.schema.interfaces.IVocabularyFactory"
/>

<utility
name="imio.smartweb.vocabulary.SubsiteDisplayMode"
component=".vocabularies.SubsiteDisplayModeVocabulary"
Expand Down

0 comments on commit 3c8d5d1

Please sign in to comment.