mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-04 13:34:46 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
531a5b4703
5 changed files with 59 additions and 3 deletions
|
|
@ -9,6 +9,8 @@ Changelog
|
|||
* Replaced lxml dependency with html5lib, to simplify installation
|
||||
* Added page_unpublished signal
|
||||
|
||||
* Fix: Updates to tag fields are now properly committed to the database when publishing directly from the page edit interface
|
||||
|
||||
0.4.1 (14.07.2014)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
* ElasticSearch backend now respects the backward-compatible URLS configuration setting, in addition to HOSTS
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ Admin
|
|||
Bug fixes
|
||||
~~~~~~~~~
|
||||
|
||||
* Updates to tag fields are now properly committed to the database when publishing directly from the page edit interface.
|
||||
|
||||
|
||||
Backwards incompatible changes
|
||||
==============================
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ from django.utils.encoding import python_2_unicode_compatible
|
|||
from django.conf.urls import url
|
||||
from django.http import HttpResponse
|
||||
|
||||
from taggit.models import TaggedItemBase
|
||||
|
||||
from modelcluster.fields import ParentalKey
|
||||
from modelcluster.tags import ClusterTaggableManager
|
||||
|
||||
from wagtail.wagtailcore.models import Page, Orderable
|
||||
from wagtail.wagtailcore.fields import RichTextField
|
||||
|
|
@ -414,3 +417,11 @@ class RoutablePageTest(RoutablePage):
|
|||
|
||||
def main(self, request):
|
||||
return HttpResponse("MAIN VIEW")
|
||||
|
||||
|
||||
class TaggedPageTag(TaggedItemBase):
|
||||
content_object = ParentalKey('tests.TaggedPage', related_name='tagged_items')
|
||||
|
||||
|
||||
class TaggedPage(Page):
|
||||
tags = ClusterTaggableManager(through=TaggedPageTag, blank=True)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from django.core import mail
|
|||
from django.core.paginator import Paginator
|
||||
from django.utils import timezone
|
||||
|
||||
from wagtail.tests.models import SimplePage, EventPage, EventPageCarouselItem, StandardIndex, BusinessIndex, BusinessChild, BusinessSubIndex
|
||||
from wagtail.tests.models import SimplePage, EventPage, EventPageCarouselItem, StandardIndex, BusinessIndex, BusinessChild, BusinessSubIndex, TaggedPage
|
||||
from wagtail.tests.utils import unittest, WagtailTestUtils
|
||||
from wagtail.wagtailcore.models import Page, PageRevision
|
||||
from wagtail.wagtailcore.signals import page_published, page_unpublished
|
||||
|
|
@ -1410,3 +1410,36 @@ class TestNotificationPreferences(TestCase, WagtailTestUtils):
|
|||
|
||||
# No email to send
|
||||
self.assertEqual(len(mail.outbox), 0)
|
||||
|
||||
|
||||
class TestIssue197(TestCase, WagtailTestUtils):
|
||||
def test_issue_197(self):
|
||||
# Find root page
|
||||
self.root_page = Page.objects.get(id=2)
|
||||
|
||||
# Create a tagged page with no tags
|
||||
self.tagged_page = self.root_page.add_child(instance=TaggedPage(
|
||||
title="Tagged page",
|
||||
slug='tagged-page',
|
||||
live=False,
|
||||
))
|
||||
|
||||
# Login
|
||||
self.user = self.login()
|
||||
|
||||
# Add some tags and publish using edit view
|
||||
post_data = {
|
||||
'title': "Tagged page",
|
||||
'slug':'tagged-page',
|
||||
'tags': "hello, world",
|
||||
'action-publish': "Publish",
|
||||
}
|
||||
response = self.client.post(reverse('wagtailadmin_pages_edit', args=(self.tagged_page.id, )), post_data)
|
||||
|
||||
# Should be redirected to explorer page
|
||||
self.assertRedirects(response, reverse('wagtailadmin_explore', args=(self.root_page.id, )))
|
||||
|
||||
# Check that both tags are in the pages tag set
|
||||
page = TaggedPage.objects.get(id=self.tagged_page.id)
|
||||
self.assertIn('hello', page.tags.slugs())
|
||||
self.assertIn('world', page.tags.slugs())
|
||||
|
|
|
|||
|
|
@ -313,7 +313,13 @@ def edit(request, page_id):
|
|||
approved_go_live_at = go_live_at
|
||||
else:
|
||||
page.live = True
|
||||
form.save()
|
||||
|
||||
# We need save the page this way to workaround a bug
|
||||
# in django-modelcluster causing m2m fields to not
|
||||
# be committed to the database. See github issue #192
|
||||
form.save(commit=False)
|
||||
page.save()
|
||||
|
||||
# Clear approved_go_live_at for older revisions
|
||||
page.revisions.update(
|
||||
submitted_for_moderation=False,
|
||||
|
|
@ -328,7 +334,9 @@ def edit(request, page_id):
|
|||
Page.objects.filter(id=page.id).update(has_unpublished_changes=True)
|
||||
else:
|
||||
page.has_unpublished_changes = True
|
||||
form.save()
|
||||
form.save(commit=False)
|
||||
page.save()
|
||||
|
||||
|
||||
page.save_revision(
|
||||
user=request.user,
|
||||
|
|
|
|||
Loading…
Reference in a new issue