Skip to content

Commit

Permalink
Fix logo for now, use a normal model in the behavior, patch the adapt…
Browse files Browse the repository at this point in the history
…er for root
  • Loading branch information
sneridagh committed Nov 12, 2024
1 parent f5e0c6c commit c361907
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 1 deletion.
4 changes: 3 additions & 1 deletion backend/src/kitconcept/intranet/behaviors/theming.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@


@provider(IFormFieldProvider)
class ITheming(SettingsSchema):
class ITheming(model.Schema):
# @ericof, bring it back when it's ready
# class ITheming(SettingsSchema):
"""Site/Subsite theming properties behavior."""

model.fieldset(
Expand Down
10 changes: 10 additions & 0 deletions backend/src/kitconcept/intranet/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:i18n="http://namespaces.zope.org/i18n"
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="kitconcept.intranet"
>

Expand All @@ -22,5 +23,14 @@
<include file="profiles.zcml" />

<include package=".behaviors" />
<include package=".services" />

<browser:page
allowed_attributes="scale tag"
class="plone.namedfile.scaling.NavigationRootScaling"
for="plone.app.layout.navigation.interfaces.INavigationRoot"
name="images"
permission="zope2.View"
/>

</configure>
Empty file.
20 changes: 20 additions & 0 deletions backend/src/kitconcept/intranet/services/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:i18n="http://namespaces.zope.org/i18n"
xmlns:plone="http://namespaces.plone.org/plone"
i18n_domain="kitconcept.intranet"
>
<plone:service
method="GET"
factory=".navroot.NavrootGet"
for="kitconcept.intranet.interfaces.IBrowserLayer"
permission="zope2.View"
name="@navroot"
/>

<adapter
factory=".navroot.CustomNavroot"
name="navroot"
/>

</configure>
38 changes: 38 additions & 0 deletions backend/src/kitconcept/intranet/services/navroot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
from kitconcept.intranet.interfaces import IBrowserLayer
from plone.restapi.services import Service
from plone.restapi.services.navroot.get import Navroot
from zope.component import adapter
from zope.interface import Interface


# Grab them from the behavior?
SETTINGS = [
"logo",
"accent_color",
"accent_foreground_color",
"primary_color",
"primary_foreground_color",
"secondary_color",
"secondary_foreground_color",
]


@adapter(Interface, IBrowserLayer)
class CustomNavroot(Navroot):
def filterAttributes(self, data):
return {key: data.get(key) for key in data.keys() if key in SETTINGS}

def __call__(self, expand=False):
result = super().__call__(expand)
if not expand:
return result
return {
"navroot": {"navroot": self.filterAttributes(result["navroot"]["navroot"])}
}


class NavrootGet(Service):
def reply(self):
navroot = Navroot(self.context, self.request)
return navroot(expand=True)["navroot"]

0 comments on commit c361907

Please sign in to comment.