Skip to content

fix(git-auto-export): Start export only if GIT_URL exists in the course settings #495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ol_openedx_git_auto_export/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ python_distribution(
dependencies=[":git_auto_export"],
provides=setup_py(
name="ol-openedx-git-auto-export",
version="0.3.1",
version="0.3.2",
license="BSD-3-Clause",
description="A plugin that auto saves the course OLX to git when an author publishes it",
entry_points={
Expand Down
2 changes: 1 addition & 1 deletion src/ol_openedx_git_auto_export/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

def plugin_settings(settings):
"""Settings for the git auto export plugin.""" # noqa: D401
settings.GIT_REPO_EXPORT_DIR = "/edx/var/edxapp/export_course_repos"
settings.GIT_REPO_EXPORT_DIR = "/openedx/export_course_repos"
settings.FEATURES[ENABLE_GIT_AUTO_EXPORT] = True
2 changes: 1 addition & 1 deletion src/ol_openedx_git_auto_export/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

def plugin_settings(settings):
"""Settings for the git auto export plugin.""" # noqa: D401
settings.GIT_REPO_EXPORT_DIR = "/edx/var/edxapp/export_course_repos"
settings.GIT_REPO_EXPORT_DIR = "/openedx/export_course_repos"
settings.FEATURES[ENABLE_GIT_AUTO_EXPORT] = True
11 changes: 9 additions & 2 deletions src/ol_openedx_git_auto_export/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.dispatch import receiver
from ol_openedx_git_auto_export.constants import ENABLE_GIT_AUTO_EXPORT
from ol_openedx_git_auto_export.tasks import async_export_to_git
from xmodule.modulestore.django import SignalHandler
from xmodule.modulestore.django import SignalHandler, modulestore

log = logging.getLogger(__name__)

Expand All @@ -20,7 +20,7 @@ def listen_for_course_publish(
Receives publishing signal and performs publishing related workflows
"""
git_repo_export_dir = getattr(
settings, "GIT_REPO_EXPORT_DIR", "/edx/var/edxapp/export_course_repos"
settings, "GIT_REPO_EXPORT_DIR", "/openedx/export_course_repos"
)
if not os.path.exists(git_repo_export_dir): # noqa: PTH110
# for development/docker/vagrant if GIT_REPO_EXPORT_DIR folder does not exist then create it # noqa: E501
Expand All @@ -32,6 +32,13 @@ def listen_for_course_publish(
if settings.FEATURES.get("ENABLE_EXPORT_GIT") and settings.FEATURES.get(
ENABLE_GIT_AUTO_EXPORT
):
course_module = modulestore().get_course(course_key)
if not course_module.giturl:
log.info(
"Course %s does not have a GIT URL set in course advance settings, skipping export.", # noqa: E501
course_module.id,
)
return
# If the Git auto-export is enabled, push the course changes to Git
log.info(
"Course published with auto-export enabled. Starting export... (course id: %s)", # noqa: E501
Expand Down
Loading