Repository: collective/collective.blog (language: python)

Issue:
Blog / Blog Post / Blog Author
@ericof @jonaspiterek I am skeptical about the "Blog" content object. For DLR/FZJ we will use a subsite or even a dedicated Plone instance for the blog. Therefore we just can not have a "Blog" content object that allows "post" and "author" to be added to this container. It could be an interface that we add to our "Subsite" content object or even "INavigationRoot". However, this is our main use case and needs to be taken into account here.

We also agreed with @davisagli that the right title for a blog post is "Blog Post" and we agreed to use "Blog Author". Please check the specs in our Trello card.


Discussion / hints:
My advice:
1. Create a "blog" behavior
2. Include a Blog content type in collective.blog which has that behavior enabled.
3. If a specific project has different needs, it can disable the Blog content type in its profile.
I agree with the Blog behavior approach and disabling the Blog content type in specific projects.
About the names, I would suggest we meet Author and Post as the content type names, but change it to Blog Author and Blog Post in the translations. This way we solve the UX problem but keep the filenames and fti shorter.
This issue will cover only the 'titles' of the content types. The #20 will take care of the blog behavior
@davisagli @ericof when you say "Blog Behavior", do you mean the existing "IBlog" interface? The only advantage of a behavior is that we can enable/disable it TTW.

Fix patch:
diff --git a/src/collective/blog/locales/collective.blog.pot b/src/collective/blog/locales/collective.blog.pot
index aa3db38..9f70b1a 100644
--- a/src/collective/blog/locales/collective.blog.pot
+++ b/src/collective/blog/locales/collective.blog.pot
@@ -17,6 +17,10 @@ msgstr ""
 "Preferred-Encodings: utf-8 latin1\n"
 "Domain: collective.blog\n"
 
+#: collective/blog/profiles/default/types/Author.xml
+msgid "A Blog Author"
+msgstr ""
+
 #: collective/blog/profiles/default/types/Post.xml
 msgid "A Blog Post"
 msgstr ""
@@ -25,16 +29,16 @@ msgstr ""
 msgid "A folderish content item representing a Blog"
 msgstr ""
 
-#: collective/blog/profiles/default/types/Author.xml
-msgid "An Author"
+#: collective/blog/profiles/default/types/Blog.xml
+msgid "Blog"
 msgstr ""
 
 #: collective/blog/profiles/default/types/Author.xml
-msgid "Author"
+msgid "Blog Author"
 msgstr ""
 
-#: collective/blog/profiles/default/types/Blog.xml
-msgid "Blog"
+#: collective/blog/profiles/default/types/Post.xml
+msgid "Blog Post"
 msgstr ""
 
 #: collective/blog/behaviors/configure.zcml:13
@@ -63,10 +67,6 @@ msgstr ""
 msgid "Package to configure Blog content types"
 msgstr ""
 
-#: collective/blog/profiles/default/types/Post.xml
-msgid "Post"
-msgstr ""
-
 #: collective/blog/profiles.zcml:21
 msgid "Uninstall Blog setup."
 msgstr ""
diff --git a/src/collective/blog/locales/de/LC_MESSAGES/collective.blog.po b/src/collective/blog/locales/de/LC_MESSAGES/collective.blog.po
index 6e84241..1e2ed51 100644
--- a/src/collective/blog/locales/de/LC_MESSAGES/collective.blog.po
+++ b/src/collective/blog/locales/de/LC_MESSAGES/collective.blog.po
@@ -14,6 +14,10 @@ msgstr ""
 "Preferred-Encodings: utf-8 latin1\n"
 "Domain: DOMAIN\n"
 
+#: collective/blog/profiles/default/types/Author.xml
+msgid "A Blog Author"
+msgstr ""
+
 #: collective/blog/profiles/default/types/Post.xml
 msgid "A Blog Post"
 msgstr ""
@@ -22,16 +26,16 @@ msgstr ""
 msgid "A folderish content item representing a Blog"
 msgstr ""
 
-#: collective/blog/profiles/default/types/Author.xml
-msgid "An Author"
+#: collective/blog/profiles/default/types/Blog.xml
+msgid "Blog"
 msgstr ""
 
 #: collective/blog/profiles/default/types/Author.xml
-msgid "Author"
+msgid "Blog Author"
 msgstr ""
 
