Skip to content

Commit

Permalink
use distribution when creating the site
Browse files Browse the repository at this point in the history
  • Loading branch information
pbauer committed Mar 7, 2024
1 parent 6526593 commit 96bde0a
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 291 deletions.
20 changes: 8 additions & 12 deletions backend/scripts/create_site.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from AccessControl.SecurityManagement import newSecurityManager
from plone.distribution.api import site as site_api
from plone6demo.interfaces import IPLONE6DEMOLayer
from Products.CMFPlone.factory import _DEFAULT_PROFILE
from Products.CMFPlone.factory import addPloneSite
from Testing.makerequest import makerequest
from zope.interface import directlyProvidedBy
from zope.interface import directlyProvides
Expand Down Expand Up @@ -42,21 +41,18 @@ def asbool(s):
newSecurityManager(None, admin)

site_id = "Plone"
payload = {
"title": "Plone 6 Demo Site",
"profile_id": _DEFAULT_PROFILE,
"extension_ids": ["plone6demo:default", "plone6demo:initial", "plone.volto:demo"],
"setup_content": False,
answers = {
"site_id": site_id,
"title": "Plone Site",
"description": "A Plone Site",
"default_language": "en",
"portal_timezone": "America/Sao_Paulo",
"setup_content": True,
}

if site_id in app.objectIds() and DELETE_EXISTING:
app.manage_delObjects([site_id])
app.manage_delObjects(site_id)
transaction.commit()
app._p_jar.sync()

if site_id not in app.objectIds():
site = addPloneSite(app, site_id, **payload)
transaction.commit()
app._p_jar.sync()
site_api._create_site(context=app, distribution_name="voltodemo", answers=answers)
4 changes: 4 additions & 0 deletions backend/src/plone6demo/src/plone6demo/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
package="plone.behavior"
file="meta.zcml"
/>
<include
package="plone.distribution"
file="meta.zcml"
/>

<include file="dependencies.zcml" />

Expand Down
9 changes: 0 additions & 9 deletions backend/src/plone6demo/src/plone6demo/profiles.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@
directory="profiles/default"
/>

<genericsetup:registerProfile
name="initial"
title="Plone 6 Demo Site: Initial content"
description="Initial content for our website."
provides="Products.GenericSetup.interfaces.EXTENSION"
directory="profiles/initial"
pre_handler=".setuphandlers.populate_portal"
/>

<genericsetup:registerProfile
name="uninstall"
title="Plone 6 Demo Site: Uninstall"
Expand Down

This file was deleted.

22 changes: 0 additions & 22 deletions backend/src/plone6demo/src/plone6demo/setuphandlers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from plone import api
from plone6demo import logger
from plone6demo.setuphandlers import content
from plone6demo.setuphandlers import users
from Products.CMFPlone.interfaces import INonInstallable
from zope.interface import implementer

Expand All @@ -13,22 +10,3 @@ def getNonInstallableProfiles(self):
return [
"plone6demo:uninstall",
]


def populate_portal(context):
"""Post install script"""
portal = api.portal.get()
# Delete content
content.delete_content(portal)
logger.info("Deleted default portal content")
user = users.create_default_user()
creators = [user.id]
logger.info("Created default user")
# Create other users
users.create_team_accounts()
logger.info("Created team accounts")
# Create Initial content
content.populate_portal(portal, creators)
logger.info("Created initial content")
# Update cover content
content.update_home(portal, creators)
103 changes: 0 additions & 103 deletions backend/src/plone6demo/src/plone6demo/setuphandlers/content.py

This file was deleted.

26 changes: 0 additions & 26 deletions backend/src/plone6demo/src/plone6demo/setuphandlers/contents.json

This file was deleted.

49 changes: 0 additions & 49 deletions backend/src/plone6demo/src/plone6demo/setuphandlers/home.json

This file was deleted.

Binary file not shown.
19 changes: 0 additions & 19 deletions backend/src/plone6demo/src/plone6demo/setuphandlers/users.json

This file was deleted.

47 changes: 0 additions & 47 deletions backend/src/plone6demo/src/plone6demo/setuphandlers/users.py

This file was deleted.

0 comments on commit 96bde0a

Please sign in to comment.