Merge branch 'master' into more-unit-tests

pull/287/head
Tom Talbot 2014-06-04 16:19:04 +01:00
commit c4e7848264
9 zmienionych plików z 70 dodań i 12 usunięć

Wyświetl plik

@ -1,6 +1,15 @@
Changelog
=========
0.4 (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.
* 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)
~~~~~~~~~~~~~~~~
* Added toolbar to allow logged-in users to add and edit pages from the site front-end

Wyświetl plik

@ -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 <https://docs.djangoproject.com/en/dev/topics/templates/#custom-tag-and-filter-libraries>`_
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 <https://docs.djangoproject.com/en/dev/topics/templates/#custom-tag-and-filter-libraries>`_
.. _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:

Wyświetl plik

@ -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',

Wyświetl plik

@ -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');

Wyświetl plik

@ -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
@ -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

Wyświetl plik

@ -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

Wyświetl plik

@ -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,
})

Wyświetl plik

@ -1,3 +1,3 @@
<div style="padding-bottom: {{ ratio }};" class="responsive-object">
{{ embed.html }}
{{ embed.html|safe }}
</div>

Wyświetl plik

@ -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())