Skip to content

Commit

Permalink
Add author content type
Browse files Browse the repository at this point in the history
  • Loading branch information
jnptk committed Nov 9, 2023
1 parent dfb2f8c commit 8bcbb8c
Show file tree
Hide file tree
Showing 10 changed files with 447 additions and 23 deletions.
26 changes: 26 additions & 0 deletions backend/src/collective_blog/src/collective_blog/content/author.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from collective_blog import _
from plone.dexterity.content import Container
from plone.supermodel.model import Schema
from zope import schema
from zope.interface import implementer


class IAuthor(Schema):
"""An author."""

title = schema.TextLine(
title=_("Name"),
description=_("Name of the author"),
required=True,
)

description = schema.TextLine(
title=_("Description"),
description=_("About the author"),
required=False,
)


@implementer(IAuthor)
class Author(Container):
"""An author."""
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
from collective_blog import _
from plone.autoform import directives
from plone.dexterity.content import Container
from plone.supermodel.model import Schema
from zope import schema
from zope.interface import implementer

from z3c.relationfield.schema import RelationChoice
from z3c.relationfield.schema import RelationList
from plone.autoform import directives
from zope import schema
from zope.interface import implementer


class IBlogPost(Schema):
"""A Blog post."""

title = schema.TextLine(
title=_('Title'),
description=_('Blog post title'),
title=_("Title"),
description=_("Blog post title"),
required=True,
)

description = schema.TextLine(
title=_('Description'),
description=_('Blog post description'),
title=_("Description"),
description=_("Blog post description"),
required=False,
)

authors = RelationList(
title=_('Authors'),
description=_('Blog post authors'),
title=_("Authors"),
description=_("Blog post authors"),
required=False,
value_type=RelationChoice(
vocabulary="plone.app.vocabularies.Catalog",
Expand All @@ -45,4 +44,4 @@ class IBlogPost(Schema):

@implementer(IBlogPost)
class BlogPost(Container):
"""A Blog post."""
"""A Blog post."""
12 changes: 8 additions & 4 deletions backend/src/collective_blog/src/collective_blog/permissions.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
<configure zcml:condition="installed AccessControl.security">
<!-- -*- extra stuff goes here -*- -->

<permission
id="kitconcept_blog.blog_post.add"
title="kitconcept_blog: Add Blog post"
/>
<permission
id="kitconcept_blog.blog_post.add"
title="kitconcept_blog: Add Blog post"
/>
<permission
id="kitconcept_blog.author.add"
title="kitconcept_blog: Add Author"
/>

</configure>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
<!-- Metadata
<column value="industry" />
-->
<index meta_type="FieldIndex" name="Blog post">
<indexed_attr value="Blog post"/>
<index meta_type="FieldIndex"
name="Blog post"
>
<indexed_attr value="Blog post" />
</index>
<index meta_type="FieldIndex"
name="Author"
>
<indexed_attr value="Author" />
</index>
</object>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
name="MyType"
/>
-->
<object meta_type="Dexterity FTI"
<object meta_type="Dexterity FTI"
name="Blog post"
/>
<object meta_type="Dexterity FTI"
name="Author"
/>
</object>
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
meta_type="Dexterity FTI"
name="Author"
i18n:domain="collective_blog"
>

<!-- Basic properties -->
<property name="title"
i18n:translate=""
>Author</property>
<property name="description"
i18n:translate=""
/>

<property name="allow_discussion">False</property>
<property name="factory">Author</property>
<property name="icon_expr" />
<property name="link_target" />

<!-- Hierarchy control -->
<property name="allowed_content_types" />
<property name="filter_content_types">True</property>
<property name="global_allow">True</property>

<!-- Schema, class and security -->
<property name="add_permission">cmf.AddPortalContent</property>
<property name="klass">collective_blog.content.author.Author</property>
<property name="model_file" />
<property name="model_source" />
<property name="schema">collective_blog.content.author.IAuthor</property>

<!-- Enabled behaviors -->
<property name="behaviors"
purge="true"
>
<element value="volto.blocks" />
<element value="volto.preview_image" />
<element value="plone.namefromtitle" />
<element value="plone.allowdiscussion" />
<element value="plone.excludefromnavigation" />
<element value="plone.shortname" />
<element value="plone.dublincore" />
<element value="plone.richtext" />
<element value="plone.relateditems" />
<element value="plone.versioning" />
<element value="plone.tableofcontents" />
<element value="plone.locking" />
</property>

<!-- View information -->
<property name="add_view_expr">string:${folder_url}/++add++author</property>
<property name="immediate_view">view</property>
<property name="default_view">view</property>
<property name="default_view_fallback">False</property>
<property name="view_methods">
<element value="view" />
</property>

<!-- Method aliases -->
<alias from="(Default)"
to="(dynamic view)"
/>
<alias from="edit"
to="@@edit"
/>
<alias from="sharing"
to="@@sharing"
/>
<alias from="view"
to="(selected layout)"
/>

<!-- Actions -->
<action action_id="view"
category="object"
condition_expr=""
description=""
title="View"
url_expr="string:${object_url}"
visible="True"
i18n:attributes="title"
>
<permission value="View" />
</action>
<action action_id="edit"
category="object"
condition_expr=""
description=""
title="Edit"
url_expr="string:${object_url}/edit"
visible="True"
i18n:attributes="title"
>
<permission value="Modify portal content" />
</action>

</object>
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
purge="true"
>
<element value="volto.blocks" />
<element value="volto.preview_image"/>
<element value="volto.preview_image" />
<element value="plone.namefromtitle" />
<element value="plone.allowdiscussion" />
<element value="plone.excludefromnavigation" />
Expand Down Expand Up @@ -95,4 +95,4 @@
<permission value="Modify portal content" />
</action>

</object>
</object>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
<bound-workflow workflow_id="workflow_id" />
</default> -->
<type type_id="Blog post">
<bound-workflow workflow_id="blog_post_workflow"/>
<bound-workflow workflow_id="blog_post_workflow" />
</type>
<type type_id="Author">
<bound-workflow workflow_id="author_workflow" />
</type>
</bindings>
</object>
</object>
Loading

0 comments on commit 8bcbb8c

Please sign in to comment.