Reputation: 61
I feel like I'm missing something painfully obvious, but if I'm in the default editors / moderator group + the user is a superuser....
Should not pages that were submitted for moderation be showing under the wagtail dashboard?
I thought I might have missed a permissions so then I went to admin and added every single option there and still no dice.....
What is required to be able to moderate the pages submitted for mod approval?
Example:
I submit a page programatically from a create view for moderation by doing the following:
my_page = self.index.add_child(instance=my_page_instance)
my_page.unpublish()
my_page.save_revision(submitted_for_moderation=True)
if not send_notification(my_page.get_latest_revision().id, 'submitted', None):
print("Failed to send notification + email for mod approval")
Upvotes: 0
Views: 444
Reputation: 5186
The issue is that when you create the revisions programmatically, you must provide a user record along with the save_revision
method call. It can be any user record.
Example:
from django.contrib.auth.models import User
some_admin_user = User.objects.all().first() # or request.user if you are doing this where you can access the current request
my_page.save_revision(submitted_for_moderation=True, user=some_admin_user)
Reason
The home view's PagesForModerationPanel
that is generated selects related pages and users to any revisions requiring moderation. When no user is passed to the new revision, it means that these revisions will not show up in the admin because the query will not return them.
See code in admin/views/home.py
self.page_revisions_for_moderation = (user_perms.revisions_for_moderation()
.select_related('page', 'user').order_by('-created_at'))
It might be worth submitting this as a potential bug, it probably would be nicer if an error was thrown when a user was not submitted with a revision save.
Upvotes: 2