-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hierarchical export/import to server, single json per item. Moving and deletion allowed #225
base: main
Are you sure you want to change the base?
Conversation
This reverts commit d0535c2.
- Adds hierarchycal content export/import. A folder structure will be created and a json file per item. This will allow to keep track of changes for each item. Also allow to move o delete content. - Some fixes for spanish translations - Modifies import_content and export_content templates to include boostrap classes and change checkboxes to switches. ### Export Content A new checkbox has been added to allow hierarchical export to server. Will generate a tree export with one json per item. For folders content a subdirectory will be added containing children. Added bootstrap css classes and redesigned checkbox into switches. The generated exported tree will contain a subdirectory for the exported site with two main directories: `content` and `removed_items` exported_tree/ └── Plone ├── content │ ├── 11_registration.json │ ├── 12_schedule.json │ ├── 19_sprint.json │ ├── 1_contact.json │ ├── 20_test1.json │ ├── 2_events.json │ ├── 6_intranet.json │ ├── 7_location-1.json │ ├── 8_news.json │ ├── contact │ ├── events │ │ ├── 3_deadline-for-talk-submission.json │ │ ├── 5_second-event-in-events-folder.json │ │ ├── deadline-for-talk-submission │ │ │ └── 4_00b2dcca-4e95-4feb-bf83-3789000a017f_1_105_c.jpeg.json │ │ └── second-event-in-events-folder │ ├── intranet │ │ ├── 13_sponsors.json │ │ ├── sponsors │ │ ├── 15_training.json │ │ ├── training │ │ ├── 16_00b2dcca-4e95-4feb-bf83-3789000a017f_1_105_c.jpeg.json │ │ ├── 17_document-third-level-inside-training.json │ │ └── document-third-level-inside-training │ │ └── 18_00b2dcca-4e95-4feb-bf83-3789000a017f_1_105_c.jpeg.json │ ├── location-1 │ ├── news │ │ ├── 10_submit-your-talks.json │ │ ├── 9_conference-website-online.json │ │ ├── conference-website-online │ │ └── submit-your-talks │ ├── registration │ ├── schedule │ ├── sprint │ └── test1 └── removed_items └── 14_00b2dcca-4e95-4feb-bf83-3789000a017f_1_105_c.jpeg.json ### Import Content Redesigned form with bootstrap css classes, added fieldsets to separate type of imports. A new fieldset added for the hierarchical import where you can select the server path to the `exported_tree` ### Moving content Non folderish item can be moved by just changing the location of the json file. Folderish object can be moved by changing the location of both json file and subdirectory. ### Reordering Exported json files names include the ordinal number of the original order. At the moment, no further reordering system has been implemented. ### Marking content as deleted Moving json files to `removed_items`will mark them as deleted. In an update import, where site has content, that item will be removed. **Disclaimer: this will be remove the item without taking care of link integrity**
@pbauer @fredvd @davisagli |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I know little about exportimport inner parts, I won't issue an official approval.
However, LGTM.
In @kitconcept/contentcreator we used the approach of using a dotted file, but the folder tree approach seems to me like an improvement.
Question: Which id
takes precedence, the one in the filename or the one in the id
attribute in the JSON file? (in case of discordance).
I'd love to see this merged soon! Thanks for the effort!
PS: @pbauer how about the PoC that you showed in the PC lightning talk? I guess this supersedes it, right?
@sneridagh the filename is ignored and the process does not modify any file content. So the answer should be both the The filename is composed by the order number and the object id. The latter with the intention of make it easier reading the files in the exported tree. Once the importer reads the json file it will modify the parent The original import process will update the I hope I have explained myself... if json_file.parent == Path(os.path.join(self.path, parents)):
yield item
else:
parent_obj = api.content.get(path=parent_path)
if not parent_obj:
# if parent_path is "." or parent_obj doesn't yet exist
parent_obj = portal
# Modify parent data into json to be yield
# local files won't be modified
if parent_obj:
self.delete_old_if_moved(item.get("UID"))
item["@id"] = item.get("@id")
json_parent.update(
{"@id": parent_obj.absolute_url(), "UID": parent_obj.UID()}
)
item["parent"] = json_parent
yield item |
Adds hierarchycal content export/import. A folder structure will be created and a json file per item.
This will allow to keep track of changes for each item. Also allow to move o delete content.
Some fixes for spanish translations
Modifies import_content and export_content templates to include boostrap classes and change checkboxes to switches.
Export Content
A new checkbox has been added to allow hierarchical export to server. Will generate a tree export with one json per item. For folders content a subdirectory will be added containing children.
Added bootstrap css classes and redesigned checkbox into switches.
The generated exported tree will contain a subdirectory for the exported site with two main directories:
content
andremoved_items
exported_tree/
└── Plone
├── content
│ ├── 11_registration.json
│ ├── 12_schedule.json
│ ├── 19_sprint.json
│ ├── 1_contact.json
│ ├── 20_test1.json
│ ├── 2_events.json
│ ├── 6_intranet.json
│ ├── 7_location-1.json
│ ├── 8_news.json
│ ├── contact
│ ├── events
│ │ ├── 3_deadline-for-talk-submission.json
│ │ ├── 5_second-event-in-events-folder.json
│ │ ├── deadline-for-talk-submission
│ │ │ └── 4_00b2dcca-4e95-4feb-bf83-3789000a017f_1_105_c.jpeg.json
│ │ └── second-event-in-events-folder
│ ├── intranet
│ │ ├── 13_sponsors.json
│ │ ├── sponsors
│ │ ├── 15_training.json
│ │ ├── training
│ │ ├── 16_00b2dcca-4e95-4feb-bf83-3789000a017f_1_105_c.jpeg.json
│ │ ├── 17_document-third-level-inside-training.json
│ │ └── document-third-level-inside-training
│ │ └── 18_00b2dcca-4e95-4feb-bf83-3789000a017f_1_105_c.jpeg.json
│ ├── location-1
│ ├── news
│ │ ├── 10_submit-your-talks.json
│ │ ├── 9_conference-website-online.json
│ │ ├── conference-website-online
│ │ └── submit-your-talks
│ ├── registration
│ ├── schedule
│ ├── sprint
│ └── test1
└── removed_items
└── 14_00b2dcca-4e95-4feb-bf83-3789000a017f_1_105_c.jpeg.json
Import Content
Redesigned form with bootstrap css classes, added fieldsets to separate type of imports.
A new fieldset added for the hierarchical import where you can select the server path to the
exported_tree
Moving content
Non folderish item can be moved by just changing the location of the json file.
Folderish object can be moved by changing the location of both json file and subdirectory.
Reordering
Exported json files names include the ordinal number of the original order. At the moment, no further reordering system has been implemented.
Marking content as deleted
Moving json files to
removed_items
will mark them as deleted. In an update import, where site has content, that item will be removed.Disclaimer: this will be remove the item without taking care of link integrity