Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
ksuess committed Aug 21, 2023
1 parent 5133ca0 commit 3f3276c
Show file tree
Hide file tree
Showing 16 changed files with 119 additions and 102 deletions.
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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(
[
Expand Down Expand Up @@ -66,7 +68,7 @@
"plone.app.contenttypes",
"plone.app.robotframework[debug]",
"collective.MockMailHost",
"pytest"
"pytest",
],
},
entry_points="""
Expand Down
1 change: 1 addition & 0 deletions src/training/votable/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""Init and utils."""
from zope.i18nmessageid import MessageFactory


_ = MessageFactory("training.votable")

ViewVotesPermission = "training.votable: View Votes"
Expand Down
41 changes: 21 additions & 20 deletions src/training/votable/api/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>

<plone:service
method="GET"
for="training.votable.behaviors.votable.IVotableMarker"
factory=".voting.VotingGet"
name="@votes"
permission="zope2.View"
/>
<plone:service
method="GET"
factory=".voting.VotingGet"
for="training.votable.behaviors.votable.IVotableMarker"
permission="zope2.View"
name="@votes"
/>

<plone:service
method="POST"
for="training.votable.behaviors.votable.IVotableMarker"
factory=".voting.VotingPost"
name="@votes"
permission="training.votable.can_vote"
/>
method="POST"
factory=".voting.VotingPost"
for="training.votable.behaviors.votable.IVotableMarker"
permission="training.votable.can_vote"
name="@votes"
/>

<plone:service
method="DELETE"
for="training.votable.behaviors.votable.IVotableMarker"
factory=".voting.VotingDelete"
name="@votes"
permission="zope2.ViewManagementScreens"
/>
method="DELETE"
factory=".voting.VotingDelete"
for="training.votable.behaviors.votable.IVotableMarker"
permission="zope2.ViewManagementScreens"
name="@votes"
/>

</configure>
11 changes: 4 additions & 7 deletions src/training/votable/api/voting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
34 changes: 19 additions & 15 deletions src/training/votable/behaviors/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
<configure
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">
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"
>

<include package="plone.behavior" file="meta.zcml"/>
<include
package="plone.behavior"
file="meta.zcml"
/>

<!-- -*- extra stuff goes here -*- -->
<!-- -*- extra stuff goes here -*- -->

<plone:behavior
name="training.votable.votable"
title="Votable"
description="Support liking and disliking of content"
provides=".votable.IVotable"
factory=".votable.Votable"
marker=".votable.IVotableMarker"
/>
<plone:behavior
name="training.votable.votable"
title="Votable"
description="Support liking and disliking of content"
factory=".votable.Votable"
provides=".votable.IVotable"
marker=".votable.IVotableMarker"
/>


</configure>
11 changes: 8 additions & 3 deletions src/training/votable/behaviors/votable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 5 additions & 4 deletions src/training/votable/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>

<i18n:registerTranslations directory="locales" />

Expand All @@ -15,7 +16,7 @@


<include file="permissions.zcml" />

<include
package="plone.rest"
file="meta.zcml"
Expand All @@ -24,18 +25,18 @@
<genericsetup:registerProfile
name="default"
title="training.votable"
directory="profiles/default"
description="Installs the training.votable add-on."
provides="Products.GenericSetup.interfaces.EXTENSION"
directory="profiles/default"
post_handler=".setuphandlers.post_install"
/>

<genericsetup:registerProfile
name="uninstall"
title="training.votable (uninstall)"
directory="profiles/uninstall"
description="Uninstalls the training.votable add-on."
provides="Products.GenericSetup.interfaces.EXTENSION"
directory="profiles/uninstall"
post_handler=".setuphandlers.uninstall"
/>

Expand Down
2 changes: 1 addition & 1 deletion src/training/votable/locales/update.py
Original file line number Diff line number Diff line change
@@ -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, ""))
Expand Down
33 changes: 17 additions & 16 deletions src/training/votable/permissions.zcml
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="plone">
xmlns="http://namespaces.zope.org/zope"
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="plone"
>

<configure zcml:condition="installed AccessControl.security">
<!-- -*- extra stuff goes here -*- -->
<!-- -*- extra stuff goes here -*- -->

<permission
id="training.votable.view_vote"
title="training.votable: View Votes"
/>
<permission
id="training.votable.view_vote"
title="training.votable: View Votes"
/>

<permission
id="training.votable.can_vote"
title="training.votable: Can Vote"
/>
<permission
id="training.votable.can_vote"
title="training.votable: Can Vote"
/>

<permission
id="training.votable.clear_votes"
title="training.votable: Clear Votes"
/>
<permission
id="training.votable.clear_votes"
title="training.votable: Clear Votes"
/>

</configure>

Expand Down
7 changes: 3 additions & 4 deletions src/training/votable/profiles/default/browserlayer.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<layers>
<layer
name="training.votable"
interface="training.votable.interfaces.ITrainingVotableLayer"
/>
<layer interface="training.votable.interfaces.ITrainingVotableLayer"
name="training.votable"
/>
</layers>
28 changes: 17 additions & 11 deletions src/training/votable/profiles/default/rolemap.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
<?xml version="1.0"?>
<rolemap>
<permissions>
<!-- -*- extra stuff goes here -*- -->
<!-- -*- extra stuff goes here -*- -->

<permission name="training.votable: View Votes" acquire="True">
<role name="Authenticated"/>
<role name="Site Administrator"/>
<role name="Manager"/>
<permission acquire="True"
name="training.votable: View Votes"
>
<role name="Authenticated" />
<role name="Site Administrator" />
<role name="Manager" />
</permission>
<permission name="training.votable: Can Vote" acquire="True">
<role name="Reviewer"/>
<permission acquire="True"
name="training.votable: Can Vote"
>
<role name="Reviewer" />
</permission>
<permission name="training.votable: Clear Votes" acquire="True">
<role name="Site Administrator"/>
<role name="Manager"/>
<permission acquire="True"
name="training.votable: Clear Votes"
>
<role name="Site Administrator" />
<role name="Manager" />
</permission>

</permissions>
</rolemap>
2 changes: 1 addition & 1 deletion src/training/votable/profiles/testing/types/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<version>202308210954</version>
</metadata>
</metadata>
7 changes: 3 additions & 4 deletions src/training/votable/profiles/uninstall/browserlayer.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<layers>
<layer
name="training.votable"
remove="true"
/>
<layer name="training.votable"
remove="true"
/>
</layers>
15 changes: 9 additions & 6 deletions src/training/votable/testing.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/training/votable/testing.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
directory="profiles/testing"
/>

</configure>
</configure>
Loading

0 comments on commit 3f3276c

Please sign in to comment.