diff --git a/changelog.d/20230502_090803_regis_palm.md b/changelog.d/20230502_090803_regis_palm.md new file mode 100644 index 0000000..3a11606 --- /dev/null +++ b/changelog.d/20230502_090803_regis_palm.md @@ -0,0 +1,2 @@ +- [Feature] Add the `do importdemocourse --repo-dir=...` option, to import courses from subdirectories of git repositories. This allows us to import the openedx-test-course in Palm with: `tutor local do importdemocourse --repo=https://github.com/openedx/openedx-test-course --version=o +pen-release/palm.master --repo-dir=test-course/course`. (by @regisb) diff --git a/tutor/commands/jobs.py b/tutor/commands/jobs.py index 22de90c..8e694fc 100644 --- a/tutor/commands/jobs.py +++ b/tutor/commands/jobs.py @@ -146,19 +146,26 @@ u.save()" show_default=True, help="Git repository that contains the course to be imported", ) +@click.option( + "-d", + "--repo-dir", + default="", + show_default=True, + help="Git relative subdirectory to import data from", +) @click.option( "-v", "--version", help="Git branch, tag or sha1 identifier. If unspecified, will default to the value of the OPENEDX_COMMON_VERSION setting.", ) def importdemocourse( - repo: str, version: t.Optional[str] + repo: str, repo_dir: str, version: t.Optional[str] ) -> t.Iterable[tuple[str, str]]: version = version or "{{ OPENEDX_COMMON_VERSION }}" template = f""" # Import demo course git clone {repo} --branch {version} --depth 1 /tmp/course -python ./manage.py cms import ../data /tmp/course +python ./manage.py cms import ../data /tmp/course/{repo_dir} # Re-index courses ./manage.py cms reindex_course --all --setup"""