A Django plugin to add Memberpress REST API and Webhook integrations.
Project description
Django Plugin For memberpress REST API Client
A lightweight, performant Django plugin that implements REST api and Webhook integrations for the Wordpress memberpress Pro plugin.
Installation
pip install django-memberpress-client
Set the Django settings using tutor.
from django.conf import settings
settings.MEMBERPRESS_API_KEY = 'set-me-please'
settings.MEMBERPRESS_API_BASE_URL = 'https://set-me-please.com/'
You'll find the memberpress API Key in the Wordpress admin site.
Usage
from memberpress_client.member import Member
# 1. passing an explicit Wordpress username
member = Member(username="jsmith")
print(member.is_active_subscription)
print(member.is_trial_subscription)
# 2. using with Django request object
member = Member(request=request)
# 3. passing a Django user object
member = Member(user=user)
# 4. passing a Django user object
member = Member(user=user)
# 5. passing an json return object from memberpress REST API
member = Member(response=memberpress_response_json)
Local development
- Use the same virtual environment that you use for edx-platform
- Set your Python interpreter to 3.8x
- install black: https://pypi.org/project/black/
- install flake8: https://flake8.pycqa.org/en/latest/
# Run these from within your edx-platform virtual environment
pip3 install pre-commit
pre-commit install
pip3 install black
python3 -m pip install flake8
Local development good practices
- run
black
on modified code before committing. - run
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- run
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- run
pre-commit run --all-files
before pushing. see: https://pre-commit.com/
edx-platform dependencies
To avoid freaky version conflicts in prod it's a good idea to install all of the edx-platform requirements to your local dev virtual environment.
- requirements/edx/base.txt
- requirements/edx/develop.txt,
- requirements/edx/testing.txt
At a minimum this will give you the full benefit of your IDE's linter.
Notes regarding development with macOS M1
-
To avoid problems with installing the edx-platform requirements, create your virtual environment with Python >= 3.9.x using the native installer from https://www.python.org/.
which python
should return/Library/Frameworks/Python.framework/Versions/3.9/bin/python3
. Ignoring this advise will lead to very weird side effects. Note that this is true even though Lilac actually runs on Python 3.8.x -
Best to install openssl, openblas, zstd, mysql, and mysql-client with Brew. Using brew helps you avoid problems with gcc compilations and linking that have proven problematic on early releases of macOS 11 on M1. If you run into problems while pip installing mysql-client / MongoDBProxy / mongoengine/ pymongo /numpy / scipy / matplotlib then analyze the stack trace for any other straggling dependencies that I might have ommitted here that might also break due to the gcc compiler or linker, and try installing these instead with Brew.
-
In addition to launching your virtual environment it also helps to set the following environment variables in your terminal window. Make sure you pay attention to any further suggestions echoed in Brew installation output:
export OPENBLAS=/opt/homebrew/opt/openblas/lib/
export LDFLAGS="-L/opt/homebrew/opt/openblas/lib -L/opt/homebrew/opt/mysql-client/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openblas/include -I/opt/homebrew/opt/mysql-client/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openblas/lib/pkgconfig /opt/homebrew/opt/mysql-client/lib/pkgconfig"
Shell Plus and iPython
The stepwise_edxapi module adds ipython and django-extensions to the stack. It is then possible to get an enhanced shell via:
tutor local exec lms ./manage.py lms shell_plus
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-memberpress-client-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a3abea47201f11173f5f1ee7370f8a6d74590e9049e1a76e8f533bf1abeffea |
|
MD5 | 0eea8ee2c8cc0dcb9a77e4bae84031c5 |
|
BLAKE2b-256 | 3a9e5e4e65be31839ff7c36d946a2ad5082826b20d2d55c7ef4566c05749ffc3 |
Hashes for django_memberpress_client-0.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7bf4cc1a3aab926e60ae99e36788238cea66e394e2328edad3eddd35fef7e4a |
|
MD5 | 312b09202f3eb873eff3cce991b279ee |
|
BLAKE2b-256 | 4ce2dde0fe4b867d6b6f0c72354840a5e2c591f9b02bdd61613becbdc1e3fc97 |