Skip to content

Commit

Permalink
Rolled back to version 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Mar 14, 2024
1 parent a72253f commit c901ab2
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 384 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*.py?
*.swp
# dirs
__pycache__/
bin/
buildout-cache/
develop-eggs/
Expand Down
20 changes: 0 additions & 20 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,6 @@ Changelog
=========


1.3.2 (unreleased)
------------------

- Nothing changed yet.


1.3.1 (2024-03-14)
------------------

- Handle missing record in restapi endpoint.
[cekk]


1.3.0 (2024-03-07)
------------------

- Add footer_top field in settings, to manage a new footer row before columns.
[cekk]


1.2.1 (2024-01-17)
------------------

Expand Down
23 changes: 10 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,16 @@ To avoid enabling registry access to everyone, this package exposes a dedicated

The response is something similar to this::

{
"footer_top": {...},
"footer_columns": [
{
'text': {'data': '<span>foo</span>'},
'title': 'First column'
},
{
'text': {'content-type': 'text/html', 'data': ''},
'title': 'Second column'
}
]
}
[
{
'text': {'data': '<span>foo</span>'},
'title': 'First column'
},
{
'text': {'content-type': 'text/html', 'data': ''},
'title': 'Second column'
}
]


Control panel
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name="redturtle.voltoplugin.editablefooter",
version="1.3.2.dev0",
version="1.2.1",
description="Add-on for Volto to manage four-columns footer",
long_description=long_description,
# Get more from https://pypi.org/classifiers/
Expand Down
2 changes: 0 additions & 2 deletions src/redturtle/voltoplugin/editablefooter/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

<include package=".browser" />
<include package=".restapi" />
<include package=".upgrades" />


<include file="permissions.zcml" />

Expand Down
9 changes: 0 additions & 9 deletions src/redturtle/voltoplugin/editablefooter/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ class IRedturtleVoltoEditablefooterLayer(IDefaultBrowserLayer):


class IEditableFooterSettings(IControlpanel):
footer_top = SourceText(
title=_("footer_top_label", default="Footer top"),
description=_(
"footer_top_help",
default="Insert some text that will be shown as first element in the footer, before the columns.",
),
required=False,
default="",
)
footer_columns = SourceText(
title=_("footer_columns_label", default="Footer columns"),
description=_(
Expand Down

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions src/redturtle/voltoplugin/editablefooter/locales/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

domain = "redturtle.voltoplugin.editablefooter"
os.chdir(pkg_resources.resource_filename(domain, ""))
os.chdir("../../../../")
os.chdir("../../../")
target_path = "src/redturtle/voltoplugin/editablefooter/"
locale_path = target_path + "locales/"
i18ndude = "./bin/i18ndude"
Expand All @@ -31,7 +31,7 @@ def locale_folder_setup():
)
subprocess.call(cmd, shell=True)

os.chdir("../../../../../")
os.chdir("../../../../")


def _rebuild():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<version>1001</version>
<version>1000</version>
<dependencies>
<dependency>profile-plone.restapi:default</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
<!-- endpoint to get footer data -->
<plone:service
method="GET"
factory=".get.EditableFooterGet"
factory=".get.FooterColumns"
for="Products.CMFCore.interfaces.ISiteRoot"
permission="zope2.View"
name="@footer-columns"
/>

<cache:ruleset
for=".get.EditableFooterGet"
for=".get.FooterColumns"
ruleset="plone.content.dynamic"
/>
</configure>
14 changes: 4 additions & 10 deletions src/redturtle/voltoplugin/editablefooter/restapi/deserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,15 @@ def __call__(self):
req = json_body(self.controlpanel.request)
proxy = self.registry.forInterface(self.schema, prefix=self.schema_prefix)
errors = []
footer_top = req.get("footer_top", {})
footer_columns = req.get("footer_columns", {})

if not footer_columns:
data = req.get("footer_columns", {})
if not data:
errors.append({"message": "Missing data", "field": "footer_columns"})
raise BadRequest(errors)
try:
# later we need to do some validations
setattr(proxy, "footer_columns", json.dumps(footer_columns))
setattr(proxy, "footer_columns", json.dumps(data))
except ValueError as e:
errors.append({"message": str(e), "field": "footer_columns", "error": e})
try:
# later we need to do some validations
setattr(proxy, "footer_top", json.dumps(footer_top))
except ValueError as e:
errors.append({"message": str(e), "field": "footer_top", "error": e})

if errors:
raise BadRequest(errors)
25 changes: 9 additions & 16 deletions src/redturtle/voltoplugin/editablefooter/restapi/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,17 @@


@implementer(IPublishTraverse)
class EditableFooterGet(Service):
class FooterColumns(Service):
def __init__(self, context, request):
super(FooterColumns, self).__init__(context, request)

def reply(self):
res = {"footer_top": None, "footer_columns": None}
footer_columns = api.portal.get_registry_record(
record = api.portal.get_registry_record(
"footer_columns", interface=IEditableFooterSettings, default=""
)
try:
footer_top = api.portal.get_registry_record(
"footer_top", interface=IEditableFooterSettings, default=""
)
except KeyError:
footer_top = ""
if footer_top:
res["footer_top"] = json.loads(footer_top)
if not footer_columns:
return res
data = json.loads(footer_columns)
if not record:
return []
data = json.loads(record)
portal_url = self.get_portal_url()
for el in data or []:
if isinstance(el, dict):
Expand All @@ -50,8 +44,7 @@ def reply(self):
item["text"]["data"] = item["text"]["data"].replace(
'href="/', f'href="{portal_url}/'
)
res["footer_columns"] = data
return res
return data

def get_portal_url(self):
portal_url = api.portal.get().absolute_url()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
class EditableFooterControlpanelSerializeToJson(ControlpanelSerializeToJson):
def __call__(self):
json_data = super(EditableFooterControlpanelSerializeToJson, self).__call__()
for field in ["footer_columns", "footer_top"]:
value = json_data["data"].get(field, "")
if value:
json_data["data"][field] = json.loads(value)
conf = json_data["data"].get("footer_columns", "")
if conf:
json_data["data"]["footer_columns"] = json.loads(conf)
return json_data
Loading

0 comments on commit c901ab2

Please sign in to comment.