kopia lustrzana https://github.com/wagtail/wagtail
Fix notification errors when there are multiple moderation groups
On SQLite, not all moderators would receive a notification. On Postgres, a “more than one row returned by a subquery used as an expression” error was thrown.pull/2139/head
rodzic
6b78836d8d
commit
0845f1e1c1
|
@ -20,6 +20,7 @@ Changelog
|
|||
* Fix: Tags added on the multiple image uploader are now saved correctly
|
||||
* Fix: Documents created by a user are no longer deleted when the user is deleted
|
||||
* Fix: Fixed a crash in `RedirectMiddleware` when a middleware class before `SiteMiddleware` returns a response (Josh Schneier)
|
||||
* Fix: Fixed error retrieving the moderator list on pages that are covered by multiple moderator permission records (Matt Fozard)
|
||||
|
||||
1.3.1 (05.01.2016)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -39,6 +39,7 @@ Bug fixes
|
|||
* Tags added on the multiple image uploader are now saved correctly
|
||||
* Documents created by a user are no longer deleted when the user is deleted
|
||||
* Fixed a crash in ``RedirectMiddleware`` when a middleware class before ``SiteMiddleware`` returns a response (Josh Schneier)
|
||||
* Fixed error retrieving the moderator list on pages that are covered by multiple moderator permission records (Matt Fozard)
|
||||
|
||||
|
||||
Upgrade considerations
|
||||
|
|
|
@ -17,7 +17,7 @@ from wagtail.tests.testapp.models import (
|
|||
BusinessIndex, BusinessChild, BusinessSubIndex,
|
||||
TaggedPage, Advert, AdvertPlacement)
|
||||
from wagtail.tests.utils import WagtailTestUtils
|
||||
from wagtail.wagtailcore.models import Page, PageRevision, Site
|
||||
from wagtail.wagtailcore.models import GroupPagePermission, Page, PageRevision, Site
|
||||
from wagtail.wagtailcore.signals import page_published, page_unpublished
|
||||
from wagtail.wagtailusers.models import UserProfile
|
||||
|
||||
|
@ -2310,6 +2310,41 @@ class TestNotificationPreferences(TestCase, WagtailTestUtils):
|
|||
# No email to send
|
||||
self.assertEqual(len(mail.outbox), 0)
|
||||
|
||||
def test_moderator_group_notifications(self):
|
||||
# Create a (non-superuser) moderator
|
||||
User = get_user_model()
|
||||
user1 = User.objects.create_user('moduser1', 'moduser1@email.com')
|
||||
user1.groups.add(Group.objects.get(name='Moderators'))
|
||||
user1.save()
|
||||
|
||||
# Create another group and user with permission to moderate
|
||||
modgroup2 = Group.objects.create(name='More moderators')
|
||||
GroupPagePermission.objects.create(
|
||||
group=modgroup2, page=self.root_page, permission_type='publish'
|
||||
)
|
||||
user2 = User.objects.create_user('moduser2', 'moduser2@email.com')
|
||||
user2.groups.add(Group.objects.get(name='More moderators'))
|
||||
user2.save()
|
||||
|
||||
# Submit
|
||||
# This used to break in Wagtail 1.3 (Postgres exception, SQLite 3/4 notifications)
|
||||
response = self.submit()
|
||||
|
||||
# Should be redirected to explorer page
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
# Check that the superusers and the moderation group members all got an email
|
||||
expected_emails = 4
|
||||
self.assertEqual(len(mail.outbox), expected_emails)
|
||||
email_to = []
|
||||
for i in range(expected_emails):
|
||||
self.assertEqual(len(mail.outbox[i].to), 1)
|
||||
email_to += mail.outbox[i].to
|
||||
self.assertIn(self.moderator.email, email_to)
|
||||
self.assertIn(self.moderator2.email, email_to)
|
||||
self.assertIn(user1.email, email_to)
|
||||
self.assertIn(user2.email, email_to)
|
||||
|
||||
|
||||
class TestLocking(TestCase, WagtailTestUtils):
|
||||
def setUp(self):
|
||||
|
|
|
@ -56,7 +56,7 @@ def users_with_page_permission(page, permission_type, include_superusers=True):
|
|||
# Find GroupPagePermission records of the given type that apply to this page or an ancestor
|
||||
ancestors_and_self = list(page.get_ancestors()) + [page]
|
||||
perm = GroupPagePermission.objects.filter(permission_type=permission_type, page__in=ancestors_and_self)
|
||||
q = Q(groups__page_permissions=perm)
|
||||
q = Q(groups__page_permissions__in=perm)
|
||||
|
||||
# Include superusers
|
||||
if include_superusers:
|
||||
|
|
Ładowanie…
Reference in New Issue