-#: collective/blog/profiles/default/types/Blog.xml
-msgid "Blog"
+#: collective/blog/profiles/default/types/Post.xml
+msgid "Blog Post"
 msgstr ""
 
 #: collective/blog/behaviors/configure.zcml:13
@@ -60,10 +64,6 @@ msgstr ""
 msgid "Package to configure Blog content types"
 msgstr ""
 
-#: collective/blog/profiles/default/types/Post.xml
-msgid "Post"
-msgstr ""
-
 #: collective/blog/profiles.zcml:21
 msgid "Uninstall Blog setup."
 msgstr ""
diff --git a/src/collective/blog/locales/en/LC_MESSAGES/collective.blog.po b/src/collective/blog/locales/en/LC_MESSAGES/collective.blog.po
index 89acc6d..5e8e170 100644
--- a/src/collective/blog/locales/en/LC_MESSAGES/collective.blog.po
+++ b/src/collective/blog/locales/en/LC_MESSAGES/collective.blog.po
@@ -14,6 +14,10 @@ msgstr ""
 "Preferred-Encodings: utf-8 latin1\n"
 "Domain: collective.blog\n"
 
+#: collective/blog/profiles/default/types/Author.xml
+msgid "A Blog Author"
+msgstr ""
+
 #: collective/blog/profiles/default/types/Post.xml
 msgid "A Blog Post"
 msgstr ""
@@ -22,16 +26,16 @@ msgstr ""
 msgid "A folderish content item representing a Blog"
 msgstr ""
 
-#: collective/blog/profiles/default/types/Author.xml
-msgid "An Author"
+#: collective/blog/profiles/default/types/Blog.xml
+msgid "Blog"
 msgstr ""
 
 #: collective/blog/profiles/default/types/Author.xml
-msgid "Author"
+msgid "Blog Author"
 msgstr ""
 
-#: collective/blog/profiles/default/types/Blog.xml
-msgid "Blog"
+#: collective/blog/profiles/default/types/Post.xml
+msgid "Blog Post"
 msgstr ""
 
 #: collective/blog/behaviors/configure.zcml:13
@@ -60,10 +64,6 @@ msgstr ""
 msgid "Package to configure Blog content types"
 msgstr ""
 
-#: collective/blog/profiles/default/types/Post.xml
-msgid "Post"
-msgstr ""
-
 #: collective/blog/profiles.zcml:21
 msgid "Uninstall Blog setup."
 msgstr ""
diff --git a/src/collective/blog/locales/es/LC_MESSAGES/collective.blog.po b/src/collective/blog/locales/es/LC_MESSAGES/collective.blog.po
index 6e84241..1e2ed51 100644
--- a/src/collective/blog/locales/es/LC_MESSAGES/collective.blog.po
+++ b/src/collective/blog/locales/es/LC_MESSAGES/collective.blog.po
@@ -14,6 +14,10 @@ msgstr ""
 "Preferred-Encodings: utf-8 latin1\n"
 "Domain: DOMAIN\n"
 
+#: collective/blog/profiles/default/types/Author.xml
+msgid "A Blog Author"
+msgstr ""
+
 #: collective/blog/profiles/default/types/Post.xml
 msgid "A Blog Post"
 msgstr ""
@@ -22,16 +26,16 @@ msgstr ""
 msgid "A folderish content item representing a Blog"
 msgstr ""
 
-#: collective/blog/profiles/default/types/Author.xml
-msgid "An Author"
+#: collective/blog/profiles/default/types/Blog.xml
+msgid "Blog"
 msgstr ""
 
 #: collective/blog/profiles/default/types/Author.xml
-msgid "Author"
+msgid "Blog Author"
 msgstr ""
 
-#: collective/blog/profiles/default/types/Blog.xml
-msgid "Blog"
+#: collective/blog/profiles/default/types/Post.xml
+msgid "Blog Post"
 msgstr ""
 
 #: collective/blog/behaviors/configure.zcml:13
@@ -60,10 +64,6 @@ msgstr ""
 msgid "Package to configure Blog content types"
 msgstr ""
 
-#: collective/blog/profiles/default/types/Post.xml
-msgid "Post"
-msgstr ""
-
 #: collective/blog/profiles.zcml:21
 msgid "Uninstall Blog setup."
 msgstr ""
diff --git a/src/collective/blog/locales/pt_BR/LC_MESSAGES/collective.blog.po b/src/collective/blog/locales/pt_BR/LC_MESSAGES/collective.blog.po
index ee0ec17..a802697 100644
--- a/src/collective/blog/locales/pt_BR/LC_MESSAGES/collective.blog.po
+++ b/src/collective/blog/locales/pt_BR/LC_MESSAGES/collective.blog.po
@@ -14,6 +14,10 @@ msgstr ""
 "Preferred-Encodings: utf-8 latin1\n"
 "Domain: DOMAIN\n"
 
+#: collective/blog/profiles/default/types/Author.xml
+msgid "A Blog Author"
+msgstr ""
+
 #: collective/blog/profiles/default/types/Post.xml
 msgid "A Blog Post"
 msgstr "Uma postagem no blog"
@@ -22,18 +26,17 @@ msgstr "Uma postagem no blog"
 msgid "A folderish content item representing a Blog"
 msgstr "Um tipo de conteúdo que representa um Blog"
 
-#: collective/blog/profiles/default/types/Author.xml
-msgid "An Author"
-msgstr "Um autor"
-
-#: collective/blog/profiles/default/types/Author.xml
-msgid "Author"
-msgstr "Autor"
-
 #: collective/blog/profiles/default/types/Blog.xml
 msgid "Blog"
 msgstr "Blog"
 
+#: collective/blog/profiles/default/types/Author.xml
+msgid "Blog Author"
+msgstr ""
+
+#: collective/blog/profiles/default/types/Post.xml
+msgid "Blog Post"
+
 #: collective/blog/behaviors/configure.zcml:13
 msgid "Blog Behavior"
 msgstr ""
@@ -60,10 +63,6 @@ msgstr ""
 msgid "Package to configure Blog content types"
 msgstr "Pacote que configura tipos de conteúdo para blogs"
 
-#: collective/blog/profiles/default/types/Post.xml
-msgid "Post"
-msgstr "Postagem"
-
 #: collective/blog/profiles.zcml:21
 msgid "Uninstall Blog setup."
 msgstr ""
diff --git a/src/collective/blog/profiles/default/types/Author.xml b/src/collective/blog/profiles/default/types/Author.xml
index c125450..73073b6 100644
--- a/src/collective/blog/profiles/default/types/Author.xml
+++ b/src/collective/blog/profiles/default/types/Author.xml
@@ -1,17 +1,17 @@
 <?xml version="1.0" encoding="utf-8"?>
 <object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
         meta_type="Dexterity FTI"
-        name="Case Study"
+        name="Blog Author"
         i18n:domain="collective.blog"
 >
 
   <!-- Basic properties -->
   <property name="title"
             i18n:translate=""
-  >Author</property>
+  >Blog Author</property>
   <property name="description"
             i18n:translate=""
-  >An Author</property>
+  >A Blog Author</property>
 
   <property name="allow_discussion">False</property>
   <property name="factory">Author</property>
@@ -21,7 +21,7 @@
   <!-- Hierarchy control -->
   <property name="allowed_content_types" />
   <property name="filter_content_types">False</property>
-  <property name="global_allow">True</property>
+  <property name="global_allow">False</property>
 
   <!-- Schema, class and security -->
   <property name="add_permission">cmf.AddPortalContent</property>
diff --git a/src/collective/blog/profiles/default/types/Blog.xml b/src/collective/blog/profiles/default/types/Blog.xml
index 5284d76..f93e385 100644
--- a/src/collective/blog/profiles/default/types/Blog.xml
+++ b/src/collective/blog/profiles/default/types/Blog.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
         meta_type="Dexterity FTI"
-        name="Case Study"
+        name="Blog"
         i18n:domain="collective.blog"
 >
 
diff --git a/src/collective/blog/profiles/default/types/Post.xml b/src/collective/blog/profiles/default/types/Post.xml
index 2edd075..edc684e 100644
--- a/src/collective/blog/profiles/default/types/Post.xml
+++ b/src/collective/blog/profiles/default/types/Post.xml
@@ -1,14 +1,14 @@
 <?xml version="1.0" encoding="utf-8"?>
 <object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
         meta_type="Dexterity FTI"
-        name="Case Study"
+        name="Blog Post"
         i18n:domain="collective.blog"
 >
 
   <!-- Basic properties -->
   <property name="title"
             i18n:translate=""
