ol-openedx-git-auto-export 0.4.0__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. ol_openedx_git_auto_export-0.5.0/.gitignore +14 -0
  2. ol_openedx_git_auto_export-0.5.0/LICENSE +28 -0
  3. ol_openedx_git_auto_export-0.5.0/PKG-INFO +68 -0
  4. ol_openedx_git_auto_export-0.5.0/README.rst +52 -0
  5. {ol-openedx-git-auto-export-0.4.0 → ol_openedx_git_auto_export-0.5.0}/ol_openedx_git_auto_export/signals.py +17 -15
  6. ol_openedx_git_auto_export-0.5.0/ol_openedx_git_auto_export/utils.py +21 -0
  7. ol_openedx_git_auto_export-0.5.0/pyproject.toml +43 -0
  8. ol-openedx-git-auto-export-0.4.0/MANIFEST.in +0 -1
  9. ol-openedx-git-auto-export-0.4.0/PKG-INFO +0 -6
  10. ol-openedx-git-auto-export-0.4.0/backend_shim.py +0 -31
  11. ol-openedx-git-auto-export-0.4.0/ol_openedx_git_auto_export/settings/__init__.py +0 -0
  12. ol-openedx-git-auto-export-0.4.0/ol_openedx_git_auto_export.egg-info/PKG-INFO +0 -6
  13. ol-openedx-git-auto-export-0.4.0/ol_openedx_git_auto_export.egg-info/SOURCES.txt +0 -19
  14. ol-openedx-git-auto-export-0.4.0/ol_openedx_git_auto_export.egg-info/dependency_links.txt +0 -1
  15. ol-openedx-git-auto-export-0.4.0/ol_openedx_git_auto_export.egg-info/entry_points.txt +0 -2
  16. ol-openedx-git-auto-export-0.4.0/ol_openedx_git_auto_export.egg-info/namespace_packages.txt +0 -1
  17. ol-openedx-git-auto-export-0.4.0/ol_openedx_git_auto_export.egg-info/requires.txt +0 -4
  18. ol-openedx-git-auto-export-0.4.0/ol_openedx_git_auto_export.egg-info/top_level.txt +0 -2
  19. ol-openedx-git-auto-export-0.4.0/setup.cfg +0 -4
  20. ol-openedx-git-auto-export-0.4.0/setup.py +0 -33
  21. {ol-openedx-git-auto-export-0.4.0 → ol_openedx_git_auto_export-0.5.0}/ol_openedx_git_auto_export/__init__.py +0 -0
  22. {ol-openedx-git-auto-export-0.4.0 → ol_openedx_git_auto_export-0.5.0}/ol_openedx_git_auto_export/app.py +0 -0
  23. {ol-openedx-git-auto-export-0.4.0 → ol_openedx_git_auto_export-0.5.0}/ol_openedx_git_auto_export/constants.py +0 -0
  24. {ol-openedx-git-auto-export-0.4.0 → ol_openedx_git_auto_export-0.5.0/ol_openedx_git_auto_export/settings}/__init__.py +0 -0
  25. {ol-openedx-git-auto-export-0.4.0 → ol_openedx_git_auto_export-0.5.0}/ol_openedx_git_auto_export/settings/common.py +0 -0
  26. {ol-openedx-git-auto-export-0.4.0 → ol_openedx_git_auto_export-0.5.0}/ol_openedx_git_auto_export/settings/production.py +0 -0
  27. {ol-openedx-git-auto-export-0.4.0 → ol_openedx_git_auto_export-0.5.0}/ol_openedx_git_auto_export/tasks.py +0 -0
@@ -0,0 +1,14 @@
1
+ # Build artifacts
2
+ /dist/
3
+ /.pids
4
+ # Python files
5
+ /.venv/
6
+ /.idea/
7
+ __pycache__/
8
+ *.egg-info/
9
+ *.DS_Store
10
+ # Test Runtime
11
+ ol_test_requirements.txt
12
+ **/.coverage
13
+ **/test_root
14
+ coverage.xml
@@ -0,0 +1,28 @@
1
+ Copyright (C) 2022 MIT Open Learning
2
+
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ * Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ * Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ * Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,68 @@
1
+ Metadata-Version: 2.4
2
+ Name: ol-openedx-git-auto-export
3
+ Version: 0.5.0
4
+ Summary: A plugin that auto saves the course OLX to git when an author publishes it
5
+ Author: MIT Office of Digital Learning
6
+ License-Expression: BSD-3-Clause
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.11
9
+ Requires-Dist: celery>=4.4.7
10
+ Requires-Dist: django>2.0
11
+ Requires-Dist: edx-django-utils>4.0.0
12
+ Requires-Dist: edx-opaque-keys
13
+ Requires-Dist: gitpython>=3.1.37
14
+ Requires-Dist: openedx-events
15
+ Description-Content-Type: text/x-rst
16
+
17
+ Git Auto Export Plugin
18
+ ######################
19
+
20
+ Installation
21
+ ============
22
+
23
+ For detailed installation instructions, please refer to the `plugin installation guide <../../docs#installation-guide>`_.
24
+
25
+ Installation required in:
26
+
27
+ * Studio (CMS)
28
+
29
+ Configuration
30
+ =============
31
+
32
+ - Enable the following FEATURES flags in the config file in Open edX. For any release after Juniper, that config file is ``/edx/etc/cms.yml``. If you're using ``private.py``, you will need to enable these FEATURES in ``cms/envs/private.py``.
33
+
34
+ .. code-block::
35
+
36
+ "FEATURES": {
37
+ "ENABLE_EXPORT_GIT": true,
38
+ }
39
+
40
+ - Set your commit user in ``cms/envs/common.py``, if you don't want to use the default one
41
+
42
+ .. code-block::
43
+
44
+ GIT_EXPORT_DEFAULT_IDENT = {
45
+ 'name': 'STUDIO_EXPORT_TO_GIT',
46
+ 'email': 'STUDIO_EXPORT_TO_GIT@example.com'
47
+ }
48
+
49
+ - Restart the server using ``make studio-restart`` on Devstack or ``tutor dev/local restart openedx`` on Tutor.
50
+ - For Tutor installations, these values can also be managed through a `custom tutor plugin <https://docs.tutor.edly.io/tutorials/plugin.html#plugin-development-tutorial>`_.
51
+
52
+ Setup github authentication for plugin
53
+ ---------------------------------------
54
+ If you're testing from a docker machine running devstack setup github authentictaion for plugin, you'll need to generate SSH keys in that
55
+ machine and add them to your Github account
56
+ (https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/ -
57
+ https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account)
58
+
59
+ Studio/CMS UI settings
60
+ ----------------------
61
+ - Open studio then course and go to advanced settings.
62
+ - Choose field GIT URL and add you OLX git repo. For example ``git@github.com:<GITHUB_USERNAME>/edx4edxlite.git``.
63
+ - Make a change to the course content and publish.
64
+ - When using Tutor, attach with the CMS container using ``tutor dev/local start cms`` and enter ``yes`` to the prompt to add the GitHub to known hosts.
65
+ - You should see a new commit in your OLX repo.
66
+ - Commit user should be the one that published the change.
67
+ - If user is not available, it should be the default one set in ``GIT_EXPORT_DEFAULT_IDENT``.
68
+ - Test commit count increase on your OLX repo.
@@ -0,0 +1,52 @@
1
+ Git Auto Export Plugin
2
+ ######################
3
+
4
+ Installation
5
+ ============
6
+
7
+ For detailed installation instructions, please refer to the `plugin installation guide <../../docs#installation-guide>`_.
8
+
9
+ Installation required in:
10
+
11
+ * Studio (CMS)
12
+
13
+ Configuration
14
+ =============
15
+
16
+ - Enable the following FEATURES flags in the config file in Open edX. For any release after Juniper, that config file is ``/edx/etc/cms.yml``. If you're using ``private.py``, you will need to enable these FEATURES in ``cms/envs/private.py``.
17
+
18
+ .. code-block::
19
+
20
+ "FEATURES": {
21
+ "ENABLE_EXPORT_GIT": true,
22
+ }
23
+
24
+ - Set your commit user in ``cms/envs/common.py``, if you don't want to use the default one
25
+
26
+ .. code-block::
27
+
28
+ GIT_EXPORT_DEFAULT_IDENT = {
29
+ 'name': 'STUDIO_EXPORT_TO_GIT',
30
+ 'email': 'STUDIO_EXPORT_TO_GIT@example.com'
31
+ }
32
+
33
+ - Restart the server using ``make studio-restart`` on Devstack or ``tutor dev/local restart openedx`` on Tutor.
34
+ - For Tutor installations, these values can also be managed through a `custom tutor plugin <https://docs.tutor.edly.io/tutorials/plugin.html#plugin-development-tutorial>`_.
35
+
36
+ Setup github authentication for plugin
37
+ ---------------------------------------
38
+ If you're testing from a docker machine running devstack setup github authentictaion for plugin, you'll need to generate SSH keys in that
39
+ machine and add them to your Github account
40
+ (https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/ -
41
+ https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account)
42
+
43
+ Studio/CMS UI settings
44
+ ----------------------
45
+ - Open studio then course and go to advanced settings.
46
+ - Choose field GIT URL and add you OLX git repo. For example ``git@github.com:<GITHUB_USERNAME>/edx4edxlite.git``.
47
+ - Make a change to the course content and publish.
48
+ - When using Tutor, attach with the CMS container using ``tutor dev/local start cms`` and enter ``yes`` to the prompt to add the GitHub to known hosts.
49
+ - You should see a new commit in your OLX repo.
50
+ - Commit user should be the one that published the change.
51
+ - If user is not available, it should be the default one set in ``GIT_EXPORT_DEFAULT_IDENT``.
52
+ - Test commit count increase on your OLX repo.
@@ -2,16 +2,15 @@ import logging
2
2
  import os
3
3
 
4
4
  from django.conf import settings
5
- from django.dispatch import receiver
6
- from xmodule.modulestore.django import SignalHandler, modulestore
5
+ from xmodule.modulestore.django import modulestore
7
6
 
8
7
  from ol_openedx_git_auto_export.constants import ENABLE_GIT_AUTO_EXPORT
9
8
  from ol_openedx_git_auto_export.tasks import async_export_to_git
9
+ from ol_openedx_git_auto_export.utils import get_publisher_username
10
10
 
11
11
  log = logging.getLogger(__name__)
12
12
 
13
13
 
14
- @receiver(SignalHandler.course_published)
15
14
  def listen_for_course_publish(
16
15
  sender, # noqa: ARG001
17
16
  course_key,
@@ -20,16 +19,6 @@ def listen_for_course_publish(
20
19
  """
21
20
  Receives publishing signal and performs publishing related workflows
22
21
  """
23
- git_repo_export_dir = getattr(
24
- settings, "GIT_REPO_EXPORT_DIR", "/openedx/export_course_repos"
25
- )
26
- if not os.path.exists(git_repo_export_dir): # noqa: PTH110
27
- # for development/docker/vagrant if GIT_REPO_EXPORT_DIR folder does not exist then create it # noqa: E501
28
- log.error(
29
- "GIT_REPO_EXPORT_DIR is not available in settings, please create it first"
30
- )
31
- os.makedirs(git_repo_export_dir, 0o755) # noqa: PTH103
32
-
33
22
  if settings.FEATURES.get("ENABLE_EXPORT_GIT") and settings.FEATURES.get(
34
23
  ENABLE_GIT_AUTO_EXPORT
35
24
  ):
@@ -40,9 +29,22 @@ def listen_for_course_publish(
40
29
  course_module.id,
41
30
  )
42
31
  return
43
- # If the Git auto-export is enabled, push the course changes to Git
32
+
33
+ git_repo_export_dir = getattr(
34
+ settings, "GIT_REPO_EXPORT_DIR", "/openedx/export_course_repos"
35
+ )
36
+ if not os.path.exists(git_repo_export_dir): # noqa: PTH110
37
+ # for development/docker/vagrant if GIT_REPO_EXPORT_DIR folder does not exist then create it # noqa: E501
38
+ log.error(
39
+ "GIT_REPO_EXPORT_DIR is not available in settings, please create it first" # noqa: E501
40
+ )
41
+ os.makedirs(git_repo_export_dir, 0o755) # noqa: PTH103
42
+
44
43
  log.info(
45
44
  "Course published with auto-export enabled. Starting export... (course id: %s)", # noqa: E501
46
45
  course_key,
47
46
  )
48
- async_export_to_git.delay(str(course_key))
47
+
48
+ user = get_publisher_username(course_module)
49
+ # If the Git auto-export is enabled, push the course changes to Git
50
+ async_export_to_git.delay(str(course_key), user)
@@ -0,0 +1,21 @@
1
+ """
2
+ Utility functions for the ol_openedx_git_auto_export app.
3
+ """
4
+
5
+ from django.contrib.auth.models import User
6
+
7
+
8
+ def get_publisher_username(course_module):
9
+ """
10
+ Return the username of the user who published the course.
11
+ If the user cannot be found, returns None.
12
+ """
13
+ if not course_module:
14
+ return None
15
+
16
+ user_id = getattr(course_module, "published_by", None)
17
+ if not user_id:
18
+ return None
19
+
20
+ user = User.objects.filter(id=user_id).first()
21
+ return user.username if user else None
@@ -0,0 +1,43 @@
1
+ [project]
2
+ name = "ol-openedx-git-auto-export"
3
+ version = "0.5.0"
4
+ description = "A plugin that auto saves the course OLX to git when an author publishes it"
5
+ authors = [
6
+ {name = "MIT Office of Digital Learning"}
7
+ ]
8
+ license = "BSD-3-Clause"
9
+ readme = "README.rst"
10
+ requires-python = ">=3.11"
11
+ dependencies = [
12
+ "Django>2.0",
13
+ "celery>=4.4.7",
14
+ "edx-django-utils>4.0.0",
15
+ "edx-opaque-keys",
16
+ "gitpython>=3.1.37",
17
+ "openedx-events",
18
+ ]
19
+
20
+ [project.entry-points."cms.djangoapp"]
21
+ ol_openedx_git_auto_export = "ol_openedx_git_auto_export.app:GitAutoExportConfig"
22
+
23
+ [build-system]
24
+ requires = ["hatchling"]
25
+ build-backend = "hatchling.build"
26
+
27
+ [tool.hatch.build.targets.wheel]
28
+ include = [
29
+ "ol_openedx_git_auto_export/**/*.py",
30
+ ]
31
+ exclude = [
32
+ "ol_openedx_git_auto_export/**/test_*"
33
+ ]
34
+
35
+ [tool.hatch.build.targets.sdist]
36
+ include = [
37
+ "ol_openedx_git_auto_export/**/*",
38
+ "README.rst",
39
+ "pyproject.toml",
40
+ ]
41
+ exclude = [
42
+ "ol_openedx_git_auto_export/**/test_*"
43
+ ]
@@ -1 +0,0 @@
1
- include *.py
@@ -1,6 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: ol-openedx-git-auto-export
3
- Version: 0.4.0
4
- Summary: A plugin that auto saves the course OLX to git when an author publishes it
5
- License: BSD-3-Clause
6
- Requires-Python: >=3.8
@@ -1,31 +0,0 @@
1
-
2
- # DO NOT EDIT THIS FILE -- AUTOGENERATED BY PANTS
3
-
4
- import errno
5
- import os
6
- import setuptools.build_meta
7
-
8
- backend = setuptools.build_meta.__legacy__
9
-
10
- dist_dir = "dist/"
11
- build_wheel = True
12
- build_sdist = True
13
- wheel_config_settings = {
14
- }
15
- sdist_config_settings = {
16
- }
17
-
18
- # Python 2.7 doesn't have the exist_ok arg on os.makedirs().
19
- try:
20
- os.makedirs(dist_dir)
21
- except OSError as e:
22
- if e.errno != errno.EEXIST:
23
- raise
24
-
25
- wheel_path = backend.build_wheel(dist_dir, wheel_config_settings) if build_wheel else None
26
- sdist_path = backend.build_sdist(dist_dir, sdist_config_settings) if build_sdist else None
27
-
28
- if wheel_path:
29
- print("wheel: {wheel_path}".format(wheel_path=wheel_path))
30
- if sdist_path:
31
- print("sdist: {sdist_path}".format(sdist_path=sdist_path))
@@ -1,6 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: ol-openedx-git-auto-export
3
- Version: 0.4.0
4
- Summary: A plugin that auto saves the course OLX to git when an author publishes it
5
- License: BSD-3-Clause
6
- Requires-Python: >=3.8
@@ -1,19 +0,0 @@
1
- MANIFEST.in
2
- __init__.py
3
- backend_shim.py
4
- setup.py
5
- ol_openedx_git_auto_export/__init__.py
6
- ol_openedx_git_auto_export/app.py
7
- ol_openedx_git_auto_export/constants.py
8
- ol_openedx_git_auto_export/signals.py
9
- ol_openedx_git_auto_export/tasks.py
10
- ol_openedx_git_auto_export.egg-info/PKG-INFO
11
- ol_openedx_git_auto_export.egg-info/SOURCES.txt
12
- ol_openedx_git_auto_export.egg-info/dependency_links.txt
13
- ol_openedx_git_auto_export.egg-info/entry_points.txt
14
- ol_openedx_git_auto_export.egg-info/namespace_packages.txt
15
- ol_openedx_git_auto_export.egg-info/requires.txt
16
- ol_openedx_git_auto_export.egg-info/top_level.txt
17
- ol_openedx_git_auto_export/settings/__init__.py
18
- ol_openedx_git_auto_export/settings/common.py
19
- ol_openedx_git_auto_export/settings/production.py
@@ -1,2 +0,0 @@
1
- [cms.djangoapp]
2
- ol_openedx_git_auto_export = ol_openedx_git_auto_export.app:GitAutoExportConfig
@@ -1,4 +0,0 @@
1
- Django>2.0
2
- celery>=4.4.7
3
- edx-django-utils>4.0.0
4
- edx-opaque-keys<4.0.0,>=3.0.0
@@ -1,2 +0,0 @@
1
-
2
- ol_openedx_git_auto_export
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
@@ -1,33 +0,0 @@
1
-
2
- # DO NOT EDIT THIS FILE -- AUTOGENERATED BY PANTS
3
- # Target: src/ol_openedx_git_auto_export:edx_git_auto_export
4
-
5
- from setuptools import setup
6
-
7
- setup(**{
8
- 'description': 'A plugin that auto saves the course OLX to git when an author publishes it',
9
- 'entry_points': {
10
- 'cms.djangoapp': [
11
- 'ol_openedx_git_auto_export = ol_openedx_git_auto_export.app:GitAutoExportConfig',
12
- ],
13
- },
14
- 'install_requires': (
15
- 'Django>2.0',
16
- 'celery>=4.4.7',
17
- 'edx-django-utils>4.0.0',
18
- 'edx-opaque-keys<4.0.0,>=3.0.0',
19
- ),
20
- 'license': 'BSD-3-Clause',
21
- 'name': 'ol-openedx-git-auto-export',
22
- 'namespace_packages': (
23
- ),
24
- 'package_data': {
25
- },
26
- 'packages': (
27
- '',
28
- 'ol_openedx_git_auto_export',
29
- 'ol_openedx_git_auto_export.settings',
30
- ),
31
- 'python_requires': '>=3.8',
32
- 'version': '0.4.0',
33
- })