kopia lustrzana https://github.com/wagtail/wagtail
				
				
				
			
			
			
			
				pull/8695/head
			
			
		
		
							rodzic
							
								
									996866fc06
								
							
						
					
					
						commit
						e2e356d0ae
					
				|  | @ -48,6 +48,7 @@ Changelog | |||
|  * Fix: Ensure non-square avatar images will correctly show throughout the admin (LB (Ben) Johnston) | ||||
|  * Fix: Ignore translations in test files and re-include some translations that were accidentally ignored (Stefan Hammer) | ||||
|  * Fix: Show alternative message when no page types are available to be created (Jaspreet Singh) | ||||
|  * Fix: Prevent error on sending notifications for the legacy moderation process when no user was specified (Yves Serrano) | ||||
| 
 | ||||
| 
 | ||||
| 3.0.1 (16.06.2022) | ||||
|  |  | |||
|  | @ -602,6 +602,7 @@ Contributors | |||
| * Benedict Faw | ||||
| * Lucie Le Frapper | ||||
| * Jaspreet Singh | ||||
| * Yves Serrano | ||||
| 
 | ||||
| Translators | ||||
| =========== | ||||
|  |  | |||
|  | @ -62,6 +62,7 @@ When using a queryset to render a list of images, you can now use the ``prefetch | |||
|  * Ensure non-square avatar images will correctly show throughout the admin (LB (Ben) Johnston) | ||||
|  * Ignore translations in test files and re-include some translations that were accidentally ignored (Stefan Hammer) | ||||
|  * Show alternative message when no page types are available to be created (Jaspreet Singh) | ||||
|  * Prevent error on sending notifications for the legacy moderation process when no user was specified (Yves Serrano) | ||||
| 
 | ||||
| 
 | ||||
| ## Upgrade considerations | ||||
|  |  | |||
|  | @ -77,7 +77,7 @@ def send_moderation_notification(revision, notification, excluded_user=None): | |||
|         ) | ||||
|     elif notification in ["rejected", "approved"]: | ||||
|         # Get submitter | ||||
|         recipient_users = [revision.user] | ||||
|         recipient_users = [revision.user] if revision.user else [] | ||||
|     else: | ||||
|         return False | ||||
| 
 | ||||
|  |  | |||
|  | @ -370,3 +370,62 @@ class TestNotificationPreferences(TestCase, WagtailTestUtils): | |||
|             headers.issubset(msg_headers), | ||||
|             msg="Message is missing the Auto-Submitted header.", | ||||
|         ) | ||||
| 
 | ||||
| 
 | ||||
| class TestApproveRejectModerationWithoutUser(TestCase, WagtailTestUtils): | ||||
|     def setUp(self): | ||||
|         self.submitter = self.create_superuser( | ||||
|             username="submitter", | ||||
|             email="submitter@email.com", | ||||
|             password="password", | ||||
|         ) | ||||
| 
 | ||||
|         self.user = self.login() | ||||
| 
 | ||||
|         # Create a page and submit it for moderation | ||||
|         root_page = Page.objects.get(id=2) | ||||
|         self.page = SimplePage( | ||||
|             title="Hello world!", | ||||
|             slug="hello-world", | ||||
|             content="hello", | ||||
|             live=False, | ||||
|             has_unpublished_changes=True, | ||||
|         ) | ||||
|         root_page.add_child(instance=self.page) | ||||
| 
 | ||||
|         # save_revision without user | ||||
|         self.page.save_revision(submitted_for_moderation=True) | ||||
|         self.revision = self.page.get_latest_revision() | ||||
| 
 | ||||
|     def test_approve_moderation_view_without_user(self): | ||||
|         """ | ||||
|         This posts to the approve moderation view and checks that the page was approved | ||||
|         """ | ||||
|         # Connect a mock signal handler to page_published signal | ||||
|         mock_handler = mock.MagicMock() | ||||
|         page_published.connect(mock_handler) | ||||
| 
 | ||||
|         # Post | ||||
|         response = self.client.post( | ||||
|             reverse("wagtailadmin_pages:approve_moderation", args=(self.revision.id,)) | ||||
|         ) | ||||
| 
 | ||||
|         # Check that the user was redirected to the dashboard | ||||
|         self.assertRedirects(response, reverse("wagtailadmin_home")) | ||||
| 
 | ||||
|         page = Page.objects.get(id=self.page.id) | ||||
|         # Page must be live | ||||
|         self.assertTrue(page.live, "Approving moderation failed to set live=True") | ||||
|         # Page should now have no unpublished changes | ||||
|         self.assertFalse( | ||||
|             page.has_unpublished_changes, | ||||
|             "Approving moderation failed to set has_unpublished_changes=False", | ||||
|         ) | ||||
| 
 | ||||
|         # Check that the page_published signal was fired | ||||
|         self.assertEqual(mock_handler.call_count, 1) | ||||
|         mock_call = mock_handler.mock_calls[0][2] | ||||
| 
 | ||||
|         self.assertEqual(mock_call["sender"], self.page.specific_class) | ||||
|         self.assertEqual(mock_call["instance"], self.page) | ||||
|         self.assertIsInstance(mock_call["instance"], self.page.specific_class) | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Yves Serrano
						Yves Serrano