feat: `importdemocourse --repo-dir=...` option

This allows us to run:

    tutor local do importdemocourse --repo=https://github.com/openedx/openedx-test-course --version=open-release/palm.master --repo-dir=test-course/course
This commit is contained in:
Régis Behmo 2023-05-02 09:09:17 +02:00
parent b3c3c4a2cc
commit 6dbb5baf81
2 changed files with 11 additions and 2 deletions

View File

@ -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)

View File

@ -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"""