Skip to content

Commit

Permalink
Merge f8ff812 into e704045
Browse files Browse the repository at this point in the history
  • Loading branch information
boulch committed Jan 26, 2023
2 parents e704045 + f8ff812 commit 766236c
Show file tree
Hide file tree
Showing 25 changed files with 2,287 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Changelog
1.1.2 (unreleased)
------------------

- Add new content type : imio.smartweb.CirkwiView
[boulch]

- Add authentic sources menu in toolbar
[boulch, laulaz]

Expand Down
7 changes: 6 additions & 1 deletion src/imio/smartweb/core/browser/instancebehaviors/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

from imio.smartweb.common.utils import get_vocabulary
from imio.smartweb.core.contents import ICirkwiView
from imio.smartweb.core.contents import IPage
from imio.smartweb.core.contents import IProcedure
from Products.Five.browser import BrowserView
Expand All @@ -15,4 +16,8 @@ def is_instancebehaviors_assignable_content(self):
)
if len(instance_behaviors_voc) == 0:
return False
return IPage.providedBy(self.context) or IProcedure.providedBy(self.context)
return (
IPage.providedBy(self.context)
or IProcedure.providedBy(self.context)
or ICirkwiView.providedBy(self.context)
)
1 change: 1 addition & 0 deletions src/imio/smartweb/core/contents/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .blocks.link.content import IBlockLink, BlockLink # NOQA
from .pages.pages import IPages, IDefaultPages, Pages # NOQA
from .folder.content import IFolder, Folder # NOQA
from .pages.cirkwi.content import ICirkwiView, CirkwiView # NOQA
from .pages.footer.content import IFooter, Footer # NOQA
from .pages.herobanner.content import IHeroBanner, HeroBanner # NOQA
from .pages.page.content import IPage, Page # NOQA
Expand Down
Empty file.
14 changes: 14 additions & 0 deletions src/imio/smartweb/core/contents/pages/cirkwi/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">

<browser:page
name="view"
for="imio.smartweb.core.contents.ICirkwiView"
class=".view.CirkwiViewView"
template="view.pt"
permission="zope2.View"
layer="imio.smartweb.core.interfaces.IImioSmartwebCoreLayer"
/>

</configure>
25 changes: 25 additions & 0 deletions src/imio/smartweb/core/contents/pages/cirkwi/content.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-

from imio.smartweb.common.config import DESCRIPTION_MAX_LENGTH
from imio.smartweb.core.contents import IPages
from imio.smartweb.core.contents import Pages
from imio.smartweb.locales import SmartwebMessageFactory as _
from zope.interface import implementer
from zope import schema


class ICirkwiView(IPages):
"""Marker interface and Dexterity Python Schema for SectionCirkwi"""

cirkwi_widget_id = schema.TextLine(
title=_("Cirkwi widget ID"),
description=_(
"Specify your cirkwi widget ID. You can find it when you create a new widget in Cirkwi."
),
required=True,
)


@implementer(ICirkwiView)
class CirkwiView(Pages):
"""SectionCirkwi class"""
13 changes: 13 additions & 0 deletions src/imio/smartweb/core/contents/pages/cirkwi/view.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html
metal:use-macro="context/main_template/macros/master"
i18n:domain="imio.smartweb">
<body>
<metal:main fill-slot="content-core">
<div class="full-width">
<div class="cirkwi_richtext" tal:content="structure context/text/output|nothing"></div>
<div class="cirkwi_contents" tal:content="structure view/get_cirkwi_html" />
</div>
</metal:main>

</body>
</html>
18 changes: 18 additions & 0 deletions src/imio/smartweb/core/contents/pages/cirkwi/view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-

from Products.Five.browser import BrowserView

import requests


class CirkwiViewView(BrowserView):

cirwki_api_uri = "https://www.modulesbox.com/fr/api/module/"

def get_cirkwi_html(self):
cirkwi_widget_id = self.context.cirkwi_widget_id
url = f"{self.cirwki_api_uri}{cirkwi_widget_id}"
response = requests.get(url)
if response.status_code != 200:
return response.status_code
return response.text
1 change: 1 addition & 0 deletions src/imio/smartweb/core/contents/pages/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">

