Skip to content

Commit

Permalink
Review feedback from sarnold and santonelli
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Arnold committed May 29, 2019
1 parent 9f5781b commit e6f325d
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 82 deletions.
28 changes: 5 additions & 23 deletions src/collective/frontpage/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,27 @@
<include file="permissions.zcml"/>
<include file="upgrades.zcml"/>

<genericsetup:registerProfile
name="clean"
title="Collective Frontpage (collective.frontpage) - Clean"
directory="profiles/clean"
description="Installs the collective.frontpage:clean profile."
provides="Products.GenericSetup.interfaces.EXTENSION"
post_handler=".setuphandlers.clean"
/>

<genericsetup:registerProfile
name="default"
title="Collective Frontpage (collective.frontpage)"
title="Collective Frontpage"
directory="profiles/default"
description="Installs the collective.frontpage add-on."
description="Install collective.frontpage Content Types and Views without setting any content"
provides="Products.GenericSetup.interfaces.EXTENSION"
post_handler=".setuphandlers.post_install"
/>

<genericsetup:registerProfile
name="demo"
title="Collective Frontpage (collective.frontpage) - Demo"
title="Collective Frontpage - Demo"
directory="profiles/demo"
description="Installs the collective.frontpage:demo profile."
description="Install the collective.frontpage in Demo Mode. Do not use in production!"
provides="Products.GenericSetup.interfaces.EXTENSION"
post_handler=".setuphandlers.demo"
/>

<genericsetup:registerProfile
name="testing"
title="Collective Frontpage (collective.frontpage) - Testing"
directory="profiles/testing"
description="Installs the collective.frontpage:testing profile."
provides="Products.GenericSetup.interfaces.EXTENSION"
post_handler=".setuphandlers.testing"
/>

<genericsetup:registerProfile
name="uninstall"
title="Collective Frontpage (collective.frontpage) - Uninstall"
title="Collective Frontpage - Uninstall"
directory="profiles/uninstall"
description="Uninstalls the collective.frontpage add-on."
provides="Products.GenericSetup.interfaces.EXTENSION"
Expand Down
7 changes: 0 additions & 7 deletions src/collective/frontpage/profiles/clean/metadata.xml

This file was deleted.

7 changes: 0 additions & 7 deletions src/collective/frontpage/profiles/testing/metadata.xml

This file was deleted.

89 changes: 46 additions & 43 deletions src/collective/frontpage/setuphandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,44 @@ def getNonInstallableProfiles(self):
return ["collective.frontpage:uninstall"]


def _create_dummy_user():
"""Creates a dummy user for testing"""
api.user.create(
email="max.mustermann@testing.com",
username="mmustermann",
password="testing@collective.frontpage",
properties={"fullname": u"Max Mustermann"},
def post_install(context):
"""Post install script"""
pass


def uninstall(context):
"""Uninstall script"""
pass


def demo(context):
"""Demo handler for the collective.frontpage:demo profile"""
portal = api.portal.get()
_create_frontpage(portal)
_remove_default_pages(portal)
_create_sections(portal)
_create_dummy_user()


def _create_frontpage(portal):
frontpage = api.content.create(
type="Frontpage", container=portal, id="frontpage", title=u"Frontpage"
)
api.content.transition(obj=frontpage, transition="publish")
section = api.content.create(
type="Section",
container=frontpage,
id="section",
title=u"Example Section",
description="This is an example Section in your new Frontpage",
section_type=u"static",
background_color="#F5F5F5",
primary_color="#0083BE",
link_url="https://github.com/collective/collective.frontpage",
link_title="Click me!",
)
api.content.transition(obj=section, transition="publish")
portal.setDefaultPage("frontpage")


def _remove_default_pages(portal):
Expand All @@ -39,12 +69,14 @@ def _remove_default_pages(portal):
pass


def _create_frontpage(portal):
frontpage = api.content.create(
type="Frontpage", container=portal, id="frontpage", title=u"Frontpage"
def _create_dummy_user():
"""Creates a dummy user for testing"""
api.user.create(
email="max.mustermann@testing.com",
username="mmustermann",
password="testing@collective.frontpage",
properties={"fullname": u"Max Mustermann"},
)
api.content.transition(obj=frontpage, transition="publish")
portal.setDefaultPage("frontpage")


def _create_sections(portal):
Expand All @@ -67,36 +99,7 @@ def _create_sections(portal):
section_type=choice(voc_types._terms).token,
background_color=choice(voc_colors._terms).token,
primary_color=choice(voc_colors._terms).token,
link_url="https://www.operun.de",
link_title="Click me!",
)
api.content.transition(obj=section, transition="publish")


def post_install(context):
"""Post install script"""
# Do something at the end of the installation of this package.
portal = api.portal.get()
_create_frontpage(portal)


def uninstall(context):
"""Uninstall script"""
# Do something at the end of the uninstallation of this package.


def clean(context):
"""Clean handler for the collective.frontpage:testing profile"""
# Do something at the end of the clean installation of this package.


def demo(context):
"""Demo handler for the collective.frontpage:testing profile"""
# Do something at the end of the demo installation of this package.
portal = api.portal.get()
_remove_default_pages(portal)
_create_sections(portal)
_create_dummy_user()


def testing(context):
"""Testing handler for the collective.frontpage:testing profile"""
# Do something at the end of the testing installation of this package.
3 changes: 1 addition & 2 deletions src/collective/frontpage/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def setUpPloneSite(self, portal):

class CollectiveFrontpageTestingLayer(CollectiveFrontpageLayer):
def setUpPloneSite(self, portal): # noqa
applyProfile(portal, "collective.frontpage:testing")
applyProfile(portal, "collective.frontpage:demo")
portal.acl_users.userFolderAddUser(
SITE_OWNER_NAME, SITE_OWNER_PASSWORD, ["Manager"], []
)
Expand All @@ -88,7 +88,6 @@ def setUpPloneSite(self, portal):
setup_sdm(portal)


COLLECTIVE_FRONTPAGE_FIXTURE = CollectiveFrontpageLayer()
COLLECTIVE_FRONTPAGE_TESTING_FIXTURE = CollectiveFrontpageTestingLayer()
COLLECTIVE_FRONTPAGE_ACCEPTANCE_SESSION_FIXTURE = CollectiveFrontpageSessionLayer()

Expand Down

0 comments on commit e6f325d

Please sign in to comment.