Skip to content

Commit

Permalink
Merge pull request #10 from collective/issue_6_profiles
Browse files Browse the repository at this point in the history
Add Demo Profile & Demo-Content
  • Loading branch information
sarn0ld committed May 29, 2019
2 parents 3cdf2cb + e6f325d commit 5782b74
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 31 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ Added:
- Added configurable section colors to configlet. #5
[netroxen]

- Added Clean and Demo profiles with demo content. #6
[netroxen]

- Initial release.
[sarn0ld]
96 changes: 96 additions & 0 deletions src/collective/frontpage/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# -*- coding: utf-8 -*-

DUMMY_TITLES = [
u"Quo in",
u"Aspernatur zzril",
u"Deleniti accusam",
u"Repellat kasd",
u"Consectetur vero",
u"Veritatis sanctus",
u"Architecto numquam",
u"Pariatur gubergren",
u"Magnam dolores te",
u"Maxime blandit",
u"Lorem ipsum",
]

DUMMY_SUBTITLES = [
u"Iriure dolor in hendrerit.",
u"Vero eros et accumsan.",
u"Praesent luptatum zzril.",
u"Autem vel eum iriure.",
u"Stet clita kasd.",
u"Vero eos et accusam.",
u"Dignissim qui blandit.",
u"Justo duo dolores et.",
u"Consetetur sadipscing elitr.",
u"Clita kasd gubergren.",
u"Te feugait nulla.",
u"Nulla facilisis at vero.",
u"Takimata sanctus est.",
]

DUMMY_DESCRIPTIONS = [
u"Duis autem vel eum iriure dolor in hendrerit in vulputate velit "
"esse molestie consequat.",
u"Feugiat nulla facilisis at vero eros et accumsan et iusto odio "
"dignissim qui blandit praesent luptatum zzril delenit augue duis "
"dolore te feugait nulla facilisi. Lorem ipsum dolor sit",
u"In hendrerit in vulputate velit esse molestie consequat, vel illum "
"dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto "
"odio dignissim qui blandit praesent.",
u"At vero eos et accusam et justo duo dolores et ea rebum. "
"Stet clita kasd gubergren.",
u"Takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor "
"sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor "
"invidunt ut labore et dolore.",
u"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam "
"nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam "
"erat, sed diam voluptua.",
u"Stet clita kasd gubergren, no sea takimata sanctus est "
"Lorem ipsum dolor sit amet.",
u"Magna aliquyam erat, sed diam voluptua. At vero eos et accusam "
"et justo duo dolores et ea rebum.",
u"Zzril delenit augue duis dolore te feugait nulla facilisi. Lorem "
"ipsum dolor sit amet.",
u"Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper "
"suscipit lobortis nisl ut aliquip ex ea commodo consequat.",
u"Nam liber tempor cum soluta nobis eleifend option congue nihil "
"imperdiet doming id quod mazim placerat facer possim assum.",
u"Sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna "
"aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud "
"exerci tation ullamcorper suscipit lobortis nisl ut aliquip.",
u"Vel eum iriure dolor in hendrerit in vulputate velit esse "
"molestie consequat, vel illum dolore eu feugiat.",
]

DUMMY_TEXT = [
u"<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed "
"do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim "
"ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut "
"aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit "
"in voluptate velit esse cillum dolore eu fugiat nulla pariatur."
"</p><p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui "
"officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit "
"amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt "
"ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud "
"exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. "
"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum "
"dolore eu fugiat nulla pariatur.</p>",
u"<p>Consectetur adipisicing elit, sed do eiusmod tempor incididunt "
"ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis "
"nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo "
"consequat. Duis aute irure dolor in reprehenderit in voluptate velit "
"esse cillum dolore eu fugiat nulla pariatur.</p>",
u"<p>Sed do eiusmod tempor incididunt ut labore et dolore magna "
"aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco "
"laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor "
"in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla "
"pariatur.</p><p>Excepteur sint occaecat cupidatat non proident, sunt in "
"culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum "
"dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor "
"incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, "
"quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo "
"consequat. Duis aute irure dolor in reprehenderit in voluptate velit "
"esse cillum dolore eu fugiat nulla pariatur.</p>",
]
16 changes: 8 additions & 8 deletions src/collective/frontpage/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@

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

