Skip to content

Allow creation of presets from existing install via Content Menu UI#634

Closed
misaochan wants to merge 7 commits intoiiab:wip-01from
misaochan:kolibri-part2
Closed

Allow creation of presets from existing install via Content Menu UI#634
misaochan wants to merge 7 commits intoiiab:wip-01from
misaochan:kolibri-part2

Conversation

@misaochan
Copy link
Copy Markdown
Contributor

@misaochan misaochan commented Mar 19, 2026

Part 2 (final part), closes #623 . Also resolves #624 and #626 . Tested multiple scenarios as seen below, running on VirtualBox with Ubuntu 24.04.4.

The Content Menu now has a "Create a Content Collection" panel that allows users to create a preset from their existing install, including Kolibri channels. All the fields in preset.json can be filled in, except for size_in_gb and last_modified, which are computed automatically.

image

Test scenario with successful creation and import

Clicking "Create" triggers mk-preset.py. For instance, in this test case I am creating a preset after downloading the PointB Kolibri channel.

image

In Install Content > Quick Pick, the user will then see their new preset in the list.

image

And when they import that preset, the PointB Kolibri channel "channel_id": "254f1b384c2551ed80ada423449212a1" is automatically downloaded.

image

Test scenario where the preset name filled in by the user is the same as a supplied preset name.

Creation of the preset is blocked.

image

Test scenario where the preset name filled in by the user is the same as an existing preset name, but NOT a supplied preset name.

A warning is shown and the user can choose to overwrite if desired.

image

@misaochan
Copy link
Copy Markdown
Contributor Author

@tim-moody Ready for review. :)

def get_kolibri_lang():
kolibri_db = '/library/kolibri/db.sqlite3'
conn = sqlite3.connect(kolibri_db)
cur = conn.execute('SELECT language_id FROM device_devicesettings LIMIT 1')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is per device and not per channel?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, per device.

@misaochan
Copy link
Copy Markdown
Contributor Author

Removed all the kalite empty objects in content.json and their references in install_presets(), and replaced kalite menu items with their kolibri counterparts as requested. Tested fr-school preset:

image

map_cmd_info = cmd_info
map_list = content['maps']
for map in map_list:
map_cmd_info = cmd_info
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes a pre-existing bug where the maps loop crashes if pseudo_cmd_handler returns None for any map entry. Noticed it because fr-school had multiple maps and I ran a re-installation.

@tim-moody
Copy link
Copy Markdown
Contributor

zim_list = content['zims']
module_list = content['modules'] # service is web server which is always installed
map_list = content['maps']
kalite_vars = content['kalite']

So is this problem there for all content types and removing kalite {} was a mistake?

@misaochan
Copy link
Copy Markdown
Contributor Author

So kalite_vars doesn't actually do anything now, which is why I removed it. The problem does exist for all content types though. It can be fixed by:

zim_list = content.get('zims', [])
module_list = content.get('modules', [])
map_list = content.get('maps', [])

Happy to add those to this PR as well if you want.

@tim-moody
Copy link
Copy Markdown
Contributor

go ahead and make those changes

@misaochan
Copy link
Copy Markdown
Contributor Author

@tim-moody All done. Tested by installing en-school, which has quite a few ZIMs, all jobs scheduled successfully.

@tim-moody
Copy link
Copy Markdown
Contributor

merged against master

@tim-moody tim-moody closed this Mar 26, 2026
@holta holta mentioned this pull request Mar 26, 2026
@misaochan
Copy link
Copy Markdown
Contributor Author

Thanks for merge! Can we close the related issues? #623 #624 #626 The automatic closure via PR doesn't work as the master merge was done directly from my branch instead of from the PR.

@tim-moody
Copy link
Copy Markdown
Contributor

tim-moody commented Mar 26, 2026 via email

@misaochan
Copy link
Copy Markdown
Contributor Author

Haha all good! Yeah, I'll submit my future PRs to master. :)

@tim-moody
Copy link
Copy Markdown
Contributor

tim-moody commented Mar 26, 2026 via email

@misaochan
Copy link
Copy Markdown
Contributor Author

You should have everything, I think - I can see that my whole branch was merged in. I'll let you know if I find any issues.

@misaochan
Copy link
Copy Markdown
Contributor Author

Oh, I don't have permissions to close the issues btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants