This repository has been archived by the owner on Dec 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c893745
Showing
27 changed files
with
1,262 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.*.swp | ||
!.gitignore | ||
TODO | ||
__pycache__ | ||
*.egg-info/ | ||
/build/ | ||
/dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pypi: | ||
script: | ||
- apk add --no-cache make | ||
- pip3 install -U setuptools twine | ||
- python3 setup.py sdist | ||
- twine upload --skip-existing dist/tutor-ecommerce*.tar.gz | ||
only: | ||
- tags | ||
tags: | ||
- private |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
recursive-include tutorecommerce/patches * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
Ecommerce plugin for `Tutor <https://docs.tutor.overhang.io>`_ | ||
=============================================================== | ||
|
||
This is a plugin for `Tutor <https://docs.tutor.overhang.io>`_ that integrates the `Ecommerce <https://github.com/edx/ecommerce/>`__ application in an Open edX platform. | ||
|
||
.. image:: https://overhang.io/images/clients/e-ducation.jpg | ||
:alt: E-ducation | ||
:target: https://www.e-ducation.cn/ | ||
|
||
This plugin was developed and open sourced to the community thanks to the generous support of `E-ducation <https://www.e-ducation.cn/>`_. Thank you! | ||
|
||
Installation | ||
------------ | ||
|
||
This plugin requires tutor>=3.6.0 and the Discovery plugin `tutor-discovery <https://github.com/overhangio/tutor-discovery>`__. Also, you should have installed tutor from source, and not from a pre-compiled binary. | ||
|
||
:: | ||
|
||
pip install tutor-ecommerce | ||
|
||
Then, to enable this plugin, run:: | ||
|
||
tutor plugins enable ecommerce | ||
|
||
Services will have to be re-configured and restarted, so you are probably better off just running quickstart again:: | ||
|
||
tutor local quickstart | ||
|
||
Note that this plugins is compatible with `Kubernetes integration <http://docs.tutor.overhang.io/k8s.html>`__, so if deploying to a Kubernetes cluster, run instead:: | ||
|
||
tutor k8s quickstart | ||
|
||
Operations | ||
---------- | ||
|
||
Creating a user | ||
~~~~~~~~~~~~~~~ | ||
|
||
The ecommerce user interface will be available at http://ecommerce.localhost for a local instance, and at ``ECOMMERCE_HOST`` (by default: ``http(s)://ecommerce.<your lms host>) in production. In order to run commands from the UI, a user with admin rights must be created:: | ||
|
||
tutor local run ecommerce ./manage.py createsuperuser | ||
|
||
Local development | ||
~~~~~~~~~~~~~~~~~ | ||
|
||
For developing locally, it is necessary to configure the ecommerce service to be served from localhost:: | ||
|
||
tutor config save --set ECOMMERCE_HOST=ecommerce.localhost | ||
|
||
Configuration | ||
~~~~~~~~~~~~~ | ||
|
||
- ``ECOMMERCE_HOST`` (default: ``"ecommerce.{{ LMS_HOST }}"``) | ||
- ``ECOMMERCE_PAYMENT_PROCESSORS`` (default: ``{cybersource: {}, paypal: {}}``) | ||
- ``ECOMMERCE_ENABLED_PAYMENT_PROCESSORS``: (default: ``["cybersource", "paypal"]``) | ||
- ``ECOMMERCE_ENABLED_CLIENT_SIDE_PAYMENT_PROCESSORS`` (default: ``["cybersource"]``) | ||
- ``ECOMMERCE_EXTRA_PAYMENT_PROCESSOR_CLASSES`` (default: ``[]``) | ||
- ``ECOMMERCE_MYSQL_PASSWORD``: ``"{{ 8|random_string }}"``) | ||
- ``ECOMMERCE_SECRET_KEY`` (default: ``"{{ 20|random_string }}"``) | ||
- ``ECOMMERCE_OAUTH2_SECRET`` (default: ``"{{ 8|random_string }}"``) | ||
- ``ECOMMERCE_API_KEY`` (default: ``"{{ 20|random_string }}"``) | ||
- ``ECOMMERCE_DOCKER_IMAGE`` (default: ``"overhangio/openedx-ecommerce:{{ TUTOR_VERSION }}"``) | ||
- ``ECOMMERCE_WORKER_DOCKER_IMAGE`` (default: ``"overhangio/openedx-ecommerce-worker:{{ TUTOR_VERSION }}"``) | ||
- ``ECOMMERCE_MYSQL_DATABASE`` (default: ``"ecommerce"``) | ||
- ``ECOMMERCE_MYSQL_USERNAME`` (default: ``"ecommerce"``) | ||
- ``ECOMMERCE_MYSQL_USERNAME`` (default: ``"ecommerce"``) | ||
- ``ECOMMERCE_OAUTH2_KEY`` (default: ``"ecommerce"``) | ||
- ``ECOMMERCE_API_TIMEOUT`` (default: ``5``) | ||
- ``ECOMMERCE_WORKER_JWT_ISSUER`` (default: ``"ecommerce_worker"``) | ||
- ``ECOMMERCE_EXTRA_PIP_REQUIREMENTS`` (default: ``[]``) | ||
|
||
Image customisation | ||
~~~~~~~~~~~~~~~~~~~ | ||
|
||
Ecommerce implementations vary a lot from one country to another. If all you need are the Paypal, Cybersource and Stripe payment processors, then it should not be necessary to customize the tutor-ecommerce docker image, which contains the vanilla Ecommerce platform. However, if you need to run a fork of Ecommerce, or install extra requirements, then you should re-build the docker image. To do so, first set the appropriate settings:: | ||
|
||
tutor config save \ | ||
--set 'ENABLED_PAYMENT_PROCESSORS=["myprocessor"]' \ | ||
--set 'ENABLED_CLIENT_SIDE_PAYMENT_PROCESSORS=["myprocessor"]' \ | ||
--set 'ECOMMERCE_EXTRA_PAYMENT_PROCESSOR_CLASSES=["myextension.payment.MyProcessor"]' \ | ||
--set 'ECOMMERCE_EXTRA_PIP_REQUIREMENTS=["git+https://github.com/myusername/myplugin"]' | ||
|
||
Then, build the image, pointing to your fork if necessary:: | ||
|
||
tutor images build ecommerce \ | ||
-a ECOMMERCE_REPOSITORY=https://github.com/myusername/ecommerce \ | ||
-a ECOMMERCE_VERSION=my/tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import io | ||
import os | ||
from setuptools import setup, find_packages | ||
|
||
here = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
with io.open(os.path.join(here, "README.rst"), "rt", encoding="utf8") as f: | ||
readme = f.read() | ||
|
||
|
||
setup( | ||
name="tutor-ecommerce", | ||
version="0.1.0", | ||
url="https://docs.tutor.overhang.io/", | ||
project_urls={ | ||
"Documentation": "https://docs.tutor.overhang.io/", | ||
"Code": "https://github.com/overhangio/tutor-ecommerce", | ||
"Issue tracker": "https://github.com/overhangio/tutor/issues", | ||
"Community": "https://discuss.overhang.io", | ||
}, | ||
license="AGPLv3", | ||
author="Overhang.io", | ||
author_email="[email protected]", | ||
description="A Tutor plugin for Open edX Ecommerce", | ||
long_description=readme, | ||
packages=find_packages(exclude=["tests*"]), | ||
include_package_data=True, | ||
python_requires=">=3.5", | ||
install_requires=["tutor-openedx", "tutor-discovery"], | ||
entry_points={"tutor.plugin.v0": ["ecommerce = tutorecommerce.plugin"]}, | ||
classifiers=[ | ||
"Development Status :: 3 - Alpha", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: GNU Affero General Public License v3", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3.5", | ||
"Programming Language :: Python :: 3.6", | ||
"Programming Language :: Python :: 3.7", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: ecommerce | ||
labels: | ||
app.kubernetes.io/name: ecommerce | ||
spec: | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: ecommerce | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: ecommerce | ||
spec: | ||
containers: | ||
- name: ecommerce | ||
image: {{ DOCKER_REGISTRY }}{{ ECOMMERCE_DOCKER_IMAGE }} | ||
ports: | ||
- containerPort: 8000 | ||
env: | ||
- name: DJANGO_SETTINGS_MODULE | ||
value: ecommerce.settings.tutor | ||
volumeMounts: | ||
- mountPath: /openedx/ecommerce/ecommerce/settings/tutor.py | ||
name: settings | ||
subPath: tutor.py | ||
volumes: | ||
- name: settings | ||
configMap: | ||
name: ecommerce-settings | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: ecommerce_worker | ||
labels: | ||
app.kubernetes.io/name: ecommerce_worker | ||
spec: | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: ecommerce_worker | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: ecommerce_worker | ||
spec: | ||
containers: | ||
- name: ecommerce_worker | ||
image: {{ DOCKER_REGISTRY }}{{ ECOMMERCE_WORKER_DOCKER_IMAGE }} | ||
ports: | ||
- containerPort: 8000 | ||
env: | ||
- name: WORKER_CONFIGURATION_MODULE | ||
value: ecommerce_worker.configuration.tutor_worker | ||
- name: C_FORCE_ROOT | ||
value: "1" | ||
volumeMounts: | ||
- mountPath: /openedx/ecommerce_worker/ecommerce_worker/configuration/tutor_worker.py:ro | ||
name: settings | ||
subPath: tutor_worker.py | ||
volumes: | ||
- name: settings | ||
configMap: | ||
name: ecommerce_worker-settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- name: init-ecommerce-staticfiles | ||
image: {{ DOCKER_REGISTRY }}{{ ECOMMERCE_DOCKER_IMAGE }} | ||
args: ['cp', '-r', '/openedx/ecommerce/assets/', '/var/www/ecommerce/assets'] | ||
volumeMounts: | ||
- mountPath: /var/www/ecommerce/ | ||
name: ecommerce-staticfiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- name: ecommerce-staticfiles | ||
emptyDir: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
apiVersion: certmanager.k8s.io/v1alpha1 | ||
kind: Certificate | ||
metadata: | ||
name: {{ ECOMMERCE_HOST|replace(".", "-") }} | ||
spec: | ||
secretName: {{ ECOMMERCE_HOST }}-tls | ||
issuerRef: | ||
name: letsencrypt | ||
commonName: {{ ECOMMERCE_HOST }} | ||
dnsNames: | ||
- {{ ECOMMERCE_HOST }} | ||
acme: | ||
config: | ||
- http01: | ||
ingress: web | ||
domains: | ||
- {{ ECOMMERCE_HOST }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- host: {{ ECOMMERCE_HOST }} | ||
http: | ||
paths: | ||
- backend: | ||
serviceName: nginx | ||
servicePort: {% if ACTIVATE_HTTPS %}443{% else %}80{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- {{ ECOMMERCE_HOST }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: ecommerce | ||
spec: | ||
type: NodePort | ||
ports: | ||
- port: 8000 | ||
protocol: TCP | ||
selector: | ||
app.kubernetes.io/name: ecommerce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- name: ecommerce-settings | ||
files: | ||
- plugins/ecommerce/apps/settings/tutor.py | ||
- name: ecommerce_worker-settings | ||
files: | ||
- plugins/ecommerce/apps/settings/tutor_worker.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- ../../data/ecommerce:/var/www/ecommerce:ro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
ecommerce: | ||
image: {{ DOCKER_REGISTRY }}{{ ECOMMERCE_DOCKER_IMAGE }} | ||
environment: | ||
DJANGO_SETTINGS_MODULE: ecommerce.settings.tutor | ||
restart: unless-stopped | ||
volumes: | ||
- ../plugins/ecommerce/apps/tutor.py:/openedx/ecommerce/ecommerce/settings/tutor.py:ro | ||
- ../../data/ecommerce/media:/openedx/ecommerce/course_ecommerce/media | ||
depends_on: | ||
{% if ACTIVATE_LMS %}- lms{% endif %} # TODO decomment this | ||
{% if ACTIVATE_MYSQL %}- mysql{% endif %} | ||
- discovery | ||
|
||
ecommerce_worker: | ||
image: {{ DOCKER_REGISTRY }}{{ ECOMMERCE_WORKER_DOCKER_IMAGE }} | ||
environment: | ||
WORKER_CONFIGURATION_MODULE: ecommerce_worker.configuration.tutor_worker | ||
C_FORCE_ROOT: "1" | ||
restart: unless-stopped | ||
volumes: | ||
- ../plugins/ecommerce/apps/tutor_worker.py:/openedx/ecommerce_worker/ecommerce_worker/configuration/tutor_worker.py:ro | ||
depends_on: | ||
- ecommerce | ||
|
||
ecommerce-assets: | ||
image: {{ DOCKER_REGISTRY }}{{ ECOMMERCE_DOCKER_IMAGE }} | ||
volumes: | ||
- ../../data/ecommerce:/var/www/ecommerce | ||
command: sh -c "rm -rf /var/www/ecommerce/assets && cp -r /openedx/ecommerce/assets/ /var/www/ecommerce/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Ecommerce | ||
upstream ecommerce-backend { | ||
server ecommerce:8000 fail_timeout=0; | ||
} | ||
{% if ACTIVATE_HTTPS %} | ||
server { | ||
server_name {{ ECOMMERCE_HOST }}; | ||
listen 80; | ||
return 301 https://$server_name$request_uri; | ||
} | ||
{% endif %} | ||
server { | ||
{% if ACTIVATE_HTTPS %}listen 443 {{ "" if WEB_PROXY else "ssl" }};{% else %}listen 80;{% endif %} | ||
server_name ecommerce.localhost {{ ECOMMERCE_HOST }}; | ||
|
||
{% if ACTIVATE_HTTPS and not WEB_PROXY %} | ||
ssl_certificate /etc/letsencrypt/live/{{ ECOMMERCE_HOST }}/fullchain.pem; | ||
ssl_certificate_key /etc/letsencrypt/live/{{ ECOMMERCE_HOST }}/privkey.pem; | ||
{% endif %} | ||
|
||
# Disables server version feedback on pages and in headers | ||
server_tokens off; | ||
|
||
client_max_body_size 10m; | ||
|
||
location / { | ||
{% if not WEB_PROXY %} | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_set_header X-Forwarded-Port $server_port; | ||
proxy_set_header X-Forwarded-For $remote_addr; | ||
{% endif %} | ||
proxy_set_header Host $http_host; | ||
proxy_redirect off; | ||
proxy_pass http://ecommerce-backend; | ||
} | ||
|
||
location /static { | ||
alias /var/www/ecommerce/assets; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ECOMMERCE_PUBLIC_URL_ROOT = "http://ecommerce:8000" | ||
ECOMMERCE_API_URL = ECOMMERCE_PUBLIC_URL_ROOT + "/api/v2" | ||
ECOMMERCE_API_TIMEOUT = {{ ECOMMERCE_API_TIMEOUT }} | ||
EDX_API_KEY = "{{ ECOMMERCE_API_KEY }}" | ||
ECOMMERCE_API_SIGNING_KEY = "{{ JWT_COMMON_SECRET_KEY }}" |
Oops, something went wrong.