<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
83 changes: 78 additions & 5 deletions src/collective/frontpage/setuphandlers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# -*- coding: utf-8 -*-
from collective.frontpage import config
from plone import api
from Products.CMFPlone.interfaces import INonInstallable
from random import choice
from zope.component import getUtility
from zope.interface import implementer
from zope.schema.interfaces import IVocabularyFactory


@implementer(INonInstallable)
Expand All @@ -13,20 +17,89 @@ def getNonInstallableProfiles(self):

def post_install(context):
"""Post install script"""
# Do something at the end of the installation of this package.
pass


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


def testing(context):
"""post_handler for the collective.frontpage:testing profile"""
# Do something at the end of the testing installation of this package.
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):
"""Remove default pages"""
try:
default_pages = [
portal.get("news"),
portal.get("events"),
portal.get("Members"),
portal.get("front-page"),
]
api.content.delete(objects=default_pages)
except Exception:
pass


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 _create_sections(portal):
frontpage = portal.get("frontpage", None)
section_colors = getUtility(
IVocabularyFactory, "collective.frontpage.SectionColors"
)
voc_colors = section_colors(portal)
section_types = getUtility(IVocabularyFactory, "collective.frontpage.SectionTypes")
voc_types = section_types(portal)
if frontpage:
for i in range(1, 5):
num = "{0:0=2d}".format(i)
section = api.content.create(
type="Section",
container=frontpage,
id="section-{0}".format(num),
title=u"Section {0}".format(num),
description=choice(config.DUMMY_DESCRIPTIONS),
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")
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
2 changes: 1 addition & 1 deletion src/collective/frontpage/tests/test_ct_frontpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_ct_frontpage_factory(self):
def test_ct_frontpage_adding(self):
setRoles(self.portal, TEST_USER_ID, ["Contributor"])
obj = api.content.create(
container=self.portal, type="Frontpage", id="frontpage"
container=self.portal, type="Frontpage", id="test-frontpage"
)

self.assertTrue(
Expand Down
12 changes: 5 additions & 7 deletions src/collective/frontpage/tests/test_vocab_section_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ def test_vocab_section_types(self):
vocabulary = factory(self.portal)
self.assertTrue(IVocabularyTokenized.providedBy(vocabulary))

# VocabItem(u'welcome', _(u'Welcome Section')),
# VocabItem(u'teaser', _(u'Teaser Section')),
# VocabItem(u'static', _(u'Static Section')),
# VocabItem(u'news', _(u'News Section')),
# VocabItem(u'tiles', _(u'Tiles Section')),
# VocabItem(u'search', _(u'Search Section')),

self.assertEqual(vocabulary.getTerm(u"welcome").title, _(u"Welcome Section"))
self.assertEqual(vocabulary.getTerm(u"teaser").title, _(u"Teaser Section"))
self.assertEqual(vocabulary.getTerm(u"static").title, _(u"Static Section"))
self.assertEqual(vocabulary.getTerm(u"news").title, _(u"News Section"))
self.assertEqual(vocabulary.getTerm(u"tiles").title, _(u"Tiles Section"))
self.assertEqual(vocabulary.getTerm(u"search").title, _(u"Search Section"))
8 changes: 0 additions & 8 deletions src/collective/frontpage/vocabularies/section_types.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-

from collective.frontpage import _
from plone.dexterity.interfaces import IDexterityContent
from zope.globalrequest import getRequest
from zope.interface import implementer
from zope.schema.interfaces import IVocabularyFactory
from zope.schema.vocabulary import SimpleTerm
Expand All @@ -26,12 +24,6 @@ def __call__(self, context):
VocabItem(u"tiles", _(u"Tiles Section")),
VocabItem(u"search", _(u"Search Section")),
]
# Fix context if you are using the vocabulary in DataGridField.
# https://github.com/collective/
# collective.z3cform.datagridfield/issues/31
if not IDexterityContent.providedBy(context):
req = getRequest()
context = req.PARENTS[0]

# Create a list of SimpleTerm items:
terms = []
Expand Down

0 comments on commit 5782b74

Please sign in to comment.