Skip to content

Commit 796936c

Browse files
authored
Merge pull request #7 from codesyntax/develop
Develop
2 parents 02b3628 + aa4bd4b commit 796936c

47 files changed

Lines changed: 1452 additions & 238 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@ var/
4141
/sources/
4242
/venv/
4343
constraints*.txt
44-
requirements*.txt
44+
requirements*.txt
45+
.mxdev_cache
46+

news/7.feat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- Add icons to views @libargutxi
2+
- Add row spacing configuration @libargutxi
3+
- Add behavior to set fetchpriority/loading attributes to images @libargutxi
4+
- Complete translations @erral

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "cs_dynamicpages"
33
dynamic = ["version"]
44
description = "A new addon for Plone"
55
readme = "README.md"
6-
requires-python = ">=3.10"
6+
requires-python = ">=3.10,<3.14"
77
authors = [{ name = "CodeSyntax", email = "plone@codesyntax.com" }]
88
keywords = ["CMS", "Plone", "Python"]
99
classifiers = [

src/cs_dynamicpages/behaviors/configure.zcml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
/>
1313

1414
<!-- -*- extra stuff goes here -*- -->
15+
<plone:behavior
16+
name="cs_dynamicpages.row_vertical_spacing"
17+
title="RowVerticalSpacing"
18+
description="This behavior provides..."
19+
factory=".row_vertical_spacing.RowVerticalSpacing"
20+
provides=".row_vertical_spacing.IRowVerticalSpacing"
21+
marker=".row_vertical_spacing.IRowVerticalSpacingMarker"
22+
/>
1523

1624
<plone:behavior
1725
name="cs_dynamicpages.row_width"
@@ -51,6 +59,15 @@
5159
marker=".related_image.IRelatedImageMarker"
5260
/>
5361

62+
<plone:behavior
63+
name="cs_dynamicpages.fetchpriority_image"
64+
title="FetchPriorityImage"
65+
description="This behavior provides..."
66+
factory=".fetchpriority_image.FetchPriorityImage"
67+
provides=".fetchpriority_image.IFetchPriorityImage"
68+
marker=".fetchpriority_image.IFetchPriorityImageMarker"
69+
/>
70+
5471

5572
<plone:behavior
5673
name="cs_dynamicpages.link_info"
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from cs_dynamicpages import _
2+
from plone import schema
3+
from plone.autoform.interfaces import IFormFieldProvider
4+
from plone.supermodel import model
5+
from Products.CMFPlone.utils import safe_hasattr
6+
from zope.component import adapter
7+
from zope.interface import implementer
8+
from zope.interface import Interface
9+
from zope.interface import provider
10+
11+
12+
class IFetchPriorityImageMarker(Interface):
13+
pass
14+
15+
16+
@provider(IFormFieldProvider)
17+
class IFetchPriorityImage(model.Schema):
18+
""" """
19+
20+
fetchpriority_image = schema.Bool(
21+
title=_("Fetch priority image"),
22+
description=_(
23+
"Set this to true if you want to signal that this image has a 'high' fetch "
24+
"priority, otherwise 'auto' will be used. When using 'high' the value of "
25+
"the loading attribute will be set to 'eager', and 'lazy' when "
26+
"it is not set."
27+
),
28+
required=False,
29+
)
30+
31+
32+
@implementer(IFetchPriorityImage)
33+
@adapter(IFetchPriorityImageMarker)
34+
class FetchPriorityImage:
35+
def __init__(self, context):
36+
self.context = context
37+
38+
@property
39+
def fetchpriority_image(self):
40+
if safe_hasattr(self.context, "fetchpriority_image"):
41+
return self.context.fetchpriority_image
42+
return None
43+
44+
@fetchpriority_image.setter
45+
def fetchpriority_image(self, value):
46+
self.context.fetchpriority_image = value

src/cs_dynamicpages/behaviors/link_info.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from cs_dynamicpages import _
22
from plone import schema
3+
from plone.app.z3cform.widgets.link import LinkFieldWidget
4+
from plone.autoform import directives as form
35
from plone.autoform.interfaces import IFormFieldProvider
46
from plone.supermodel import model
57
from Products.CMFPlone.utils import safe_hasattr
@@ -29,6 +31,11 @@ class ILinkInfo(model.Schema):
2931
required=False,
3032
)
3133

34+
form.widget(
35+
"link_url",
36+
LinkFieldWidget,
37+
)
38+
3239

