Git Product home page Git Product logo

ra-learn's Introduction

Learn

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.

Install pyenv, python, pipenv, and virtualenvwrapper

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:

  1. Install pyenv to help manage our Python environments.
    $ brew install pyenv
  2. Install the Python version we need.
    $ pyenv install 3.10
  3. Set this newly installed version as the global default.
    $ pyenv global 3.10.
  4. 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
  5. Install pipenv to help manage packages.
    $ brew install pipenv
  6. 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
  7. Check that we have dependencies required for pyenv.
    $ brew install zlib sqlite
  8. Install virtualenvwrapper into the current Python environment
    $ $(pyenv which python3) -m pip install virtualenvwrapper
  9. 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
  10. 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
    

Set up Learn in your local environment

  1. Navigate to the repository you want Learn to reside in.
  2. Clone this codebase
    $ git clone https://github.com/rocketacademy/learn.git
  3. Retrieve environment variables from 1Password and place them in a .env file in Learn's root directory.
  4. In Learn folder, create a virtual environment
    $ mkvirtualenv $(basename $(pwd))
  5. You should see the following when the virtual environment has been created and activated.
    (learn) $
  6. From now on, navigate to the project directory to activate or deactivate the virtual environment.
    $ pipenv shell or $ workon learn $ deactivate
  7. Install packages.
    $ pipenv install
    $ pipenv install --dev

Install certifi since Python no longer relies on macOS' openSSL certificates

  1. Create install_certifi.py file
  2. Copy and paste code from this gist
  3. Run python install_certifi.py

Install and set up Postgres database

  1. Install Postgres
    $ brew install postgresql@14
  2. Start database
    $ pg_ctl -D /opt/homebrew/var/postgres start
  3. Check that Postgres has been installed
    $ psql postgres
    $ \du (from inside psql)
  4. Create Learn database
    $ createdb learn
  5. Check that database was created
    $ psql learn

Verify that set-up is complete

$ python manage.py migrate
$ python manage.py collectstatic
$ pytest
$ python manage.py runserver

Stripe webhook

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/

Slack event hook

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

  1. Starting a local web service
    ngrok http 8000
  2. Adding the event hook's endpoint in api.slack.com > Event Subscriptions

ra-learn's People

Contributors

samklq avatar bryluke avatar rocketkai avatar michelle-mok avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.