Skip to content

Commit

Permalink
Add null pk back, force to false
Browse files Browse the repository at this point in the history
  • Loading branch information
berkalpyakici committed Jul 3, 2019
1 parent e9565d6 commit ef6c3e2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="wagtail-import-export-tool",
version="0.9.4",
version="0.9.5",
author="Berk Alp Yakici",
author_email="[email protected]",
description="Import/Export tool for Wagtail CMS (built on top of Django), that supports pages, images, documents, and snippets.",
Expand Down
8 changes: 8 additions & 0 deletions wagtailimportexport/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ class ExportPage(forms.Form):
help_text=_("If True, unpublished pages will be exported along with published pages."),
)

null_pk = forms.BooleanField(
widget=forms.HiddenInput(),
required = False,
initial=False,
label=_("Remove Primary Keys"),
help_text=_("This is set to False as default and can be changed in code. Changing to True may break import functionality."),
)

null_fk = forms.BooleanField(
initial=True,
required=False,
Expand Down
8 changes: 6 additions & 2 deletions wagtailimportexport/importing.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from wagtailimportexport import functions


def import_page(uploaded_archive, parent_page):
def import_page(uploaded_archive, parent_page, overwrites = {}):
"""
Imports uploaded_archive as children of parent_page.
Expand Down Expand Up @@ -55,7 +55,7 @@ def import_page(uploaded_archive, parent_page):
contents_mapping = functions.unzip_contents(zf)

# Get the list of pages to skip.
existing_pages = list_existing_pages(contents)
existing_pages = list_existing_pages(contents) if not overwrites else []

# Dictionaries to store original paths.
pages_by_original_path = {}
Expand Down Expand Up @@ -106,6 +106,10 @@ def import_page(uploaded_archive, parent_page):
for (field, new_value) in new_field_datas.items():
page_record['content'][field] = new_value

# Misc. overwrites
for (field, new_value) in overwrites.items():
page_record['content'][field] = new_value

# Create page instance.
page = Page.from_serializable_data(page_record['content'])

Expand Down

0 comments on commit ef6c3e2

Please sign in to comment.