3340
@implementer(ILinkInfo)
3441
@adapter(ILinkInfoMarker)
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
from cs_dynamicpages import _
2+
from plone import schema
3+
from plone.autoform.interfaces import IFormFieldProvider
4+
from plone.supermodel import model
5+
from Products.CMFPlone.utils import safe_hasattr
6+
from zope.component import adapter
7+
from zope.interface import implementer
8+
from zope.interface import Interface
9+
from zope.interface import provider
10+
11+
12+
class IRowVerticalSpacingMarker(Interface):
13+
pass
14+
15+
16+
@provider(IFormFieldProvider)
17+
class IRowVerticalSpacing(model.Schema):
18+
padding_top = schema.Choice(
19+
title=_("Row padding top"),
20+
description=_("Select the padding top that this row will have"),
21+
vocabulary="cs_dynamicpages.RowPaddingTop",
22+
required=True,
23+
default="pt-0",
24+
)
25+
padding_bottom = schema.Choice(
26+
title=_("Row padding bottom"),
27+
description=_("Select the padding bottom that this row will have"),
28+
vocabulary="cs_dynamicpages.RowPaddingBottom",
29+
required=True,
30+
default="pb-0",
31+
)
32+
margin_top = schema.Choice(
33+
title=_("Row margin top"),
34+
description=_("Select the margin top that this row will have"),
35+
vocabulary="cs_dynamicpages.RowMarginTop",
36+
required=True,
37+
default="mt-0",
38+
)
39+
margin_bottom = schema.Choice(
40+
title=_("Row margin bottom"),
41+
description=_("Select the margin bottom that this row will have"),
42+
vocabulary="cs_dynamicpages.RowMarginBottom",
43+
required=True,
44+
default="mb-0",
45+
)
46+
47+
48+
@implementer(IRowVerticalSpacing)
49+
@adapter(IRowVerticalSpacingMarker)
50+
class RowVerticalSpacing:
51+
def __init__(self, context):
52+
self.context = context
53+
54+
@property
55+
def padding_top(self):
56+
if safe_hasattr(self.context, "padding_top"):
57+
return self.context.padding_top
58+
return None
59+
60+
@padding_top.setter
61+
def padding_top(self, value):
62+
self.context.padding_top = value
63+
64+
@property
65+
def padding_bottom(self):
66+
if safe_hasattr(self.context, "padding_bottom"):
67+
return self.context.padding_bottom
68+
return None
69+
70+
@padding_bottom.setter
71+
def padding_bottom(self, value):
72+
self.context.padding_bottom = value
73+
74+
@property
75+
def margin_top(self):
76+
if safe_hasattr(self.context, "margin_top"):
77+
return self.context.margin_top
78+
return None
79+
80+
@margin_top.setter
81+
def margin_top(self, value):
82+
self.context.margin_top = value
83+
84+
@property
85+
def margin_bottom(self):
86+
if safe_hasattr(self.context, "margin_bottom"):
87+
return self.context.margin_bottom
88+
return None
89+
90+
@margin_bottom.setter
91+
def margin_bottom(self, value):
92+
self.context.margin_bottom = value
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from plone import api
2+
from plone.app.layout.globals.layout import IBodyClassAdapter
3+
from zope.component import adapter
4+
from zope.interface import implementer
5+
from zope.interface import Interface
6+
7+
8+
@adapter(Interface, Interface)
9+
@implementer(IBodyClassAdapter)
10+
class DynamicViewFolderClasses:
11+
def __init__(self, context, request):
12+
self.context = context
13+
self.request = request
14+
15+
def get_classes(self, template, view):
16+
"""Whenever we are in a dynamic-view, add a custom class
17+
signaling that the user can edit the content
18+
"""
19+
if template.id == "dynamic_view.pt":
20+
can_edit = api.user.has_permission(
21+
"Modify portal content", obj=self.context
22+
)
23+
if can_edit:
24+
return ["can_edit"]
25+
return []
26+
return []

src/cs_dynamicpages/browser/configure.zcml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@
1414
type="plone"
1515
/>
1616

17+
<adapter factory=".body_class.DynamicViewFolderClasses" />
18+
1719
</configure>

src/cs_dynamicpages/browser/static/delete-row.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// Only run on dynamic-view with edit permissions
1717
if (
1818
!document.body.classList.contains("template-dynamic-view") ||
19-
!document.body.classList.contains("userrole-manager")
19+
!document.body.classList.contains("can_edit")
2020
) {
2121
return;
2222
}
@@ -114,7 +114,10 @@
114114
if (modal) {
115115
modal.hide();
116116
}
117-
sessionStorage.setItem('toast-message', 'Element deleted successfully.');
117+
sessionStorage.setItem(
118+
"toast-message",
119+
"Element deleted successfully."
120+
);
118121
// Refresh the page after successful update
119122
window.location.reload();
120123
});

0 commit comments

Comments
 (0)