def create_content_database(channel, force, user_id, force_exercises, task_object=None): # increment the channel version if not force: raise_if_nodes_are_all_unchanged(channel) fh, tempdb = tempfile.mkstemp(suffix=".sqlite3") with using_content_database(tempdb): channel.main_tree.publishing = True channel.main_tree.save() prepare_export_database(tempdb) if task_object: task_object.update_state(state='STARTED', meta={'progress': 10.0}) map_channel_to_kolibri_channel(channel) map_content_nodes(channel.main_tree, channel.language, channel.id, channel.name, user_id=user_id, force_exercises=force_exercises, task_object=task_object, starting_percent=10.0) # It should be at this percent already, but just in case. if task_object: task_object.update_state(state='STARTED', meta={'progress': 90.0}) map_prerequisites(channel.main_tree) save_export_database(channel.pk) return tempdb
def create_content_database(channel_id, force, user_id, force_exercises): channel = ccmodels.Channel.objects.get(pk=channel_id) # increment the channel version if not force: raise_if_nodes_are_all_unchanged(channel) fh, tempdb = tempfile.mkstemp(suffix=".sqlite3") with using_content_database(tempdb): channel.main_tree.publishing = True channel.main_tree.save() prepare_export_database(tempdb) map_channel_to_kolibri_channel(channel) map_content_nodes(channel.main_tree, channel.language, channel.id, channel.name, user_id=user_id, force_exercises=force_exercises) map_prerequisites(channel.main_tree) save_export_database(channel_id)