Modify

Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#3341 closed enhancement (fixed)

Hidden posts

Reported by: Álvaro Iradier Owned by: osimons
Priority: normal Component: FullBlogPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

I'm missing a checkbox to make a post Invisible or hidden. Sometimes I'd like to hide a blog post until it's ready. For example, create a first draft, but make it hidden. Then attach some Images, add the images to the post, review it, etc., and finally make it visible when ready.

I guess this could be as simple as adding a hide this post checkbox (which I guess would require a new field in the database), or maybe just use some special title, like having the post title in brackets will make the post invisible.

Attachments (1)

full_blog_drafts.diff (7.5 KB) - added by Álvaro Iradier 16 years ago.
Patch to make posts invisible except for owner when in draft category

Download all attachments as: .zip

Change History (14)

comment:1 Changed 16 years ago by osimons

In addition to the various listings and view possibilities, you would also need to make sure that the post (and the various versions and possibly existing comments) did not show up in timeline, search and similar. Permissions would also need to be considered - editable only by you, or ability to review by others? You'd also need to work out what happens when it gets 'Published' - do we then list all versions in the Timeline, or somehow remove them to only keep the latest version?

Originally, I did have an idea to make it possible to 'Publish' and possibly also 'Unpublish' a given blog post. However, I concluded that:

  1. It adds heaps of complexity,
  2. It is a feature that makes the blog tool more advanced than I originally planned as a project news tool,
  3. And, lastly: It is not the Trac way - you can preview like other modules, but like wiki, ticket and so on there is never a 'save draft' feature. Keep it simple...

So, I would personally hesitate to put this support into the various levels of the code base as so many factors can easily make it unmanageable.

Instead, could you perhaps investigate alternative ways of achieving that functionality? The one thing that springs to mind is making a separate permission policy plugin. All blog resources check for permission for any kind of listing, display and action. What if you permission policy checked for 'draft' as a category, and if so denied access for all except for owner + perhaps BLOG_ADMIN. Make a final edit to remove the 'draft' category, and the post becomes readable by everyone with BLOG_VIEW permissions.

I'd be happy to review and help make such a plugin, it would be a nice addition to the 'sample-plugins' directory. It should be no more than 10 lines of Python code + some docs on how to add and configure it.

comment:2 Changed 16 years ago by Álvaro Iradier

Ok, so I didn't find out how to make it work with the permissions policy plugin, but I'm attaching a patch that works for me. Adding a post to draft category will make it invisible for listing and viewing, as well as invisible in timeline, for all users except for the owner.

Changed 16 years ago by Álvaro Iradier

Attachment: full_blog_drafts.diff added

Patch to make posts invisible except for owner when in draft category

comment:3 Changed 16 years ago by osimons

As I said, I won't be making changes in the core functionality that keeps checking all kinds of 'draft' circumstances. And, something as low-level as the entities representing the posts in the database should not need to be aware of such user-oriented features. That said, I do appreciate your efforts with making your patch - getting familiar with the code, and making efforts to improve the plugin. I do hope you can provide further patches in the future!

Anyway, I sat down and wrote the plugin I had in mind. It ended up as slightly more than 10 lines - but then it also added some extra checking to make sure drafts don't run astray. Still, it is mostly just docs :-)

Please review the plugin added in [3999]. It should be simple to tweak it if needed.

comment:4 Changed 16 years ago by Álvaro Iradier

Thanks!

I didn't mean you to include my patch in the core, I just attached it as it worked for us, and maybe it could be useful for someone. Your plugin looks better, however, so thanks very much for your quick response and support!

comment:5 Changed 16 years ago by Álvaro Iradier

Ok, trying the plugin I still find some problems, and I guess they require changes in the core.

First, draft posts are not shown in latest posts, but they are still in the archive listing. I think BLOG_VIEW permission is not being checked for these, and I suggest this change:

        elif command == 'archive':
            # Requesting the archive page
            template = 'fullblog_archive.html'


            # BEGIN OLD
            # -----------------------
            # data['blog_archive'] = group_posts_by_month(get_blog_posts(self.env))
            # -----------------------
            # END OLD

            # BEGIN NEW
            # -----------------------
            data['blog_post_list'] = []
            blog_posts = group_posts_by_month(get_blog_posts(self.env))
            for post in blog_posts:
                bp = BlogPost(self.env, post[0], post[1])
                if 'BLOG_VIEW' in req.perm(bp.resource):
                    data['blog_post_list'].append(bp)
            # -----------------------
            # END NEW

            add_link(req, 'alternate', req.href.blog(format='rss'), 'RSS Feed',
                     'application/rss+xml', 'rss')

Finally, post count on the sidebar counts draft posts even when it shouldn't (and Draft category is shown). Should BLOG_VIEW permission be checked in get_months_authors_categories in model.py too?

Thanks for your time.

comment:6 Changed 16 years ago by osimons

(In [4002]) FullBlogPlugin: Permission fixes for when using fine-grained permission (such as the Draft sample plugin).

  • The archive listing did not check for fine-grained permissions at all. Now it does.
  • The sidebar content (periods, categories, categories - with totals) are now correctly filtered for permissions. Moved the method from 'model' to 'core' as it did not involve the database directly, was not really needed by any other model code, and any code involving perm and users should not be entangled with database code.

References #3341. Thanks to airadier for reporting and suggesting fixes.

comment:7 Changed 16 years ago by osimons

As you can see, I've made the permission fixes. Please test and report back.

Personally I think this turned out to be a very useful plugin. Thanks for suggestion and problem reports :-)

comment:8 Changed 16 years ago by Álvaro Iradier

Works perfect as far as I've tried. Thanks very much, now FullBlog is perfect for me.

comment:9 in reply to:  8 Changed 16 years ago by osimons

Resolution: fixed
Status: newclosed

Replying to airadier:

Works perfect as far as I've tried.

And on that note... Closing as fixed.

comment:10 Changed 16 years ago by osimons

#3375 closed as duplicate.

comment:11 Changed 16 years ago by osimons

#4551 closed as duplicate.

comment:12 Changed 15 years ago by osimons

5619 closed as duplicate.

comment:13 Changed 15 years ago by osimons

#5619 that is...

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain osimons.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.