From 24320332b0a55f8f06a06a7e92075b1e89f35bd5 Mon Sep 17 00:00:00 2001 From: Tom Talbot Date: Thu, 29 May 2014 15:02:56 +0100 Subject: [PATCH 01/16] Fix #94. Panels are now hidden on page load if they are marked as deleted after a form validation failure. --- .../static/wagtailadmin/js/page-editor.js | 11 +++++++++++ wagtail/wagtailadmin/views/pages.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js b/wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js index cbff2c8af8..4e8e1b02dc 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js +++ b/wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js @@ -181,6 +181,17 @@ function InlinePanel(opts) { self.updateMoveButtonDisabledStates(); }); } + + /* Hide container on page load if it is marked as deleted. Remove the error + message so that it doesn't count towards the number of errors on the tab at the + top of the page. */ + if ( $('#' + deleteInputId).val() === "1" ) { + $('#' + childId).hide(0, function() { + self.updateMoveButtonDisabledStates(); + self.setHasContent(); + }); + $('#' + childId).find(".error-message").remove(); + } }; self.formsUl = $('#' + opts.formsetPrefix + '-FORMS'); diff --git a/wagtail/wagtailadmin/views/pages.py b/wagtail/wagtailadmin/views/pages.py index 308f6fdd41..809497d83e 100644 --- a/wagtail/wagtailadmin/views/pages.py +++ b/wagtail/wagtailadmin/views/pages.py @@ -5,7 +5,7 @@ from django.contrib import messages from django.contrib.contenttypes.models import ContentType from django.contrib.auth.decorators import permission_required from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger -from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext as _ from django.views.decorators.vary import vary_on_headers from wagtail.wagtailadmin.edit_handlers import TabbedInterface, ObjectList From 4887bb7cf7df9d47153bc79be6eb22d44feb3e36 Mon Sep 17 00:00:00 2001 From: Tom Talbot Date: Fri, 30 May 2014 17:13:07 +0100 Subject: [PATCH 02/16] Added tests for snippets edit_handlers.py --- wagtail/wagtailsnippets/tests.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/wagtail/wagtailsnippets/tests.py b/wagtail/wagtailsnippets/tests.py index fd283f7f55..727e5e52df 100644 --- a/wagtail/wagtailsnippets/tests.py +++ b/wagtail/wagtailsnippets/tests.py @@ -5,6 +5,8 @@ from django.contrib.auth.models import User from wagtail.tests.utils import login, unittest from wagtail.tests.models import Advert +from wagtail.wagtailsnippets.views.snippets import get_content_type_from_url_params, get_snippet_edit_handler +from wagtail.wagtailsnippets.edit_handlers import SnippetChooserPanel class TestSnippetIndexView(TestCase): def setUp(self): @@ -137,3 +139,32 @@ class TestSnippetDelete(TestCase): # Check that the page is gone self.assertEqual(Advert.objects.filter(text='test_advert').count(), 0) + + +class TestSnippetChooserPanel(TestCase): + def setUp(self): + content_type = get_content_type_from_url_params('tests', + 'advert') + + test_snippet = Advert() + test_snippet.text = 'test_advert' + test_snippet.url = 'http://www.example.com/' + test_snippet.save() + + edit_handler_class = get_snippet_edit_handler(Advert) + form_class = edit_handler_class.get_form_class(Advert) + form = form_class(instance=test_snippet) + + self.snippet_chooser_panel_class = SnippetChooserPanel('text', content_type) + self.snippet_chooser_panel = self.snippet_chooser_panel_class(instance=test_snippet, + form=form) + + def test_create_snippet_chooser_panel_class(self): + self.assertEqual(self.snippet_chooser_panel_class.__name__, '_SnippetChooserPanel') + + def test_render_as_field(self): + self.assertTrue('test_advert' in self.snippet_chooser_panel.render_as_field()) + + def test_render_js(self): + self.assertTrue("createSnippetChooser(fixPrefix('id_text'), 'contenttypes/contenttype');" + in self.snippet_chooser_panel.render_js()) From 3f9cb2da6fcd614c3206631d6132d4286b6f1fbc Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Mon, 2 Jun 2014 13:27:39 +0100 Subject: [PATCH 03/16] Made login view redirect already logged in users to dashboard. Fixes #25 --- .../account/password_reset/complete.html | 2 +- .../templates/wagtailadmin/login.html | 2 +- .../tests/test_account_management.py | 1 - wagtail/wagtailadmin/urls.py | 10 ++------- wagtail/wagtailadmin/views/account.py | 22 ++++++++++++++++++- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/complete.html b/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/complete.html index c0cf872e25..3dc8272b07 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/complete.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/complete.html @@ -13,6 +13,6 @@ {% block furniture %}