<include package=".cirkwi" />
<include package=".footer" />
<include package=".herobanner" />
<include package=".page" />
Expand Down
5 changes: 5 additions & 0 deletions src/imio/smartweb/core/permissions.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
title="imio.smartweb.core: Add Procedure"
/>

<permission
id="imio.smartweb.core.AddCirkwiView"
title="imio.smartweb.core: Add Cirkwi view"
/>

<permission
id="imio.smartweb.core.ManageMinisite"
title="imio.smartweb.core: Manage Minisite"
Expand Down
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>1035</version>
<version>1036</version>
<dependencies>
<dependency>profile-plone.app.dexterity:default</dependency>
<dependency>profile-plone.app.imagecropping:default</dependency>
Expand Down
1 change: 1 addition & 0 deletions src/imio/smartweb/core/profiles/default/registry/plone.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
interface="Products.CMFPlone.interfaces.controlpanel.INavigationSchema"
field="displayed_types">
<value purge="false">
<element>imio.smartweb.CirkwiView</element>
<element>imio.smartweb.DirectoryView</element>
<element>imio.smartweb.EventsView</element>
<element>imio.smartweb.Folder</element>
Expand Down
7 changes: 7 additions & 0 deletions src/imio/smartweb/core/profiles/default/rolemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
<role name="Contributor"/>
</permission>

<permission name="imio.smartweb.core: Add Cirkwi view" acquire="True">
<role name="Manager"/>
<role name="Site Administrator"/>
<role name="Owner"/>
<role name="Contributor"/>
</permission>

<permission name="imio.smartweb.core: Manage Minisite" acquire="True">
<role name="Manager"/>
<role name="Site Administrator"/>
Expand Down
1 change: 1 addition & 0 deletions src/imio/smartweb/core/profiles/default/types.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<object name="portal_types" meta_type="Plone Types Tool">
<object meta_type="Dexterity FTI" name="imio.smartweb.BlockLink"/>
<object meta_type="Dexterity FTI" name="imio.smartweb.CirkwiView"/>
<object meta_type="Dexterity FTI" name="imio.smartweb.DirectoryView"/>
<object meta_type="Dexterity FTI" name="imio.smartweb.EventsView"/>
<object meta_type="Dexterity FTI" name="imio.smartweb.Folder"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0"?>
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
name="imio.smartweb.DirectoryView"
meta_type="Dexterity FTI"
i18n:domain="imio.smartweb">

<!-- Basic properties -->
<property
i18n:translate=""
name="title">Cirkwi view</property>
<property
i18n:translate=""
name="description">Display cirkwi informations and map.</property>

<property name="icon_expr">string:file-person</property>

<!-- Hierarchy control -->
<property name="global_allow">True</property>

<!-- Schema, class and security -->
<property name="add_permission">imio.smartweb.core.AddCirkwiView</property>
<property name="klass">imio.smartweb.core.contents.CirkwiView</property>
<property name="schema">imio.smartweb.core.contents.ICirkwiView</property>

<!-- Enabled behaviors -->
<property name="behaviors" purge="false">
<element value="plone.namefromtitle"/>
<element value="plone.excludefromnavigation"/>
<element value="plone.shortname"/>
<element value="plone.publication"/>
<element value="plone.basic"/>
<element value="plone.locking"/>
<element value="plone.leadimage"/>
<element value="plone.richtext"/>
<element value="imio.smartweb.listing"/>
<element value="imio.smartweb.topics"/>
<element value="imio.smartweb.iam"/>
<element value="plone.categorization"/>
<element value="collective.autopublishing.behavior.IAutoPublishing"/>
</property>

</object>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<element value="Collection" />
<element value="Message" />
<element value="Link" />
<element value="imio.smartweb.CirkwiView" />
<element value="imio.smartweb.DirectoryView" />
<element value="imio.smartweb.EventsView" />
<element value="imio.smartweb.Folder" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div id="content-core">
<div class="full-width">
<div class="cirkwi_richtext"></div>
<div class="cirkwi_contents">404</div>
</div>
</div>

0 comments on commit 766236c

Please sign in to comment.