diff --git a/setup.py b/setup.py
index 9523ee1..efdc13b 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
"""Installer for the training.votable package."""
-from setuptools import find_packages, setup
+from setuptools import find_packages
+from setuptools import setup
+
long_description = "\n\n".join(
[
@@ -66,7 +68,7 @@
"plone.app.contenttypes",
"plone.app.robotframework[debug]",
"collective.MockMailHost",
- "pytest"
+ "pytest",
],
},
entry_points="""
diff --git a/src/training/votable/__init__.py b/src/training/votable/__init__.py
index 886deb7..b9c1fdb 100644
--- a/src/training/votable/__init__.py
+++ b/src/training/votable/__init__.py
@@ -2,6 +2,7 @@
"""Init and utils."""
from zope.i18nmessageid import MessageFactory
+
_ = MessageFactory("training.votable")
ViewVotesPermission = "training.votable: View Votes"
diff --git a/src/training/votable/api/configure.zcml b/src/training/votable/api/configure.zcml
index f83a627..05c9f25 100644
--- a/src/training/votable/api/configure.zcml
+++ b/src/training/votable/api/configure.zcml
@@ -2,30 +2,31 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:plone="http://namespaces.plone.org/plone"
- i18n_domain="training.votable">
+ i18n_domain="training.votable"
+ >
-
+
+ method="POST"
+ factory=".voting.VotingPost"
+ for="training.votable.behaviors.votable.IVotableMarker"
+ permission="training.votable.can_vote"
+ name="@votes"
+ />
+ method="DELETE"
+ factory=".voting.VotingDelete"
+ for="training.votable.behaviors.votable.IVotableMarker"
+ permission="zope2.ViewManagementScreens"
+ name="@votes"
+ />
diff --git a/src/training/votable/api/voting.py b/src/training/votable/api/voting.py
index fea5442..5566e09 100644
--- a/src/training/votable/api/voting.py
+++ b/src/training/votable/api/voting.py
@@ -3,17 +3,14 @@
from plone.protect.interfaces import IDisableCSRFProtection
from plone.restapi.deserializer import json_body
from plone.restapi.services import Service
+from training.votable import CanVotePermission
+from training.votable import ClearVotesPermission
+from training.votable import ViewVotesPermission
+from training.votable.behaviors.votable import IVotable
from zExceptions import Unauthorized
from zope.globalrequest import getRequest
from zope.interface import alsoProvides
-from training.votable import (
- CanVotePermission,
- ClearVotesPermission,
- ViewVotesPermission,
-)
-from training.votable.behaviors.votable import IVotable
-
class VotingGet(Service):
"""Voting information about the current object"""
diff --git a/src/training/votable/behaviors/configure.zcml b/src/training/votable/behaviors/configure.zcml
index 06ca4ac..e25873d 100644
--- a/src/training/votable/behaviors/configure.zcml
+++ b/src/training/votable/behaviors/configure.zcml
@@ -1,22 +1,26 @@
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ xmlns:plone="http://namespaces.plone.org/plone"
+ xmlns:zcml="http://namespaces.zope.org/zcml"
+ i18n_domain="plone"
+ >
-
+
-
+
-
+
diff --git a/src/training/votable/behaviors/votable.py b/src/training/votable/behaviors/votable.py
index 02428f1..2f46094 100644
--- a/src/training/votable/behaviors/votable.py
+++ b/src/training/votable/behaviors/votable.py
@@ -2,13 +2,18 @@
from persistent.dict import PersistentDict
from persistent.list import PersistentList
-from plone import api, schema
+from plone import api
+from plone import schema
from plone.autoform import directives as form
from plone.autoform.interfaces import IFormFieldProvider
-from plone.supermodel import directives, model
+from plone.supermodel import directives
+from plone.supermodel import model
from zope.annotation.interfaces import IAnnotations
from zope.component import adapter
-from zope.interface import Interface, implementer, provider
+from zope.interface import implementer
+from zope.interface import Interface
+from zope.interface import provider
+
"""
The key must be unique.
diff --git a/src/training/votable/configure.zcml b/src/training/votable/configure.zcml
index afd1492..b04caef 100644
--- a/src/training/votable/configure.zcml
+++ b/src/training/votable/configure.zcml
@@ -3,7 +3,8 @@
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
xmlns:i18n="http://namespaces.zope.org/i18n"
xmlns:plone="http://namespaces.plone.org/plone"
- i18n_domain="training.votable">
+ i18n_domain="training.votable"
+ >
@@ -15,7 +16,7 @@
-
+
diff --git a/src/training/votable/locales/update.py b/src/training/votable/locales/update.py
index 3fd7546..b54f531 100644
--- a/src/training/votable/locales/update.py
+++ b/src/training/votable/locales/update.py
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
import os
+import pkg_resources
import subprocess
-import pkg_resources
domain = "training.votable"
os.chdir(pkg_resources.resource_filename(domain, ""))
diff --git a/src/training/votable/permissions.zcml b/src/training/votable/permissions.zcml
index e79dfaa..d395427 100644
--- a/src/training/votable/permissions.zcml
+++ b/src/training/votable/permissions.zcml
@@ -1,25 +1,26 @@
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:zcml="http://namespaces.zope.org/zcml"
+ i18n_domain="plone"
+ >
-
+
-
+
-
+
-
+
diff --git a/src/training/votable/profiles/default/browserlayer.xml b/src/training/votable/profiles/default/browserlayer.xml
index 97c81ac..aac9b7d 100644
--- a/src/training/votable/profiles/default/browserlayer.xml
+++ b/src/training/votable/profiles/default/browserlayer.xml
@@ -1,7 +1,6 @@
-
+
diff --git a/src/training/votable/profiles/default/rolemap.xml b/src/training/votable/profiles/default/rolemap.xml
index a80418d..d81d823 100644
--- a/src/training/votable/profiles/default/rolemap.xml
+++ b/src/training/votable/profiles/default/rolemap.xml
@@ -1,20 +1,26 @@
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
+
+
+
-
+
diff --git a/src/training/votable/profiles/testing/types/metadata.xml b/src/training/votable/profiles/testing/types/metadata.xml
index a548ac7..25af642 100644
--- a/src/training/votable/profiles/testing/types/metadata.xml
+++ b/src/training/votable/profiles/testing/types/metadata.xml
@@ -1,4 +1,4 @@
202308210954
-
\ No newline at end of file
+
diff --git a/src/training/votable/profiles/uninstall/browserlayer.xml b/src/training/votable/profiles/uninstall/browserlayer.xml
index 57c4ab6..7532789 100644
--- a/src/training/votable/profiles/uninstall/browserlayer.xml
+++ b/src/training/votable/profiles/uninstall/browserlayer.xml
@@ -1,7 +1,6 @@
-
+
diff --git a/src/training/votable/testing.py b/src/training/votable/testing.py
index 9bf7d4b..bc486d9 100644
--- a/src/training/votable/testing.py
+++ b/src/training/votable/testing.py
@@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE
from plone.app.robotframework.testing import REMOTE_LIBRARY_BUNDLE_FIXTURE
-from plone.app.testing import (
- FunctionalTesting,
- IntegrationTesting,
- PloneSandboxLayer,
- applyProfile,
-)
+from plone.app.testing import applyProfile
+from plone.app.testing import FunctionalTesting
+from plone.app.testing import IntegrationTesting
+from plone.app.testing import PloneSandboxLayer
from plone.testing import z2
from plone.testing import zope
+
+
# from zope.configuration import xmlconfig
@@ -21,13 +21,16 @@ def setUpZope(self, app, configurationContext):
# The z3c.autoinclude feature is disabled in the Plone fixture base
# layer.
import plone.app.dexterity
+
self.loadZCML(package=plone.app.dexterity)
import plone.restapi
+
self.loadZCML(package=plone.restapi)
# training.votable
import training.votable
+
self.loadZCML(package=training.votable)
self.loadZCML("testing.zcml", package=training.votable)
diff --git a/src/training/votable/testing.zcml b/src/training/votable/testing.zcml
index f5769ab..68ac6a6 100644
--- a/src/training/votable/testing.zcml
+++ b/src/training/votable/testing.zcml
@@ -16,4 +16,4 @@
directory="profiles/testing"
/>
-
\ No newline at end of file
+
diff --git a/src/training/votable/tests/test_voting.py b/src/training/votable/tests/test_voting.py
index 4fc3d00..c01b6b6 100644
--- a/src/training/votable/tests/test_voting.py
+++ b/src/training/votable/tests/test_voting.py
@@ -1,15 +1,15 @@
from pkg_resources import resource_filename
+from plone.app.testing import popGlobalRegistry
+from plone.app.testing import pushGlobalRegistry
from plone.app.testing import setRoles
from plone.app.testing import SITE_OWNER_NAME
from plone.app.testing import SITE_OWNER_PASSWORD
from plone.app.testing import TEST_USER_ID
from plone.app.testing import TEST_USER_PASSWORD
+from plone.restapi.testing import register_static_uuid_utility
from plone.restapi.testing import RelativeSession
from plone.restapi.tests.statictime import StaticTime
from plone.testing.zope import Browser
-from plone.app.testing import popGlobalRegistry
-from plone.app.testing import pushGlobalRegistry
-from plone.restapi.testing import register_static_uuid_utility
from training.votable.testing import TRAINING_VOTABLE_FUNCTIONAL_TESTING
from zope.component.hooks import getSite
@@ -138,7 +138,6 @@ def save_request_for_docs(name, response, request_text_override=""):
class TestVotingBase(unittest.TestCase):
-
def setUp(self):
self.statictime = self.setup_with_context_manager(StaticTime())
@@ -218,9 +217,8 @@ def test_documentation_voting(self):
# Vote on talk
response = self.api_session.post(
f"{talk_python.absolute_url()}/@votes",
- json={
- "rating": 1
- },)
+ json={"rating": 1},
+ )
save_request_and_response_for_docs("talk_vote", response)
response = response.json()
self.assertEqual(response["average_vote"], 1)