{% trans "Password change successful" %}

-

{% trans "Login" %}

+

{% trans "Login" %}

{% endblock %} \ No newline at end of file diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/login.html b/wagtail/wagtailadmin/templates/wagtailadmin/login.html index 012dd32f89..22682500f7 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/login.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/login.html @@ -20,7 +20,7 @@ {% endif %} -
+ {% csrf_token %}

{% trans "Sign in to Wagtail" %}

diff --git a/wagtail/wagtailadmin/tests/test_account_management.py b/wagtail/wagtailadmin/tests/test_account_management.py index 95d54d7d93..63c70779b2 100644 --- a/wagtail/wagtailadmin/tests/test_account_management.py +++ b/wagtail/wagtailadmin/tests/test_account_management.py @@ -49,7 +49,6 @@ class TestAuthentication(TestCase): self.assertTrue('_auth_user_id' in self.client.session) self.assertEqual(self.client.session['_auth_user_id'], User.objects.get(username='test').id) - @unittest.expectedFailure # See: https://github.com/torchbox/wagtail/issues/25 def test_already_logged_in_redirect(self): """ This tests that a user who is already logged in is automatically diff --git a/wagtail/wagtailadmin/urls.py b/wagtail/wagtailadmin/urls.py index 8fbf2f6e77..806240c5c5 100644 --- a/wagtail/wagtailadmin/urls.py +++ b/wagtail/wagtailadmin/urls.py @@ -5,15 +5,8 @@ from wagtail.wagtailadmin.forms import LoginForm, PasswordResetForm from wagtail.wagtailadmin.views import account, chooser, home, pages, tags, userbar from wagtail.wagtailadmin import hooks -urlpatterns = [ - url( - r'^login/$', 'django.contrib.auth.views.login', { - 'template_name': 'wagtailadmin/login.html', - 'authentication_form': LoginForm, - 'extra_context': {'show_password_reset': getattr(settings, 'WAGTAIL_PASSWORD_MANAGEMENT_ENABLED', True)}, - }, name='wagtailadmin_login' - ), +urlpatterns = [ # Password reset url( r'^password_reset/$', 'django.contrib.auth.views.password_reset', { @@ -81,6 +74,7 @@ urlpatterns += [ url(r'^tag-autocomplete/$', tags.autocomplete, name='wagtailadmin_tag_autocomplete'), + url(r'^login/$', account.login, name='wagtailadmin_login'), url(r'^account/$', account.account, name='wagtailadmin_account'), url(r'^account/change_password/$', account.change_password, name='wagtailadmin_account_change_password'), url(r'^logout/$', account.logout, name='wagtailadmin_logout'), diff --git a/wagtail/wagtailadmin/views/account.py b/wagtail/wagtailadmin/views/account.py index 8479ea6b0e..c5e461f55c 100644 --- a/wagtail/wagtailadmin/views/account.py +++ b/wagtail/wagtailadmin/views/account.py @@ -3,8 +3,13 @@ from django.shortcuts import render, redirect from django.contrib import messages from django.contrib.auth.forms import SetPasswordForm from django.contrib.auth.decorators import permission_required -from django.contrib.auth.views import logout as auth_logout +from django.contrib.auth.views import logout as auth_logout, login as auth_login from django.utils.translation import ugettext as _ +from django.views.decorators.debug import sensitive_post_parameters +from django.views.decorators.cache import never_cache + +from wagtail.wagtailadmin import forms + @permission_required('wagtailadmin.access_admin') def account(request): @@ -37,6 +42,21 @@ def change_password(request): }) +@sensitive_post_parameters() +@never_cache +def login(request): + if request.user.is_authenticated(): + return redirect('wagtailadmin_home') + else: + return auth_login(request, + template_name='wagtailadmin/login.html', + authentication_form=forms.LoginForm, + extra_context={ + 'show_password_reset': getattr(settings, 'WAGTAIL_PASSWORD_MANAGEMENT_ENABLED', True), + }, + ) + + def logout(request): response = auth_logout(request, next_page = 'wagtailadmin_login') From 94f14ab12a191db6d188c88f3c6947f974bf4011 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Mon, 2 Jun 2014 16:17:40 +0100 Subject: [PATCH 04/16] Added changelog entry for #280 --- CHANGELOG.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 0a6024bd16..d2914194b7 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,8 @@ Changelog ========= + * When logged in user visits login page, they are now redirected to the dashboard + 0.3 (28.05.2014) ~~~~~~~~~~~~~~~~ * Added toolbar to allow logged-in users to add and edit pages from the site front-end From c7b997bd02e06f02362de098958b6a1b9c0023f5 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Tue, 3 Jun 2014 11:50:38 +0100 Subject: [PATCH 05/16] When previewing a page creation, populate url_path. This ensures that Page.dummy_request can infer a sensible hostname rather than falling back on example.com, which fails when ALLOWED_HOSTS is enforced. --- wagtail/wagtailadmin/views/pages.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wagtail/wagtailadmin/views/pages.py b/wagtail/wagtailadmin/views/pages.py index 308f6fdd41..17717dbba7 100644 --- a/wagtail/wagtailadmin/views/pages.py +++ b/wagtail/wagtailadmin/views/pages.py @@ -349,6 +349,10 @@ def preview_on_create(request, content_type_app_name, content_type_model_name, p if form.is_valid(): form.save(commit=False) + # ensure that our unsaved page instance has a suitable url set + parent_page = get_object_or_404(Page, id=parent_page_id).specific + page.set_url_path(parent_page) + # This view will generally be invoked as an AJAX request; as such, in the case of # an error Django will return a plaintext response. This isn't what we want, since # we will be writing the response back to an HTML page regardless of success or From e24e68fceda6d483e71c548d3c30d1f056981110 Mon Sep 17 00:00:00 2001 From: Dave Cranwell Date: Tue, 3 Jun 2014 12:59:49 +0100 Subject: [PATCH 06/16] Update CHANGELOG.txt --- CHANGELOG.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d2914194b7..68a21731b8 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -2,6 +2,7 @@ Changelog ========= * When logged in user visits login page, they are now redirected to the dashboard + * Fix: Deleting an item from an InlinePanel, then generating a validation error on saving, no longer causes the deleted item to confusingly reappear with an error of it's own. 0.3 (28.05.2014) ~~~~~~~~~~~~~~~~ From c052214880fccff239c14466ee5d67ac118e5488 Mon Sep 17 00:00:00 2001 From: Tom Dyson Date: Tue, 3 Jun 2014 13:30:45 +0100 Subject: [PATCH 07/16] Grammar fixes in FE docs --- docs/building_your_site/frontenddevelopers.rst | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/building_your_site/frontenddevelopers.rst b/docs/building_your_site/frontenddevelopers.rst index d009a1af87..e5f5833979 100644 --- a/docs/building_your_site/frontenddevelopers.rst +++ b/docs/building_your_site/frontenddevelopers.rst @@ -7,8 +7,6 @@ For Front End developers Overview ======================== -This page is aimed at non-Django-literate Front End developers. - Wagtail uses Django's templating language. For developers new to Django, start with Django's own template documentation: https://docs.djangoproject.com/en/dev/topics/templates/ @@ -75,7 +73,7 @@ Images uploaded to Wagtail by its users (as opposed to a developer's static file Unlike other CMS, adding images to a page does not involve choosing a "version" of the image to use. Wagtail has no predefined image "formats" or "sizes". Instead the template developer defines image manipulation to occur *on the fly* when the image is requested, via a special syntax within the template. -Images from the library **must** be requested using this syntax, but a developer's static images can be added via conventional means e.g ``img`` tags. Only images from the library can be manipulated on the fly. +Images from the library must be requested using this syntax, but a developer's static images can be added via conventional means e.g ``img`` tags. Only images from the library can be manipulated on the fly. Read more about the image manipulation syntax here :ref:`image_tag`. @@ -84,7 +82,7 @@ Read more about the image manipulation syntax here :ref:`image_tag`. Template tags & filters ======================== -In addition to Django's standard tags and filters, Wagtail provides some of it's own, which can be ``load``-ed `as you would any other `_ +In addition to Django's standard tags and filters, Wagtail provides some of its own, which can be ``load``-ed `as you would any other `_ .. _image_tag: @@ -146,15 +144,15 @@ The available ``method`` s are: Resize and **crop** to fill the **exact** dimensions. - This can be particularly useful for websites requiring square thumbnails of arbitrary images. e.g A landscape image of width 2000, height 1000, treated with ``fill`` dimensions ``200x200`` would have it's height reduced to 200, then it's width (ordinarily 400) cropped to 200. + This can be particularly useful for websites requiring square thumbnails of arbitrary images. For example, a landscape image of width 2000, height 1000, treated with ``fill`` dimensions ``200x200`` would have its height reduced to 200, then its width (ordinarily 400) cropped to 200. **The crop always aligns on the centre of the image.** .. Note:: - Wagtail *does not allow deforming or stretching images*. Image dimension ratios will always be kept. Wagtail also *does not support upscaling*. Small images forced to appear at larger sizes will "max out" at their their native dimensions. + Wagtail does not allow deforming or stretching images. Image dimension ratios will always be kept. Wagtail also *does not support upscaling*. Small images forced to appear at larger sizes will "max out" at their their native dimensions. .. Note:: - Wagtail does not make the "original" version of an image explicitly available. To request it, it's suggested you rely on the lack of upscaling by requesting an image much larger than it's maximum dimensions. e.g to insert an image who's dimensions are uncertain/unknown at it's maximum size, try: ``{% image self.image width-10000 %}``. This assumes the image is unlikely to be larger than 10000px wide. + Wagtail does not make the "original" version of an image explicitly available. To request it, you could rely on the lack of upscaling by requesting an image larger than its maximum dimensions. e.g to insert an image whose dimensions are unknown at its maximum size, try: ``{% image self.image width-10000 %}``. This assumes the image is unlikely to be larger than 10000px wide. .. _image_tag_alt: From f3f7b466b13944de4cd43cc9f0a19ceb8d0e2552 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Tue, 3 Jun 2014 14:15:18 +0100 Subject: [PATCH 08/16] When generating dummy requests for pages with no routable URL, fall back on a hostname from ALLOWED_HOSTS and finally localhost --- wagtail/wagtailcore/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wagtail/wagtailcore/models.py b/wagtail/wagtailcore/models.py index f72e6f6f9e..30ffc8a77f 100644 --- a/wagtail/wagtailcore/models.py +++ b/wagtail/wagtailcore/models.py @@ -581,7 +581,12 @@ class Page(MP_Node, ClusterableModel, Indexed): path = url_info.path port = url_info.port or 80 else: - hostname = 'example.com' + # Cannot determine a URL to this page - cobble one together based on + # whatever we find in ALLOWED_HOSTS + try: + hostname = settings.ALLOWED_HOSTS[0] + except IndexError: + hostname = 'localhost' path = '/' port = 80 From 2d7a276b831aebf5c56a61eaec13d08f41ea807e Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Tue, 3 Jun 2014 14:33:21 +0100 Subject: [PATCH 09/16] Changelog entries for dummy_request fixes --- CHANGELOG.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 0a6024bd16..1e8d9ac93b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,11 @@ Changelog ========= +0.3.1 (xx.xx.20xx) +~~~~~~~~~~~~~~~~~~ + * Fix: When constructing dummy requests for pages with no routable URL, fall back on a hostname from ALLOWED_HOSTS and finally 'localhost', to avoid 'Invalid HTTP_HOST header' errors on preview when DEBUG=False. + * Fix: Ensure that url_path is populated when previewing a newly created page, to avoid unnecessarily taking the above fallback. + 0.3 (28.05.2014) ~~~~~~~~~~~~~~~~ * Added toolbar to allow logged-in users to add and edit pages from the site front-end From a5072c768df546641311a0085aed6e6ae8debb57 Mon Sep 17 00:00:00 2001 From: Tom Talbot Date: Thu, 29 May 2014 15:02:56 +0100 Subject: [PATCH 10/16] Fix #94. Panels are now hidden on page load if they are marked as deleted after a form validation failure. --- .../static/wagtailadmin/js/page-editor.js | 11 +++++++++++ wagtail/wagtailadmin/views/pages.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js b/wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js index cbff2c8af8..4e8e1b02dc 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js +++ b/wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js @@ -181,6 +181,17 @@ function InlinePanel(opts) { self.updateMoveButtonDisabledStates(); }); } + + /* Hide container on page load if it is marked as deleted. Remove the error + message so that it doesn't count towards the number of errors on the tab at the + top of the page. */ + if ( $('#' + deleteInputId).val() === "1" ) { + $('#' + childId).hide(0, function() { + self.updateMoveButtonDisabledStates(); + self.setHasContent(); + }); + $('#' + childId).find(".error-message").remove(); + } }; self.formsUl = $('#' + opts.formsetPrefix + '-FORMS'); diff --git a/wagtail/wagtailadmin/views/pages.py b/wagtail/wagtailadmin/views/pages.py index 17717dbba7..9bf6dbf444 100644 --- a/wagtail/wagtailadmin/views/pages.py +++ b/wagtail/wagtailadmin/views/pages.py @@ -5,7 +5,7 @@ from django.contrib import messages from django.contrib.contenttypes.models import ContentType from django.contrib.auth.decorators import permission_required from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger -from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext as _ from django.views.decorators.vary import vary_on_headers from wagtail.wagtailadmin.edit_handlers import TabbedInterface, ObjectList From e449fcc8610d157df51dc1bd67174f696f53b6d5 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Tue, 3 Jun 2014 14:47:05 +0100 Subject: [PATCH 11/16] Changelog entry for a5072c7 --- CHANGELOG.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 1e8d9ac93b..10fe8132d3 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -5,6 +5,7 @@ Changelog ~~~~~~~~~~~~~~~~~~ * Fix: When constructing dummy requests for pages with no routable URL, fall back on a hostname from ALLOWED_HOSTS and finally 'localhost', to avoid 'Invalid HTTP_HOST header' errors on preview when DEBUG=False. * Fix: Ensure that url_path is populated when previewing a newly created page, to avoid unnecessarily taking the above fallback. + * Fix: Deleting an item from an InlinePanel, then generating a validation error on saving, no longer causes the deleted item to confusingly reappear with an error of its own. 0.3 (28.05.2014) ~~~~~~~~~~~~~~~~ From 649cbf95c4af4e0edc86888cccbdb86b5f21c6ba Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Tue, 3 Jun 2014 14:54:37 +0100 Subject: [PATCH 12/16] version bump for 0.3.1 --- CHANGELOG.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 10fe8132d3..4910fa4bbf 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,7 +1,7 @@ Changelog ========= -0.3.1 (xx.xx.20xx) +0.3.1 (03.06.2014) ~~~~~~~~~~~~~~~~~~ * Fix: When constructing dummy requests for pages with no routable URL, fall back on a hostname from ALLOWED_HOSTS and finally 'localhost', to avoid 'Invalid HTTP_HOST header' errors on preview when DEBUG=False. * Fix: Ensure that url_path is populated when previewing a newly created page, to avoid unnecessarily taking the above fallback. diff --git a/setup.py b/setup.py index 4f5b87c121..7b26817cd8 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ except ImportError: setup( name='wagtail', - version='0.3', + version='0.3.1', description='A Django content management system focused on flexibility and user experience', author='Matthew Westcott', author_email='matthew.westcott@torchbox.com', From 399f271ca7a9a2352cb8f4e01c03ad70e7cbff7d Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Wed, 4 Jun 2014 13:27:06 +0100 Subject: [PATCH 13/16] Fixed missing return statement in embed frontend renderer --- wagtail/wagtailembeds/format.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wagtail/wagtailembeds/format.py b/wagtail/wagtailembeds/format.py index 453c73641a..1654be989e 100644 --- a/wagtail/wagtailembeds/format.py +++ b/wagtail/wagtailembeds/format.py @@ -17,7 +17,7 @@ def embed_to_frontend_html(url): ratio = "0" # Render template - render_to_string('wagtailembeds/embed_frontend.html', { + return render_to_string('wagtailembeds/embed_frontend.html', { 'embed': embed, 'ratio': ratio, }) From 6a4df387e3e55e6d710dc38c6b63be086576e338 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Wed, 4 Jun 2014 13:35:58 +0100 Subject: [PATCH 14/16] Mark embed code as safe in frontend template --- .../wagtailembeds/templates/wagtailembeds/embed_frontend.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wagtail/wagtailembeds/templates/wagtailembeds/embed_frontend.html b/wagtail/wagtailembeds/templates/wagtailembeds/embed_frontend.html index feb209311f..b97dceb830 100644 --- a/wagtail/wagtailembeds/templates/wagtailembeds/embed_frontend.html +++ b/wagtail/wagtailembeds/templates/wagtailembeds/embed_frontend.html @@ -1,3 +1,3 @@
- {{ embed.html }} + {{ embed.html|safe }}
From 43e0ce721fcbca7a70d41f4bd92d859cacb296ad Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Wed, 4 Jun 2014 14:43:10 +0100 Subject: [PATCH 15/16] Revert "Made login view redirect already logged in users to dashboard." This reverts commit 3f9cb2da6fcd614c3206631d6132d4286b6f1fbc. --- .../account/password_reset/complete.html | 2 +- .../templates/wagtailadmin/login.html | 2 +- .../tests/test_account_management.py | 1 + wagtail/wagtailadmin/urls.py | 10 +++++++-- wagtail/wagtailadmin/views/account.py | 22 +------------------ 5 files changed, 12 insertions(+), 25 deletions(-) diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/complete.html b/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/complete.html index 3dc8272b07..c0cf872e25 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/complete.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/complete.html @@ -13,6 +13,6 @@ {% block furniture %}