-  >Post</property>
+  >Blog Post</property>
   <property name="description"
             i18n:translate=""
   >A Blog Post</property>


Test patch:
diff --git a/tests/conftest.py b/tests/conftest.py
index 8ba9dbe..8ab4227 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -21,25 +21,6 @@
 )
 
 
-@pytest.fixture
-def authors_payload() -> list:
-    """Payload to create two author items."""
-    return [
-        {
-            "type": "Author",
-            "id": "douglas-adams",
-            "title": "Douglas Adams",
-            "description": "A very good writer",
-        },
-        {
-            "type": "Author",
-            "id": "marvin",
-            "title": "Marvin",
-            "description": "A very good nice robot",
-        },
-    ]
-
-
 @pytest.fixture
 def blogs_payload() -> list:
     """Payload to create two blogs items."""
@@ -59,6 +40,25 @@ def blogs_payload() -> list:
     ]
 
 
+@pytest.fixture
+def authors_payload() -> list:
+    """Payload to create two author items."""
+    return [
+        {
+            "type": "Author",
+            "id": "douglas-adams",
+            "title": "Douglas Adams",
+            "description": "A very good writer",
+        },
+        {
+            "type": "Author",
+            "id": "marvin",
+            "title": "Marvin",
+            "description": "A very good nice robot",
+        },
+    ]
+
+
 @pytest.fixture
 def posts_payload() -> list:
     """Payload to create two posts items."""
@@ -79,23 +79,25 @@ def posts_payload() -> list:
 
 
 @pytest.fixture
-def authors(portal, authors_payload) -> dict:
-    """Create Authors content items."""
+def blogs(portal, blogs_payload) -> dict:
+    """Create Blogs content items."""
     response = {}
     with api.env.adopt_roles(["Manager"]):
-        for data in authors_payload:
+        for data in blogs_payload:
             content = api.content.create(container=portal, **data)
             response[content.UID()] = content.title
     return response
 
 
 @pytest.fixture
-def blogs(portal, blogs_payload) -> dict:
-    """Create Blogs content items."""
+def authors(blogs, authors_payload) -> dict:
+    """Create Authors content items."""
     response = {}
+    blog_uuid = list(blogs.keys())
     with api.env.adopt_roles(["Manager"]):
-        for data in blogs_payload:
-            content = api.content.create(container=portal, **data)
+        blog = api.content.get(UID=blog_uuid[0])
+        for data in authors_payload:
+            content = api.content.create(container=blog, **data)
             response[content.UID()] = content.title
     return response
 
@@ -107,7 +109,7 @@ def posts(portal, authors, blogs, posts_payload) -> dict:
     authors_uuid = list(authors.keys())
     blog_uuid = list(blogs.keys())
     with api.env.adopt_roles(["Manager"]):
-        blog = api.content.get(uuid=blog_uuid[0])
+        blog = api.content.get(UID=blog_uuid[0])
         for data in posts_payload:
             # Add one author
             data["creators"] = [authors_uuid[0]]
diff --git a/tests/content/test_author.py b/tests/content/test_author.py
index ea171a6..b5ff3dc 100644
--- a/tests/content/test_author.py
+++ b/tests/content/test_author.py
@@ -11,8 +11,10 @@
 
 class TestAuthor:
     @pytest.fixture(autouse=True)
-    def _fti(self, get_fti, integration):
+    def _fti(self, get_fti, portal, blogs_payload):
         self.fti = get_fti(CONTENT_TYPE)
+        with api.env.adopt_roles(["Manager"]):
+            self.blog = api.content.create(container=portal, **blogs_payload[0])
 
     def test_fti(self):
         assert isinstance(self.fti, DexterityFTI)
@@ -42,8 +44,10 @@ def test_has_behavior(self, get_behaviors, behavior):
         assert behavior in get_behaviors(CONTENT_TYPE)
 
     def test_create(self, portal, authors_payload):
+        """A Blog Author need to be created inside a Blog."""
+        blog = self.blog
         payload = authors_payload[0]
         with api.env.adopt_roles(["Manager"]):
-            content = api.content.create(container=portal, **payload)
+            content = api.content.create(container=blog, **payload)
         assert content.portal_type == CONTENT_TYPE
         assert isinstance(content, Author)