Blog and "Login required"

216 views
Skip to first unread message

S2w

unread,
Apr 7, 2012, 5:35:22 PM4/7/12
to Mezzanine Users
Hello,
I'm just starting to use Mezzanine and I cannot make the following
Blog admin checkbox work:
Login required
If checked, only logged in users can view this page

When it's checked, not logged users can still see the page (I changed
ACCOUNTS_ENABLED to True).

Also, how can I create more than one blog? (in the admin/Content/Pages
this is the only entry that can not be removed or added).

I need to have different blogs for different kinds of users without
having to manage different sites.

Cheers,
Stephane.

Stephen McDonald

unread,
Apr 8, 2012, 3:59:25 AM4/8/12
to mezzani...@googlegroups.com
Firstly, the blog application is a modelled as a single blog with multiple authors. So the main blog listing page will show all posts for the blog, but there are views/urls/tags included for listing authors and filtering by them - depending on your needs this might work well for you.

As for the blog's page in the navigation not honouring the "login required" checkbox, this was an oversight in as much as the blog page isn't handled like a regular page in Mezzanine, it's just there to support having the blog display in the site's navigation. I've fixed this in the commit linked below and fleshed out handling for this type of situation a bit more.


I've added mezzanine.pages.decorators.for_page - this is a decorator for any views (like the blog list and blog detail) that are implemented as regular Django apps, but map to a page in Mezzanine's page tree. It handles the redirect for login_required field on the page, and more importantly it loads the page instance and puts it into the template context. This makes the special loading of the blog page instance inside the blog views redundant, so I've removed that and applied the decorator. This is really good in that it provides a general purpose way of doing this, which I think has come up as an issue dozens of times on the list before. 

This has also allowed for expanding the docs a bit more in the "Content Architecture" section. This is where the main documentation of how pages work in Mezzanine has always been, but it's always included this little dangling section at the end that talks about the Displayable model, with the idea of documenting how things can work without using pages, but it never really provided any context around how and why to use it. So I've changed that part to be called "Non-page Content", and documented the Displayable model and the for_page decorator, which hopefully will provide a more complete picture of how you go about integrating regular Django apps and their views with the navigation tree.

Haven't pushed a release for this - it'll be part of 1.1 which is probably a week or two away.

--
Stephen McDonald
http://jupo.org

Stephen McDonald

unread,
Apr 8, 2012, 4:01:34 AM4/8/12
to mezzani...@googlegroups.com
Also I forgot to mention - the blog feeds now also honour the login_required field on the blog page, so if it's True, it means the blog feeds are always empty.

Somewhere down the track we can probably extend this so that the actual URLs to the feeds in this case, include a token for the logged in user, which can be used for authenticated feeds.

S2w

unread,
Apr 8, 2012, 12:54:57 PM4/8/12
to Mezzanine Users
Hi Stephen,

Thank you for the quick and comprehensive reply.

I thought I could achieve some kind of multi-tenancy using access-
control (one deployment, several sets of users accessing siloed
information) but this is more complex than that.

I need to explore the subject a bit more and will certainly come back
with more questions.

Best regards,
Stephane.

Reply all
Reply to author
Forward
0 new messages