From 0fb9bfe008362fddfb2e0ebd26a4d9cf246c4390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Thu, 5 Dec 2019 11:45:09 +0100 Subject: [PATCH] Get rid of the `indexcourses` command This command adds a burden on the `local` and `k8s` command. It does not make sense to provide this command out of the box, and not other administration commands. Instead, we should better document how to run regular `manage.py` commands from tutor. Close #269. --- CHANGELOG.md | 4 ++++ docs/local.rst | 13 ++++++++----- tutor/commands/k8s.py | 11 ----------- tutor/commands/local.py | 11 ----------- tutor/scripts.py | 4 ---- tutor/templates/hooks/cms/importdemocourse | 4 ++++ tutor/templates/hooks/cms/indexcourses | 4 ---- 7 files changed, 16 insertions(+), 35 deletions(-) delete mode 100644 tutor/templates/hooks/cms/indexcourses diff --git a/CHANGELOG.md b/CHANGELOG.md index dc09df1..c25df74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ Note: Breaking changes between versions are indicated by "💥". +## Unreleased + +- 💥[Improvement] Get rid of the `indexcourses` command (#269) + ## 3.8.0 (2019-11-22) - [Improvement] Add `k8s-deployments-nginx-volume-mounts` patch diff --git a/docs/local.rst b/docs/local.rst index 01464fc..80c3515 100644 --- a/docs/local.rst +++ b/docs/local.rst @@ -108,14 +108,17 @@ After a fresh installation, your platform will not have a single course. To impo tutor local importdemocourse -Updating the course search index -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Running arbitrary ``manage.py`` commands +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The course search index can be updated with:: +Any ``./manage.py`` command provided by Open edX can be run in a local platform deployed with Tutor. For instance, to delete a course, run:: + + tutor local run cms ./manage.py cms delete_course - tutor local indexcourses +To update the course search index, run:: -Run this command periodically to ensure that course search results are always up-to-date. + # Run this command periodically to ensure that course search results are always up-to-date. + tutor local run cms ./manage.py cms reindex_course --all --setup .. _portainer: diff --git a/tutor/commands/k8s.py b/tutor/commands/k8s.py index defb06c..2cbd33d 100644 --- a/tutor/commands/k8s.py +++ b/tutor/commands/k8s.py @@ -139,16 +139,6 @@ def importdemocourse(root): config = tutor_config.load(root) runner = K8sScriptRunner(root, config) scripts.import_demo_course(runner) - fmt.echo_info("Re-indexing courses") - indexcourses.callback(root) - - -@click.command(help="Re-index courses for better searching") -@opts.root -def indexcourses(root): - config = tutor_config.load(root) - runner = K8sScriptRunner(root, config) - scripts.index_courses(runner) @click.command(name="exec", help="Execute a command in a pod of the given application") @@ -237,6 +227,5 @@ k8s.add_command(delete) k8s.add_command(init) k8s.add_command(createuser) k8s.add_command(importdemocourse) -k8s.add_command(indexcourses) k8s.add_command(exec_command) k8s.add_command(logs) diff --git a/tutor/commands/local.py b/tutor/commands/local.py index cc8cb6e..553c392 100644 --- a/tutor/commands/local.py +++ b/tutor/commands/local.py @@ -314,16 +314,6 @@ def importdemocourse(root): runner = ScriptRunner(root, config) fmt.echo_info("Importing demo course") scripts.import_demo_course(runner) - fmt.echo_info("Re-indexing courses") - indexcourses.callback(root) - - -@click.command(help="Re-index courses for better searching") -@opts.root -def indexcourses(root): - config = tutor_config.load(root) - runner = ScriptRunner(root, config) - scripts.index_courses(runner) @click.command( @@ -381,5 +371,4 @@ local.add_command(https) local.add_command(logs) local.add_command(createuser) local.add_command(importdemocourse) -local.add_command(indexcourses) local.add_command(portainer) diff --git a/tutor/scripts.py b/tutor/scripts.py index f7ec985..3776f0a 100644 --- a/tutor/scripts.py +++ b/tutor/scripts.py @@ -88,7 +88,3 @@ def import_demo_course(runner): runner.check_service_is_activated("cms") runner.run("cms", "hooks", "cms", "importdemocourse") - -def index_courses(runner): - runner.check_service_is_activated("cms") - runner.run("cms", "hooks", "cms", "indexcourses") diff --git a/tutor/templates/hooks/cms/importdemocourse b/tutor/templates/hooks/cms/importdemocourse index d36b325..07f3d1f 100644 --- a/tutor/templates/hooks/cms/importdemocourse +++ b/tutor/templates/hooks/cms/importdemocourse @@ -1,5 +1,9 @@ export DJANGO_SETTINGS_MODULE=$SERVICE_VARIANT.envs.$SETTINGS echo "Loading settings $DJANGO_SETTINGS_MODULE" +# Import demo course git clone https://github.com/edx/edx-demo-course --branch open-release/ironwood.2 --depth 1 ../edx-demo-course python ./manage.py cms import ../data ../edx-demo-course + +# Re-index courses +./manage.py cms reindex_course --all --setup diff --git a/tutor/templates/hooks/cms/indexcourses b/tutor/templates/hooks/cms/indexcourses deleted file mode 100644 index 3ebfcd3..0000000 --- a/tutor/templates/hooks/cms/indexcourses +++ /dev/null @@ -1,4 +0,0 @@ -export DJANGO_SETTINGS_MODULE=$SERVICE_VARIANT.envs.$SETTINGS -echo "Loading settings $DJANGO_SETTINGS_MODULE" - -./manage.py cms reindex_course --all --setup