From 8bcbb8ce2179915eee391e97141d662fade7b4d3 Mon Sep 17 00:00:00 2001 From: jonaspiterek Date: Thu, 9 Nov 2023 12:20:08 +0100 Subject: [PATCH] Add author content type --- .../src/collective_blog/content/author.py | 26 ++ .../src/collective_blog/content/blog_post.py | 21 +- .../src/collective_blog/permissions.zcml | 12 +- .../profiles/default/catalog.xml | 11 +- .../profiles/default/types.xml | 5 +- .../profiles/default/types/Author.xml | 98 ++++++ .../profiles/default/types/Blog_post.xml | 4 +- .../profiles/default/workflows.xml | 7 +- .../workflows/author_workflow/definition.xml | 284 ++++++++++++++++++ .../blog_post_workflow/definition.xml | 2 +- 10 files changed, 447 insertions(+), 23 deletions(-) create mode 100644 backend/src/collective_blog/src/collective_blog/content/author.py create mode 100644 backend/src/collective_blog/src/collective_blog/profiles/default/types/Author.xml create mode 100644 backend/src/collective_blog/src/collective_blog/profiles/default/workflows/author_workflow/definition.xml diff --git a/backend/src/collective_blog/src/collective_blog/content/author.py b/backend/src/collective_blog/src/collective_blog/content/author.py new file mode 100644 index 0000000..ed192e8 --- /dev/null +++ b/backend/src/collective_blog/src/collective_blog/content/author.py @@ -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.""" diff --git a/backend/src/collective_blog/src/collective_blog/content/blog_post.py b/backend/src/collective_blog/src/collective_blog/content/blog_post.py index ccc61e1..a9c0e58 100644 --- a/backend/src/collective_blog/src/collective_blog/content/blog_post.py +++ b/backend/src/collective_blog/src/collective_blog/content/blog_post.py @@ -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", @@ -45,4 +44,4 @@ class IBlogPost(Schema): @implementer(IBlogPost) class BlogPost(Container): - """A Blog post.""" \ No newline at end of file + """A Blog post.""" diff --git a/backend/src/collective_blog/src/collective_blog/permissions.zcml b/backend/src/collective_blog/src/collective_blog/permissions.zcml index d3ff788..bf43af8 100644 --- a/backend/src/collective_blog/src/collective_blog/permissions.zcml +++ b/backend/src/collective_blog/src/collective_blog/permissions.zcml @@ -7,10 +7,14 @@ - + + diff --git a/backend/src/collective_blog/src/collective_blog/profiles/default/catalog.xml b/backend/src/collective_blog/src/collective_blog/profiles/default/catalog.xml index 7dc04fd..061e9cc 100644 --- a/backend/src/collective_blog/src/collective_blog/profiles/default/catalog.xml +++ b/backend/src/collective_blog/src/collective_blog/profiles/default/catalog.xml @@ -10,7 +10,14 @@ - - + + + + + diff --git a/backend/src/collective_blog/src/collective_blog/profiles/default/types.xml b/backend/src/collective_blog/src/collective_blog/profiles/default/types.xml index d7605a7..0f728e8 100644 --- a/backend/src/collective_blog/src/collective_blog/profiles/default/types.xml +++ b/backend/src/collective_blog/src/collective_blog/profiles/default/types.xml @@ -7,7 +7,10 @@ name="MyType" /> --> - + diff --git a/backend/src/collective_blog/src/collective_blog/profiles/default/types/Author.xml b/backend/src/collective_blog/src/collective_blog/profiles/default/types/Author.xml new file mode 100644 index 0000000..9f675e6 --- /dev/null +++ b/backend/src/collective_blog/src/collective_blog/profiles/default/types/Author.xml @@ -0,0 +1,98 @@ + + + + + Author + + + False + Author + + + + + + True + True + + + cmf.AddPortalContent + collective_blog.content.author.Author + + + collective_blog.content.author.IAuthor + + + + + + + + + + + + + + + + + + + string:${folder_url}/++add++author + view + view + False + + + + + + + + + + + + + + + + + + + diff --git a/backend/src/collective_blog/src/collective_blog/profiles/default/types/Blog_post.xml b/backend/src/collective_blog/src/collective_blog/profiles/default/types/Blog_post.xml index 32a07a8..9078f84 100644 --- a/backend/src/collective_blog/src/collective_blog/profiles/default/types/Blog_post.xml +++ b/backend/src/collective_blog/src/collective_blog/profiles/default/types/Blog_post.xml @@ -35,7 +35,7 @@ purge="true" > - + @@ -95,4 +95,4 @@ - \ No newline at end of file + diff --git a/backend/src/collective_blog/src/collective_blog/profiles/default/workflows.xml b/backend/src/collective_blog/src/collective_blog/profiles/default/workflows.xml index 7019430..d484652 100644 --- a/backend/src/collective_blog/src/collective_blog/profiles/default/workflows.xml +++ b/backend/src/collective_blog/src/collective_blog/profiles/default/workflows.xml @@ -11,7 +11,10 @@ --> - + + + + - \ No newline at end of file + diff --git a/backend/src/collective_blog/src/collective_blog/profiles/default/workflows/author_workflow/definition.xml b/backend/src/collective_blog/src/collective_blog/profiles/default/workflows/author_workflow/definition.xml new file mode 100644 index 0000000..ee849b7 --- /dev/null +++ b/backend/src/collective_blog/src/collective_blog/profiles/default/workflows/author_workflow/definition.xml @@ -0,0 +1,284 @@ + + + + Access contents information + Modify portal content + View + + + + Waiting to be reviewed, not editable by the owner. + + + + + + Manager + Owner + Editor + Reader + Contributor + Reviewer + Site Administrator + + + Manager + Reviewer + Site Administrator + + + Manager + Owner + Editor + Reader + Contributor + Reviewer + Site Administrator + + + + + + Can only be seen and edited by the owner. + + + + + Manager + Owner + Editor + Reader + Contributor + Site Administrator + + + Manager + Owner + Editor + Site Administrator + + + Manager + Owner + Editor + Reader + Contributor + Site Administrator + + + + + Visible to everyone, editable by the owner. + + + + + Anonymous + + + Manager + Owner + Editor + Site Administrator + + + Anonymous + + + + + + Publishing the item makes it visible to other users. + + Approved + + Review portal content + + + + + Sending the item back will return the item to the original author instead of publishing it. You should preferably include a reason for why it was not published. + + Send back + + Review portal content + + + + + If you submitted the item by mistake or want to perform additional edits, this will take it back. + + Retract + + Request review + + + + + Puts your holiday in a review queue, so it can be approved by the reviewer. + + Submit for review + + Request review + + + + + Reviewer tasks + Pending (%(count)d) + + Review portal content + + + + + + Previous transition + + + transition/getId|nothing + + + + + + The ID of the user who performed the previous transition + + + user/getId + + + + + + Comment about the last transition + + + python:state_change.kwargs.get('comment', '') + + + + + + Provides access to workflow history + + + state_change/getHistory + + + Request review + Review portal content + + + + When the previous transition was performed + + + state_change/getDateTime + + + + + + diff --git a/backend/src/collective_blog/src/collective_blog/profiles/default/workflows/blog_post_workflow/definition.xml b/backend/src/collective_blog/src/collective_blog/profiles/default/workflows/blog_post_workflow/definition.xml index 3ae5d5d..249538a 100644 --- a/backend/src/collective_blog/src/collective_blog/profiles/default/workflows/blog_post_workflow/definition.xml +++ b/backend/src/collective_blog/src/collective_blog/profiles/default/workflows/blog_post_workflow/definition.xml @@ -281,4 +281,4 @@ - \ No newline at end of file +