Coder Social home page Coder Social logo

jd-08 / case Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 320011/case

0.0 1.0 0.0 808 KB

UWA Masters of Pharmacy Case Study Management Application written for Dr. Kenneth Lee using the Django Framework

License: MIT License

Python 59.05% CSS 3.31% HTML 30.24% JavaScript 7.38% Shell 0.02%

case's Introduction

Case · Django 2.2.4 Python 3.7.2

Case is a web application written using the Django Framework for Dr. Kenneth Lee and students studying Pharmacy at the University of Western Australia.

The purpose of the application is to allow students to populate a database with case studies that they have experienced, so that other users can attempt the case. Additionally it gives students an opportunity to try more cases, than currently available in the course.

Authors

License

This project is licensed under the MIT License.

Deployment

Database Server

  1. Install postgres 9.5 or greater

  2. Set up postgres database for case with associated user

  3. Allow postgres connections to the app server

App Server:

Distribution: Red Hat Enterprise 7

  1. Install EPEL repo
yum install epel-release
  1. Install required packages
yum install python-pip python-devel gcc nginx
  1. Clone the project
git clone https://github.com/320011/case
  1. Set up and activate a virtualenv inside case root
pip install virtualenv
virtualenv venv
. venv/bin/activate
  1. Install pip requirements (including production specific)
pip install -r requirements.txt
pip install gunicorn psycopg2-binary
  1. Create local_settings.py file in the same directory as settings.py and populate it with required data
import os

ALLOWED_HOSTS = ["example.com"]

DEBUG = False

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

STATIC_ROOT = "/path/to/static/for/nginx"

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'db_name',
        'USER': 'db_user',
        'PASSWORD': 'db_pass',
        'HOST': 'db_host',
    }
}

EMAIL_USE_TLS = True
EMAIL_HOST = 'my.smtp.server'
EMAIL_HOST_USER = "[email protected]"
EMAIL_HOST_PASSWORD = "email_app_password"
EMAIL_PORT = 587
  1. Collect static files for Nginx to serve
python manage.py collectstatic
  1. Create systemd daemon for gunicorn
vim /etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=case_linux_user
Group=nginx
WorkingDirectory=/path/to/repo/core
ExecStart=/path/to/repo/venv/bin/gunicorn --workers 3 --bind unix:/path/to/repo/case.sock core.wsgi:application

[Install]
WantedBy=multi-user.target
  1. Create an Nginx server block inside http {...} (or use SSL here)
vim /etc/nginx/nginx.conf
http {
    ...
    
    server {
        listen 80;
        server_name example.com;

        location = /favicon.ico {
            alias /path/to/staticfiles/favicon.ico;
        }
        location /static/ {
            alias /path/to/staticfiles/;
        }

        location / {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://unix:/path/to/repo/case.sock;
        }
    }
    
    ...
}
  1. Allow port 80 through the firewall

  2. Grant nginx file permissions to execute (important) your staticfiles directory

  3. Compile scss files into css. Follow the instructions here to download sass and compile

  4. Once the database is running, migrate our django models to it

python manage.py makemigrations
python manage.py migrate
  1. Start and enable systemd daemons
systemctl start gunicorn
systemctl enable gunicorn
systemctl start nginx
systemctl enable nginx

case's People

Contributors

dragonite avatar maxine4j avatar jd-08 avatar aaronjenkins1111 avatar hugozhangc avatar jonathanneo avatar

Watchers

James Cloos 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.