Skip to content

Commit

Permalink
Merge branch 'overhangio:master' into danyalfaheem/upgrade-to-python-…
Browse files Browse the repository at this point in the history
…3.12
  • Loading branch information
Danyal-Faheem committed Mar 7, 2024
2 parents 11dbaac + 9b1fdd9 commit 4f4e33b
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 43 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/auto-add-to-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Auto Add Issues and Pull Requests to Project

on:
issues:
types:
- opened

jobs:
# https://github.com/actions/add-to-project
add-to-proje
name: Add issue and bugs to project
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
project-url: https://github.com/orgs/overhangio/projects/4
github-token: ${{ secrets.GH_PROJECT_PERSONAL_ACCESS_TOKEN }}
1 change: 0 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ variables:
TUTOR_PLUGIN: discovery
TUTOR_IMAGES: discovery
TUTOR_PYPI_PACKAGE: tutor-discovery
OPENEDX_RELEASE: palm
GITHUB_REPO: overhangio/tutor-discovery

include:
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ instructions, because git commits are used to generate release notes:

<!-- scriv-insert-here -->

<a id='changelog-17.0.0'></a>
## v17.0.0 (2023-12-09)

- 💥 [Feature] Upgrade to Quince. (by @ziafazal)
- [Bugfix] Fix missing pkg-config during image build. (by @regisb)
- [Feature] Pull translations via `atlas` during Docker build. (by @OmarIthawi)

<a id='changelog-16.0.2'></a>
## v16.0.2 (2023-12-09)

- [Improvement] Added Typing to code, Makefile and test action to the repository and formatted code with Black and isort. (by @CodeWithEmad)
- [Improvement] Introduced Course Discovery Repository and Version settings. (by @Faraz32123)
- [BugFix] Fix base url for discovery media files, including program banner images. (by @Faraz32123)

<a id='changelog-16.0.1'></a>
## v16.0.1 (2023-11-08)

Expand Down
45 changes: 28 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Course Discovery plugin for `Tutor <https://docs.tutor.overhang.io>`_
Course Discovery plugin for `Tutor <https://docs.tutor.edly.io>`_
=====================================================================

This is a plugin for `Tutor <https://docs.tutor.overhang.io>`_ that integrates the `Course Discovery <https://github.com/edx/course-discovery/>`__ application in an Open edX platform. it is useful for integration with, for example, `Ecommerce <https://github.com/edx/ecommerce>`__ or an external course catalog.
This is a plugin for `Tutor <https://docs.tutor.edly.io>`_ that integrates the `Course Discovery <https://github.com/edx/course-discovery/>`__ application in an Open edX platform. it is useful for integration with, for example, `Ecommerce <https://github.com/edx/ecommerce>`__ or an external course catalog.

Installation
------------
Expand All @@ -14,27 +14,21 @@ Then, to enable this plugin, run::

tutor plugins enable discovery

You will have to re-generate the environment::
Restart and initialize your platform with::

tutor config save

Then, run migrations::

tutor local init

This last step is unnecessary if you run instead ``tutor local launch``.
tutor local launch

Operations
----------

Creating a user
~~~~~~~~~~~~~~~

The discovery user interface will be available at http://discovery.local.overhang.io for a local test instance, and at ``DISCOVERY_HOST`` (by default: http(s)://discovery.<your lms host>) in production. In order to run commands from the UI, a user must be created::
The discovery user interface will be available at http://discovery.local.edly.io for a local test instance, and at ``DISCOVERY_HOST`` (by default: http(s)://discovery.<your lms host>) in production. In order to run commands from the UI, a user must be created::

tutor local run discovery ./manage.py createsuperuser

Then, you must login with this user at http://discovery.local.overhang.io/admin.
Then, you must login with this user at http://discovery.local.edly.io/admin.

Alternatively, you can login with oauth2 using a pre-existing user created on the LMS/CMS by accessing http(s)://discovery.<your lms host>/login. To do so, the proper domain names must exist and point to the production server.

Expand Down Expand Up @@ -71,13 +65,30 @@ Then run the below command, this command will cause errors every time as it trie

tutor local run lms ./manage.py lms cache_programs

If you don't want the errors, then make use of an extra argument to the command .i.e. ``--domain``. This argument will be equal to ``local.overhang.io`` if you are running tutor local and ``local.overhang.io:8000`` if you are running tutor dev::
tutor local run lms ./manage.py lms cache_programs --domain="local.overhang.io"
If you don't want the errors, then make use of an extra argument to the command .i.e. ``--domain``. This argument will be equal to ``local.edly.io`` if you are running tutor local and ``local.edly.io:8000`` if you are running tutor dev::
tutor local run lms ./manage.py lms cache_programs --domain="local.edly.io"
or
tutor dev run lms ./manage.py lms cache_programs --domain="local.overhang.io:8000"
tutor dev run lms ./manage.py lms cache_programs --domain="local.edly.io:8000"

This last step should be performed every time you create new or make changes to existing programs.

Show Programs Tab
~~~~~~~~~~~~~~~~

In order to show programs tab in the LMS dashboard, users will need to manually create an entry in ``Programs api config`` model in LMS Admin Panel. Go to http://local.edly.io/admin/programs/programsapiconfig/. Add ``Marketing path`` equal to ``/programs`` and enable it. Then Programs tab will be shown on the LMS where users can view their registered programs. It will show like as in below picture.

.. image:: https://github.com/overhangio/tutor-discovery/assets/122095701/e0224011-adc0-41e4-a104-af4cb0c24b82
:alt: Programs Tab on LMS dashboard

In the above image, User can see explore programs button which is pointing to ``http://localhost:8080/programs`` by default. This link does not exist. So, users can change this link to their custom build marketing site url to show all programs there. This can be done by modifying ``Site Configurations`` model in LMS Admin Panel. Go to http://local.edly.io/site_configuration/siteconfiguration/. Open respective LMS site configuration and add below dict in ``site values`` field like below image::

"MKTG_URLS": {
"ROOT": "https://custom-marketing-site-here.com"
}

.. image:: https://github.com/overhangio/tutor-discovery/assets/122095701/2d588ea9-a830-40b6-9845-8fab56d7cb5a
:alt: Add Custom Site for Explore Programs

Install extra requirements
~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -97,7 +108,7 @@ To debug the course discovery service, you are encouraged to mount the course-di

tutor dev start --mount /path/to/course-discovery/ discovery

You can then access the development server at http://discovery.local.overhang.io:8381. Feel free to add breakpoints (``import pdb; pdb.set_trace()``) anywhere in your source code to debug your application.
You can then access the development server at http://discovery.local.edly.io:8381. Feel free to add breakpoints (``import pdb; pdb.set_trace()``) anywhere in your source code to debug your application.

Once a local repository is mounted in the image, you will have to install nodejs dependencies and collect static assets::

Expand All @@ -107,7 +118,7 @@ Once a local repository is mounted in the image, you will have to install nodejs
Troubleshooting
---------------

This Tutor plugin is maintained by Muhammad Faraz Maqsood from `Edly <https://edly.io/>`__. Community support is available from the official `Open edX forum <https://discuss.openedx.org>`__. Do you need help with this plugin? See the `troubleshooting <https://docs.tutor.overhang.io/troubleshooting.html>`__ section from the Tutor documentation.
This Tutor plugin is maintained by Muhammad Faraz Maqsood from `Edly <https://edly.io/>`__. Community support is available from the official `Open edX forum <https://discuss.openedx.org>`__. Do you need help with this plugin? See the `troubleshooting <https://docs.tutor.edly.io/troubleshooting.html>`__ section from the Tutor documentation.


`Max retries exceeded with url`
Expand Down
1 change: 0 additions & 1 deletion changelog.d/20231005_153602_codewithemad.md

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions changelog.d/20240212_115536_regis_pkg_resources.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- [Bugfix] Make plugin compatible with Python 3.12 by removing dependency on `pkg_resources`. (by @regisb)
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
setup(
name="tutor-discovery",
version=about["__version__"],
url="https://docs.tutor.overhang.io/",
url="https://docs.tutor.edly.io/",
project_urls={
"Documentation": "https://docs.tutor.overhang.io/",
"Documentation": "https://docs.tutor.edly.io/",
"Code": "https://github.com/overhangio/tutor-discovery",
"Issue tracker": "https://github.com/overhangio/tutor-discovery/issues",
"Community": "https://discuss.openedx.org",
Expand All @@ -34,7 +34,8 @@
long_description_content_type="text/x-rst",
packages=find_packages(exclude=["tests*"]),
include_package_data=True,
install_requires=["tutor>=16.0.0,<17.0.0"],
install_requires=["tutor>=17.0.0,<18.0.0"],
extras_require={"dev": "tutor[dev]>=17.0.0,<18.0.0"},
python_requires=">=3.8",
entry_points={"tutor.plugin.v1": ["discovery = tutordiscovery.plugin"]},
classifiers=[
Expand Down
2 changes: 1 addition & 1 deletion tutordiscovery/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "16.0.1"
__version__ = "17.0.0"
10 changes: 6 additions & 4 deletions tutordiscovery/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import typing as t
from glob import glob

import pkg_resources
import importlib_resources
from tutor import hooks as tutor_hooks
from tutor.__about__ import __version_suffix__

Expand All @@ -31,6 +31,8 @@
"OAUTH2_KEY_SSO": "discovery-sso",
"OAUTH2_KEY_SSO_DEV": "discovery-sso-dev",
"CACHE_REDIS_DB": "{{ OPENEDX_CACHE_REDIS_DB }}",
"ATLAS_PULL": False,
"DEFAULT_PRODUCT_SOURCE_SLUG": "edx",
"EXTRA_PIP_REQUIREMENTS": [],
"REPOSITORY": "https://github.com/openedx/course-discovery.git",
"REPOSITORY_VERSION": "{{ OPENEDX_COMMON_VERSION }}",
Expand All @@ -48,7 +50,7 @@
for service in init_tasks:
with open(
os.path.join(
pkg_resources.resource_filename("tutordiscovery", "templates"),
str(importlib_resources.files("tutordiscovery") / "templates"),
"discovery",
"tasks",
service,
Expand Down Expand Up @@ -110,7 +112,7 @@ def _mount_course_discovery_on_build(

# Add the "templates" folder as a template root
tutor_hooks.Filters.ENV_TEMPLATE_ROOTS.add_item(
pkg_resources.resource_filename("tutordiscovery", "templates")
str(importlib_resources.files("tutordiscovery") / "templates")
)
# Render the "build" and "apps" folders
tutor_hooks.Filters.ENV_TEMPLATE_TARGETS.add_items(
Expand All @@ -122,7 +124,7 @@ def _mount_course_discovery_on_build(
# Load patches from files
for path in glob(
os.path.join(
pkg_resources.resource_filename("tutordiscovery", "patches"),
str(importlib_resources.files("tutordiscovery") / "patches"),
"*",
)
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
PARLER_LANGUAGES["default"]["fallbacks"] = [PARLER_DEFAULT_LANGUAGE_CODE]

EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
DEFAULT_PRODUCT_SOURCE_SLUG = "{{ DISCOVERY_DEFAULT_PRODUCT_SOURCE_SLUG }}"
EMAIL_HOST = "{{ SMTP_HOST }}"
EMAIL_PORT = "{{ SMTP_PORT }}"
EMAIL_HOST_USER = "{{ SMTP_USERNAME }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@
# Disable API caching, which makes it a pain to troubleshoot issues
USE_API_CACHING = False

DISCOVERY_BASE_URL = "http://{{ DISCOVERY_HOST }}:8381"
MEDIA_URL = DISCOVERY_BASE_URL + "/media/"

{{ patch("discovery-development-settings") }}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@

SOCIAL_AUTH_REDIRECT_IS_HTTPS = {% if ENABLE_HTTPS %}True{% else %}False{% endif %}

DISCOVERY_BASE_URL = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ DISCOVERY_HOST }}"
MEDIA_URL = DISCOVERY_BASE_URL + "/media/"

{{ patch("discovery-production-settings") }}
37 changes: 22 additions & 15 deletions tutordiscovery/templates/discovery/build/discovery/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{% if is_buildkit_enabled() %}# syntax=docker/dockerfile:1.4{% endif %}
# syntax=docker/dockerfile:1.4
###### Minimal image with base system requirements for most stages
FROM docker.io/ubuntu:20.04 as minimal

ENV DEBIAN_FRONTEND=noninteractive
RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked{% endif %} \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt update && \
apt install -y curl git-core language-pack-en python3 python3-pip python3-venv \
build-essential libcairo2 libffi-dev libmysqlclient-dev libxml2-dev libxslt-dev libjpeg-dev libssl-dev
apt install -y curl git-core gettext language-pack-en python3 python3-dev python3-pip python3-venv \
build-essential libcairo2 libffi-dev libmysqlclient-dev libxml2-dev libxslt-dev libjpeg-dev libssl-dev \
pkg-config
ENV LC_ALL en_US.UTF-8

ARG APP_USER_ID=1000
Expand All @@ -30,14 +31,14 @@ ENV DISCOVERY_CFG /openedx/config.yml
RUN python3 -m venv ../venv/
ENV PATH "/openedx/venv/bin:$PATH"

RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/openedx/.cache/pip,sharing=shared {% endif %}pip install \
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared pip install \
# https://pypi.org/project/setuptools/
# https://pypi.org/project/pip/
# https://pypi.org/project/wheel/
setuptools==67.7.2 pip==23.1.2. wheel==0.40.0
setuptools==68.2.2 pip==23.2.1. wheel==0.41.2

# Install a recent version of nodejs
RUN pip install nodeenv==1.7.0
RUN pip install nodeenv==1.8.0
# nodejs version picked from https://github.com/openedx/course-discovery/blob/master/Dockerfile
RUN nodeenv /openedx/nodeenv --node=16.14.2 --prebuilt
ENV PATH /openedx/nodeenv/bin:${PATH}
Expand All @@ -46,21 +47,27 @@ ENV PATH /openedx/nodeenv/bin:${PATH}
# This is identical to "make production-requirements" but it was split in multiple
# instructions to benefit from docker image caching
# Install base requirements
RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/openedx/.cache/pip,sharing=shared {% endif %}pip install -r requirements.txt
{% for extra_requirement in DISCOVERY_EXTRA_PIP_REQUIREMENTS %}RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/openedx/.cache/pip,sharing=shared {% endif %}pip install '{{ extra_requirement }}'
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared pip install -r requirements.txt
{% for extra_requirement in DISCOVERY_EXTRA_PIP_REQUIREMENTS %}RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared pip install '{{ extra_requirement }}'
{% endfor %}

# Install npm, bower requirements
ARG NPM_REGISTRY='{{ NPM_REGISTRY }}'
RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/openedx/.npm/,sharing=shared,uid=${APP_USER_ID} {% endif %}npm clean-install --verbose --no-audit --registry=$NPM_REGISTRY --production
RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/openedx/.cache/bower,sharing=shared,uid=${APP_USER_ID} {% endif %}./node_modules/.bin/bower install --allow-root --production
RUN --mount=type=cache,target=/openedx/.npm/,sharing=shared,uid=${APP_USER_ID} npm clean-install --verbose --no-audit --registry=$NPM_REGISTRY --production
RUN --mount=type=cache,target=/openedx/.cache/bower,sharing=shared,uid=${APP_USER_ID} ./node_modules/.bin/bower install --allow-root --production

# Install extra requirements
RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/openedx/.cache/pip,sharing=shared {% endif %}pip install \
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared pip install \
# Use redis as a django cache https://pypi.org/project/django-redis/
django-redis==5.2.0 \
django-redis==5.4.0 \
# uwsgi server https://pypi.org/project/uWSGI/
uwsgi==2.0.21
uwsgi==2.0.22

{% if DISCOVERY_ATLAS_PULL %}
# Pull translations. Support the OEP-58 proposal behind a feature flag until it's fully implemented.
RUN atlas pull {{ patch("atlas-extra-args") }} translations/course-discovery/course_discovery/conf/locale:course_discovery/conf/locale
RUN python manage.py compilemessages
{% endif %}

# Collect static assets
COPY --chown=app:app assets.py ./course_discovery/settings/assets.py
Expand Down

0 comments on commit 4f4e33b

Please sign in to comment.