Skip to content

Commit

Permalink
fix #5502 (#5508)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedie authored and czpython committed Sep 6, 2016
1 parent ed72cf7 commit e897ba0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
parent to a published page.
* Fixed a bug where moving a published page under a page marked as pending publishing
is left as published instead of being marked as pending publishing.
* Fixed AttributeError when using ``create_page`` in management command


=== 3.3.2 (2016-08-11) ===
Expand Down
15 changes: 7 additions & 8 deletions cms/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,6 @@ def create_page(title, template, language, menu_title=None, slug=None,
if with_revision in (True, False):
_raise_revision_warning()

# ugly permissions hack
if created_by and isinstance(created_by, get_user_model()):
_thread_locals.user = created_by

created_by = getattr(created_by, get_user_model().USERNAME_FIELD)
else:
_thread_locals.user = None

# validate template
if not template == TEMPLATE_INHERITANCE_MAGIC:
assert template in [tpl[0] for tpl in get_cms_setting('TEMPLATES')]
Expand Down Expand Up @@ -205,6 +197,13 @@ def create_page(title, template, language, menu_title=None, slug=None,
else:
application_urls = None

# ugly permissions hack
if created_by and isinstance(created_by, get_user_model()):
_thread_locals.user = created_by
created_by = getattr(created_by, get_user_model().USERNAME_FIELD)
else:
_thread_locals.user = None

if reverse_id:
if Page.objects.drafts().filter(reverse_id=reverse_id, site=site).exists():
raise FieldError('A page with the reverse_id="%s" already exist.' % reverse_id)
Expand Down

0 comments on commit e897ba0

Please sign in to comment.