1
0
Fork 0
forked from github/pelican

Merge pull request #2455 from oulenz/static_content

Disinherit Page from Static so default draft status does not affect save_as
This commit is contained in:
Justin Mayer 2018-11-20 15:34:27 -06:00 committed by GitHub
commit a0c0816191
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View file

@ -527,7 +527,11 @@ class Article(Content):
@python_2_unicode_compatible
class Static(Page):
class Static(Content):
mandatory_properties = ('title',)
default_status = 'published'
default_template = None
def __init__(self, *args, **kwargs):
super(Static, self).__init__(*args, **kwargs)
self._output_location_referenced = False

View file

@ -917,3 +917,18 @@ class TestStatic(LoggedTestCase):
self.settings['INDEX_SAVE_AS'])) +
'">link</a>')
self.assertEqual(content, expected_html)
def test_not_save_as_draft(self):
"""Static.save_as is not affected by draft status."""
static = Static(
content=None,
metadata=dict(status='draft',),
settings=self.settings,
source_path=os.path.join('dir', 'foo.jpg'),
context=self.settings.copy())
expected_save_as = os.path.join('dir', 'foo.jpg')
self.assertEqual(static.status, 'draft')
self.assertEqual(static.save_as, expected_save_as)
self.assertEqual(static.url, path_to_url(expected_save_as))