{% trans "Password change successful" %}

-

{% trans "Login" %}

+

{% trans "Login" %}

{% endblock %} \ No newline at end of file diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/login.html b/wagtail/wagtailadmin/templates/wagtailadmin/login.html index 22682500f7..012dd32f89 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/login.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/login.html @@ -20,7 +20,7 @@ {% endif %} - + {% csrf_token %}

{% trans "Sign in to Wagtail" %}

diff --git a/wagtail/wagtailadmin/tests/test_account_management.py b/wagtail/wagtailadmin/tests/test_account_management.py index 63c70779b2..95d54d7d93 100644 --- a/wagtail/wagtailadmin/tests/test_account_management.py +++ b/wagtail/wagtailadmin/tests/test_account_management.py @@ -49,6 +49,7 @@ class TestAuthentication(TestCase): self.assertTrue('_auth_user_id' in self.client.session) self.assertEqual(self.client.session['_auth_user_id'], User.objects.get(username='test').id) + @unittest.expectedFailure # See: https://github.com/torchbox/wagtail/issues/25 def test_already_logged_in_redirect(self): """ This tests that a user who is already logged in is automatically diff --git a/wagtail/wagtailadmin/urls.py b/wagtail/wagtailadmin/urls.py index 806240c5c5..8fbf2f6e77 100644 --- a/wagtail/wagtailadmin/urls.py +++ b/wagtail/wagtailadmin/urls.py @@ -5,8 +5,15 @@ from wagtail.wagtailadmin.forms import LoginForm, PasswordResetForm from wagtail.wagtailadmin.views import account, chooser, home, pages, tags, userbar from wagtail.wagtailadmin import hooks - urlpatterns = [ + url( + r'^login/$', 'django.contrib.auth.views.login', { + 'template_name': 'wagtailadmin/login.html', + 'authentication_form': LoginForm, + 'extra_context': {'show_password_reset': getattr(settings, 'WAGTAIL_PASSWORD_MANAGEMENT_ENABLED', True)}, + }, name='wagtailadmin_login' + ), + # Password reset url( r'^password_reset/$', 'django.contrib.auth.views.password_reset', { @@ -74,7 +81,6 @@ urlpatterns += [ url(r'^tag-autocomplete/$', tags.autocomplete, name='wagtailadmin_tag_autocomplete'), - url(r'^login/$', account.login, name='wagtailadmin_login'), url(r'^account/$', account.account, name='wagtailadmin_account'), url(r'^account/change_password/$', account.change_password, name='wagtailadmin_account_change_password'), url(r'^logout/$', account.logout, name='wagtailadmin_logout'), diff --git a/wagtail/wagtailadmin/views/account.py b/wagtail/wagtailadmin/views/account.py index c5e461f55c..8479ea6b0e 100644 --- a/wagtail/wagtailadmin/views/account.py +++ b/wagtail/wagtailadmin/views/account.py @@ -3,13 +3,8 @@ from django.shortcuts import render, redirect from django.contrib import messages from django.contrib.auth.forms import SetPasswordForm from django.contrib.auth.decorators import permission_required -from django.contrib.auth.views import logout as auth_logout, login as auth_login +from django.contrib.auth.views import logout as auth_logout from django.utils.translation import ugettext as _ -from django.views.decorators.debug import sensitive_post_parameters -from django.views.decorators.cache import never_cache - -from wagtail.wagtailadmin import forms - @permission_required('wagtailadmin.access_admin') def account(request): @@ -42,21 +37,6 @@ def change_password(request): }) -@sensitive_post_parameters() -@never_cache -def login(request): - if request.user.is_authenticated(): - return redirect('wagtailadmin_home') - else: - return auth_login(request, - template_name='wagtailadmin/login.html', - authentication_form=forms.LoginForm, - extra_context={ - 'show_password_reset': getattr(settings, 'WAGTAIL_PASSWORD_MANAGEMENT_ENABLED', True), - }, - ) - - def logout(request): response = auth_logout(request, next_page = 'wagtailadmin_login') From a104c5eb168866cef3b47b59013933172b740730 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Wed, 4 Jun 2014 14:44:14 +0100 Subject: [PATCH 16/16] revert changelog entry --- CHANGELOG.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 9a5a5669fe..b708cfd217 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,7 +3,6 @@ Changelog 0.4 (xx.xx.20xx) ~~~~~~~~~~~~~~~~~~ - * When logged in user visits login page, they are now redirected to the dashboard 0.3.1 (03.06.2014) ~~~~~~~~~~~~~~~~~~