Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Commit

Permalink
On creation of the site the creator should be also plone.Owner of the…
Browse files Browse the repository at this point in the history
… site
  • Loading branch information
Ramon Navarro Bosch committed Jan 17, 2017
1 parent 48aa5df commit 8a1de97
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/plone.server/plone/server/api/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
from plone.server.content import create_content
from plone.server.events import notify
from plone.server.json.interfaces import IResourceSerializeToJson
from plone.server.utils import get_authenticated_user_id
from zope.component import getMultiAdapter
from zope.lifecycleevent import ObjectAddedEvent
# from zope.lifecycleevent import ObjectAddedEvent
from plone.server.events import ObjectFinallyCreatedEvent
from plone.server.interfaces import ISite
from plone.server.configure import service
from plone.server.interfaces import IDatabase
from plone.server.interfaces import IApplication
from zope.securitypolicy.interfaces import IPrincipalRoleManager


@service(context=IDatabase, method='GET', permission='plone.GetPortals')
Expand Down Expand Up @@ -82,7 +85,16 @@ async def __call__(self):

self.request._site_id = site.__name__

await notify(ObjectAddedEvent(site, self.context, site.__name__))
user = get_authenticated_user_id(self.request)

# Local Roles assign owner as the creator user
roleperm = IPrincipalRoleManager(site)
roleperm.assignRoleToPrincipal(
'plone.Owner',
user)

await notify(ObjectFinallyCreatedEvent(site))
# await notify(ObjectAddedEvent(site, self.context, site.__name__))

resp = {
'@type': 'Site',
Expand Down

0 comments on commit 8a1de97

Please sign in to comment.