This is Rocket's learning management system, meant to streamline operations for administrators and improve teaching and learning experiences for section leaders and students.
It is built with Django, hosted on Heroku, and connected to a PostgreSQL database.
Since Learn is built with Django, we will need to set up our Python environment locally. Doing this wrongly could result in confusion about which Python is running. The following steps are summarised from the following articles:
- Setting Python3 as default on Mac
- Using Pyenv to run multiple versions of Python
- Setting up virtual environment for Python on Mac
- Install
pyenv
to help manage our Python environments.
$ brew install pyenv
- Install the Python version we need.
$ pyenv install 3.10
- Set this newly installed version as the global default.
$ pyenv global 3.10
. - Check that the default has been set successfully. May need to
unset PYENV_VERSION
if you see a different version being set by that env var.
$ pyenv version
$ 3.10.9 (set by /Users/<yourusername>/.pyenv/version
- Install
pipenv
to help manage packages.
$ brew install pipenv
- Add the following to your
~/.zshrc
file.- Configure shell's environment for pyenv:
if command -v pyenv 1>/dev/null 2>&1; then eval "$(pyenv init -)" fi
- Tell shell to use pyenv's version of Python whenever we run a command
PATH=$(pyenv root)/shims:$PATH
- Configure shell's environment for pyenv:
- Check that we have dependencies required for
pyenv
.
$ brew install zlib sqlite
- Install
virtualenvwrapper
into the current Python environment
$ $(pyenv which python3) -m pip install virtualenvwrapper
- Add the following to your
~/.zshrc
file.
- Specify that we want to regularly go to our virtual environment directory
export WORKON_HOME=~/.virtualenvs
- Make a virtual environment directory in a virtual environment if one doesn't already exist
mkdir -p $WORKON_HOME
- Activate the new virtual environment by calling this script
. ~/.pyenv/versions/3.10.9/bin/virtualenvwrapper.sh
- Specify that we want to regularly go to our virtual environment directory
- Restart your terminal and check that you see the following output. This means that
virtualenvwrapper
is initialising the environment. We will create a virtual environment after we clone Learn's code repository.virtualenvwrapper.user_scripts creating /Users/samanthakoh/.virtualenvs/premkproject virtualenvwrapper.user_scripts creating /Users/samanthakoh/.virtualenvs/postmkproject virtualenvwrapper.user_scripts creating /Users/samanthakoh/.virtualenvs/initialize virtualenvwrapper.user_scripts creating /Users/samanthakoh/.virtualenvs/premkvirtualenv virtualenvwrapper.user_scripts creating /Users/samanthakoh/.virtualenvs/postmkvirtualenv virtualenvwrapper.user_scripts creating /Users/samanthakoh/.virtualenvs/prermvirtualenv virtualenvwrapper.user_scripts creating /Users/samanthakoh/.virtualenvs/postrmvirtualenv virtualenvwrapper.user_scripts creating /Users/samanthakoh/.virtualenvs/predeactivate virtualenvwrapper.user_scripts creating /Users/samanthakoh/.virtualenvs/postdeactivate virtualenvwrapper.user_scripts creating /Users/samanthakoh/.virtualenvs/preactivate virtualenvwrapper.user_scripts creating /Users/samanthakoh/.virtualenvs/postactivate virtualenvwrapper.user_scripts creating /Users/samanthakoh/.virtualenvs/get_env_details
- Navigate to the repository you want Learn to reside in.
- Clone this codebase
$ git clone https://github.com/rocketacademy/learn.git
- Retrieve environment variables from 1Password and place them in a .env file in Learn's root directory.
- In Learn folder, create a virtual environment
$ mkvirtualenv $(basename $(pwd))
- You should see the following when the virtual environment has been created and activated.
(learn) $
- From now on, navigate to the project directory to activate or deactivate the virtual environment.
$ pipenv shell
or$ workon learn
$ deactivate
- Install packages.
$ pipenv install
$ pipenv install --dev
- Create
install_certifi.py
file - Copy and paste code from this gist
- Run
python install_certifi.py
- Install
Postgres
$ brew install postgresql@14
- Start database
$ pg_ctl -D /opt/homebrew/var/postgres start
- Check that
Postgres
has been installed
$ psql postgres
$ \du
(from insidepsql
) - Create Learn database
$ createdb learn
- Check that database was created
$ psql learn
$ python manage.py migrate
$ python manage.py collectstatic
$ pytest
$ python manage.py runserver
In a separate terminal window, listen to Stripe webhook in order to receive payments and complete transactions
$ stripe listen --forward-to localhost:8000/payment/stripe/webhook/
We use Slack event hooks to perform actions when users accept our Slack workspace invitations In a separate terminal window, set up your Slack event hook by
- Starting a local web service
ngrok http 8000
- Adding the event hook's endpoint in api.slack.com > Event Subscriptions