mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-08 23:44:44 +00:00
Merge branch 'master' into pull_576
This commit is contained in:
commit
75b8cc0483
8 changed files with 80 additions and 10 deletions
|
|
@ -5,6 +5,7 @@ branch = True
|
|||
source = wagtail
|
||||
|
||||
omit =
|
||||
*/south_migrations/*
|
||||
*/migrations/*
|
||||
wagtail/vendor/*
|
||||
|
||||
|
|
@ -31,4 +32,4 @@ exclude_lines =
|
|||
ignore_errors = True
|
||||
|
||||
[html]
|
||||
directory = coverage_html_report
|
||||
directory = coverage_html_report
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ Changelog
|
|||
* Renamed wagtailsearch.indexed to wagtailsearch.index
|
||||
* Fix: Page URL generation now returns correct URLs for sites that have the main 'serve' view rooted somewhere other than '/'
|
||||
* Fix: Search results in the page chooser now respect the page_type parameter on PageChooserPanel
|
||||
* Fix: Rendition filenames are now prevented from going over 60 chars, even with a large focal_point_key
|
||||
|
||||
0.5 (01.08.2014)
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ Contributing
|
|||
~~~~~~~~~~~~
|
||||
If you're a Python or Django developer, fork the repo and get stuck in!
|
||||
|
||||
We suggest you start by checking the `Help develop me! <https://github.com/torchbox/wagtail/issues?labels=Help+develop+me%21>`_ label and the `coding guidelines <http://wagtail.readthedocs.org/en/latest/contributing.html#coding-guidelines>`_.
|
||||
We suggest you start by checking the `Help develop me! <https://github.com/torchbox/wagtail/issues?labels=Help+develop+me%21>`_ label and the `coding guidelines <http://wagtail.readthedocs.org/en/latest/howto/contributing.html#coding-guidelines>`_.
|
||||
|
||||
Send us a useful pull request and we'll post you a `t-shirt <https://twitter.com/WagtailCMS/status/432166799464210432/photo/1>`_.
|
||||
|
||||
We also welcome `translations <http://wagtail.readthedocs.org/en/latest/contributing.html#translations>`_ for Wagtail's interface.
|
||||
We also welcome `translations <http://wagtail.readthedocs.org/en/latest/howto/contributing.html#translations>`_ for Wagtail's interface.
|
||||
|
|
|
|||
|
|
@ -147,3 +147,50 @@ In addition to the model fields provided, ``Page`` has many properties and metho
|
|||
Defines which template file should be used to render the login form for Protected pages using this model. This overrides the default, defined using ``PASSWORD_REQUIRED_TEMPLATE`` in your settings. See :ref:`private_pages`
|
||||
|
||||
|
||||
Tips
|
||||
~~~~
|
||||
|
||||
Friendly model names
|
||||
--------------------
|
||||
|
||||
Make your model names more friendly to users of Wagtail using Django's internal ``Meta`` class with a ``verbose_name`` e.g
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class HomePage(Page):
|
||||
...
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Homepage"
|
||||
|
||||
When users are given a choice of pages to create, the list of page types is generated by splitting your model names on each of their capital letters. Thus a ``HomePage`` model would be named "Home Page" which is a little clumsy. ``verbose_name`` as in the example above, would change this to read "Homepage" which is slightly more conventional.
|
||||
|
||||
The above example also ensures the name of the
|
||||
|
||||
Helpful model descriptions
|
||||
--------------------------
|
||||
|
||||
As your site becomes more complex users may require some prompting in deciding which content type to use when creating a new page. Developers can add a description to their Models by extending Django's internal model ``Meta`` class.
|
||||
|
||||
Insert the following once at the top of your ``models.py``:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import django.db.models.options as options
|
||||
options.DEFAULT_NAMES = options.DEFAULT_NAMES + ('description',)
|
||||
|
||||
|
||||
Then for each model as necessary, add a description option to the model ``Meta`` class
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class HomePage(Page):
|
||||
...
|
||||
|
||||
class Meta:
|
||||
description = "The top level homepage for your site"
|
||||
verbose_name = "Homepage"
|
||||
|
||||
|
||||
(This method can be used to extend the Model Meta class in various ways however Wagtail only supports the addition of a ``description`` option).
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
.. _editing-api:
|
||||
|
||||
Defining models with the Editing API
|
||||
Displaying fields with the Editing API
|
||||
====================================
|
||||
|
||||
.. note::
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ Bug fixes
|
|||
|
||||
* Page URL generation now returns correct URLs for sites that have the main 'serve' view rooted somewhere other than '/'.
|
||||
* Search results in the page chooser now respect the page_type parameter on PageChooserPanel.
|
||||
* Rendition filenames are now prevented from going over 60 chars, even with a large focal_point_key.
|
||||
|
||||
Upgrade considerations
|
||||
======================
|
||||
|
|
|
|||
|
|
@ -161,10 +161,9 @@ class AbstractImage(models.Model, TagSearchable):
|
|||
|
||||
input_filename_parts = os.path.basename(file_field.file.name).split('.')
|
||||
filename_without_extension = '.'.join(input_filename_parts[:-1])
|
||||
filename_without_extension = filename_without_extension[:60] # trim filename base so that we're well under 100 chars
|
||||
output_filename_parts = [filename_without_extension, focal_point_key, filter.spec] + input_filename_parts[-1:]
|
||||
output_filename = '.'.join(output_filename_parts)
|
||||
|
||||
extension = '.'.join([focal_point_key, filter.spec] + input_filename_parts[-1:])
|
||||
filename_without_extension = filename_without_extension[:(59-len(extension))] # Truncate filename to prevent it going over 60 chars
|
||||
output_filename = filename_without_extension + '.' + extension
|
||||
generated_image_file = File(generated_image, name=output_filename)
|
||||
|
||||
if self.focal_point:
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ from wagtail.tests.models import EventPage, EventPageCarouselItem
|
|||
from wagtail.wagtailcore.models import Page
|
||||
|
||||
|
||||
def get_test_image_file():
|
||||
def get_test_image_file(filename='test.png'):
|
||||
from six import BytesIO
|
||||
from PIL import Image
|
||||
from django.core.files.images import ImageFile
|
||||
|
|
@ -40,7 +40,7 @@ def get_test_image_file():
|
|||
f = BytesIO()
|
||||
image = Image.new('RGB', (640, 480), 'white')
|
||||
image.save(f, 'PNG')
|
||||
return ImageFile(f, name='test.png')
|
||||
return ImageFile(f, name=filename)
|
||||
|
||||
|
||||
Image = get_image_model()
|
||||
|
|
@ -1016,3 +1016,24 @@ class TestCropToPoint(TestCase):
|
|||
CropBox(125, 25, 275, 175),
|
||||
)
|
||||
|
||||
|
||||
class TestIssue573(TestCase):
|
||||
"""
|
||||
This tests for a bug which causes filename limit on Renditions to be reached
|
||||
when the Image has a long original filename and a big focal point key
|
||||
"""
|
||||
def test_issue_573(self):
|
||||
# Create an image with a big filename and focal point
|
||||
image = Image.objects.create(
|
||||
title="Test image",
|
||||
file=get_test_image_file('thisisaverylongfilename-abcdefghijklmnopqrstuvwxyz-supercalifragilisticexpialidocious.png'),
|
||||
focal_point_x=1000,
|
||||
focal_point_y=1000,
|
||||
focal_point_width=1000,
|
||||
focal_point_height=1000,
|
||||
)
|
||||
|
||||
# Try creating a rendition from that image
|
||||
# This would crash if the bug is present
|
||||
image.get_rendition('fill-800x600')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue