Django-cms and Editorial workflows - python

I need to implement workflows in my Django-CMS application at work. But form the Django-CMS feature list, we can read:
Editorial workflow
Workflows for publishing and approval.
I tried to search for it and didn't find anything. I've search the Django-CMS documentation (http://docs.django-cms.org/en/latest/index.html) and couldn't find something there either.
Does anyone has a clue about Workflows in Django-CMS (especially for the pages system) ?

An update for 2016:
No Editorial Workflow in django CMS 3 (yet)
django CMS 3 (v3.3.2 as of today) has no editorial workflow. This feature was removed in version 2.3, and replaced by the concept of "simple publishing" (2 versions of content: draft, public). Read the related blog post from Divio for their motivation.
For version 3.5 there is some extended moderation support planned via an addon, as explained by Angelo Dini in a current comment on the original blog post from 2012. Don't bet on it, though.
Control over Editing
If what you want is, at least, some control over editing, e.g. "some users are allowed to create and edit only but can't publish changes", then you're in luck. It works as follows:
Control over editing goes with the following formula, it's a combination of 3 things:
"Staff" status + App permissions + CMS permissions
The first two are plain Django concepts (from django.contrib.auth, see the Django docs) and the latter comes from django CMS. All 3 play together, here's why:
Without "Staff" status no editing is allowed at all, no CMS toolbar for front-end editing is shown either. Note that this status cannot be set on a group, it must be set on individual users. (d'oh!)
Without all app permissions (cms, djangocms-, cmsplugin-, zinnia) assigned to the group (or user directly) there is no editing; the CMS toolbar will be shown and you can typically double-click on content to initiate editing, but django CMS will tell you that you have no permission.
Omitting some of the CMS permissions (e.g. create, publish) disables the buttons on the CMS toolbar. That's about it. There is no message instructing the user what to do or explanation about what is happening (acknowledged, it's difficult to provide a generic solution here), neither are emails or other notifications sent (of course, there is no such thing as an editorial workflow).
IOW, it's possible to split your users into groups and allow them to do just some specific things (editing only, publishing only, etc.), but the user notifications, a central concept to workflow implementions, are not available in django CMS v3.3.
EDIT: See "Editorial workflow for django CMS" in the django CMS developers G+ group for details and a demo of a related implementation.

When you turn on CMS_MODERATION in Django-CMS, you will get three icons next to each page in the page list view. From left to right, these control
whether changes to this page will require moderator approval
whether changes to this page's children will require moderator approval
whether changes to this page's descendents will require moderator approval
When you create or change a page, you will be able to save it, and preview the page or new version of the page on your site, but it will require moderator approval before the page or new version of the page is visible to end users.

Related

Django: other options than models.TextField() for articles

So in the Django tutorials we make a sparse polls application that shows off some of what Django can do, but leaves a lot to be desired when it comes to learning Django (e.g. using their UserCreationForm to make a user portal).
In part of the tutorial they talk about how the admin should be publishing content (e.g. if it were a blog or newspaper) and we set up the admin site where one can make new questions for the polls.
In regard to the blog idea - since an article would be lengthy most likely - I think the correct model would include models.TextField. However, looking at Django's naturally generated admin site for adding / modifying new models with a TextField leaves a lot to be desired.
What if there should be images embedded among the text? or what if there should be formatted text? The admin site does not support a user friendly way to do this.
My question is how to produce a user friendly way for making mixed media e.g. a Stack Exchange post which might have images, code formatting, text formats, etc.
You could use Django Pagedown which aims exactly to offer a way of editing similar to that found on stackexchange sites. As for now you cannot yet upload images (this feature is though on the todos list of the author), they must be already uploaded somewhere on the web and you can insert them using their url.

How to modify wagtail CMS so that any user can post blog posts under their own blog

I have an existing website that is a Django App.
I have installed Wagtail, and the Wagtail CMS is now accessible at www.example.com/cms. Wagtail is working correctly with my database, and all the existing users are visible when I go to settings and then users, in the wagtail CMS admin page.
I want to use Wagtail to add blog functionality to my website.
Requirements
I want any user to be able to create a new blog and add posts to their blog.
I want the blog created by a user to be visible at www.example.com/blogs/username/
How can I set Wagtail up to accomplish this?
I have checked the documentation at http://docs.wagtail.io/en/v1.9/ but could not figure out where to start with my modifications. I have also installed the example blog project (https://github.com/wagtail/wagtaildemo) but I was also unable to figure out how to accomplish 1 and 2 above from this.
Any complete answers, or general pointers, very welcome.
The permission model built into Wagtail supports this kind of setup: http://docs.wagtail.io/en/stable/topics/permissions.html
After creating the index page for a blog, you'd create a group (Settings -> Groups in the Wagtail admin) for that blog - possibly just containing a single user - and under the 'Page permissions' section, assign it 'add' and 'publish' permission on that index page. Permissions propagate down the tree from that point, and 'add' permission encompasses the ability to edit pages that you've created yourself, so this would have the effect of giving the user control over the subpages of their blog.
This doesn't quite match the setup you've described, since it involves an existing Wagtail admin user having to do the initial setup, rather than users creating their own blog. However, since all of this configuration is done internally by creating / updating standard Django models such as Group and PagePermission, it would be possible in principle to script this process - for example, you could implement a Django view for "Set up my blog" on your site front-end, which runs the following steps:
Create a BlogIndexPage under /blogs with a title/slug matching request.user.username (see https://stackoverflow.com/a/43041179/1853523 for how to create pages programmatically)
Create a user group (django.contrib.auth.models.Group) for the current user, and assign them wagtailadmin.access_admin permission (so that they can log in to Wagtail admin)
Create a wagtailcore.PagePermission object corresponding to the newly-created group and blog index page, and 'add' permission; and likewise for 'publish' permission

Restrict certain pages in Django-CMS

Disclaimer: I asked the question also at Google+, but I'm not sure how active the community there is
I'm struggling with Django CMS' permissions, and the documentation remains unclear for me.
I have the following requirements:
All CMS pages should be available only for authenticated users
Editing shall only be allowed to staff
Some pages should be only visible to a certain group
I don't find the way to achieve this. Could you point me to the right combination of settings?
Here are some more specific questions:
How does the "Login required" in the page permissions form relate to the other permissions you can set on the page?
If once set a view restriction for "this and all children", how can I remove it on a child page?
Why does CMS_PUBLIC_FOR not have a value for "Authenticated users"?
Is there a way to just restrict viewing of all CMS pages to authenticated users without restricting by a specific group?
Would be great if anyone had some hints.
Thanks!
I found a solution myself now:
First I wrote a custom middleware that redirects all requests to Django CMS pages to the login. Then, I removed the “can view pages” permission from all groups and all global permissions for non-staff.
Finally I removed all view restrictions on the page root and set them only on the particular pages which should be restricted.
If you are interested about some more findings in Django CMS' permissions: I blogged some thoughts about it here: http://blog.webrunners.de/2015/09/08/django-cms-permission-pitfalls/

Django disqus startup

Well I guess that most of Django developers are aware of the fact that the default Django's comment system is deprecated and no longer supported, so now ive decided to go for a reliable system such as disqus to handle my website's commenting system but there are several obstacles I need to solve before being able to make it functional(using Django-disqus plugin):
(The scenario is that the user leaves a comment for an article published by another user, and consequently, the user receiving the comment should be able to see all of the comments left by users for his articles in his profile section as well as being able to moderate them, something like a social website)
first of all it asks for API_KEY and whatever guide ive read for obtaining one is no longer valid(it looks like that disqus has a little shift in their strategy regarding api keys)
another is the fact that the Django package repo description says that the plugin supports moderation but I cant find it anywhere
and lastly, I also need to find a way to either store the comments locally or use remote queries to filter out comments in each profile section properly, or maybe there is another way that slipped my mind?
if the disqus plugin is not suitable for this situation, a suggestion for another Django plugin for comments handling and moderation with a tutorial is also welcome.
BTW the python version is 3.4 and Django version is 1.8, (both stable)

Standard Django way for letting users edit rich content

I have a Django website in which I want site administrators to be able to edit rich content.
Suppose we're talking about an organizational info page, which might include some pictures, and some links, where the page is not as structured as a news page (which updates with news pieces every few days), but still needs the ability to be easily edited by site admins which do not necessarily want to mess with HTML (or rather, I do not want them to).
So where do I put this dynamic content? On the database? In which format? How do I make it accesible in the django default admin?
Use one of the existing rich-text editors
The lightest weight would be to use something at the js level like DojoEditor:
http://code.djangoproject.com/wiki/AddDojoEditor
See also this thread:
Replace textarea with rich text editor in Django Admin?
For what you're describing I'd use flatpages, which is a django app that lets users create and edit pages in the admin panel.
As for formatting, I'd use TinyMCE. Integrating it is pretty easy, here is a walkthrough (do steps 1 and 2 and jump to the bottom, "Using TinyMCE with flatpages (newforms)")

Categories