TWITTER_CONSUMER_SECRET=''
TWITTER_ACCESS_TOKEN_KEY=''
TWITTER_ACCESS_TOKEN_SECRET=''
+
+DJANGO_SETTINGS_MODULE='karmaworld.settings.dev'
-# Project secret files
-karmaworld/secret/*.py
-karmaworld/secret/*.json
-
-# ignore vagrant virtual machines
-.vagrant
-
# Python bytecode:
*.py[co]
Notice: This software makes use of external third party services which require
accounts to access the service APIs. Without these third parties available,
-this software may require considerable overhaul.
+this software may require considerable overhaul. These services have
+API keys that you must provide to KarmaNotes as environment variables. The
+best way to do this is by using a `.env` file. Copy `.env.example` to `.env`
+and populate the fields as required.
### Filepicker
This software uses [Filepicker.io](https://www.inkfilepicker.com/) for uploading
Filepicker requires an additional third party file hosting site where it may
send uploaded files. For this project, we have used Amazon S3.
-Filepicker will provide an API key. This is needed by the software.
+Your Filepicker API key must be provided in `FILEPICKER_API_KEY` and your
+secret in `FILEPICKER_SECRET`.
### Amazon S3
KarmaNotes uses IndexDen to create a searchable index of all the notes
in the system. Create an free IndexDen account at [their homepage](http://indexden.com/).
You will be given a private URL that accesses your IndexDen account.
-Create a file at karmaworld/secret/indexden.py, and enter your private URL, and the name
+Set the environment variable INDEXDEN_PRIVATE_URL to your private URL and
+INDEXDEN_INDEX to the name
of the index you want KarmaNotes to use. The index will be created automatically when
KarmaNotes is run if it doesn't already exist. For example,
```
-PRIVATE_URL = 'http://:secretsecret@secret.api.indexden.com'
-INDEX = 'karmanotes_something_something'
+INDEXDEN_PRIVATE_URL='http://:secretsecret@secret.api.indexden.com'
+INDEXDEN_INDEX='karmanotes_something_something'
```
### Google Drive
This software uses [Google Drive](https://developers.google.com/drive/) to
convert documents to and from various file formats.
-A Google Drive service account with access to the Google Drive is required. Thismay be done with a Google Apps account with administrative privileges, or ask
+A Google Drive service account with access to the Google Drive is required.
+This may be done with a Google Apps account with administrative privileges, or ask
your business sysadmin.
These are the instructions to create a Google Drive service account:
https://developers.google.com/drive/delegation
-When completed, you'll have a file called `client_secrets.json` and a p12 file
-which is the key to access the service account. Both are needed by the software.
+When completed, set the environment variables `GOOGLE_CLIENT_SECRETS`,
+`GOOGLE_USER`, and `GOOGLE_SERVICE_KEY_BASE64`.
### Twitter
If this Twitter feature is desired, the consumer key and secret as well as the
access token key and secret are needed by the software.
-If the required files are not found, then no errors will occur.
+If the required environment variables are not found, then no errors will occur
+and no tweets will be posted.
To set this up, create a new Twitter application at https://dev.twitter.com/apps/new.
Make sure this application has read/write access. Generate an access token. Go to your
OAuth settings, and grab the "Consumer key", "Consumer secret", "Access token", and
-"Access token secret".
+"Access token secret". Set these to the variables `TWITTER_CONSUMER_KEY`,
+`TWITTER_CONSUMER_SECRET`, `TWITTER_ACCESS_TOKEN_KEY`, `TWITTER_ACCESS_TOKEN_SECRET`
-Create a file at karmaworld/secret/twitter.py, and enter these tokens. For example,
-```
-CONSUMER_KEY = '???'
-CONSUMER_SECRET = '???'
-ACCESS_TOKEN_KEY = '???'
-ACCESS_TOKEN_SECRET = '???'
-```
### SSL Certificate
The certificate should be installed using nginx.
-# Development Install
-
-If you need to setup the project for development, it is highly recommend that
-you grab create a development virtual machine or (if available) grab one that
-has already been created for your site.
-
-The *host machine* is the system which runs e.g. VirtualBox, while the
-*virtual machine* refers to the system running inside e.g. VirtualBox.
-
-## Creating a Virtual Machine by hand
-
-Create a virtual machine with your favorite VM software. Configure the virtual
-machine for production with the steps shown in the [Production Install](#production-install) section.
-
-## Creating a Virtual Machine with Vagrant
-
-Vagrant supports a variety of virtual machine software and there is additional
-support for Vagrant to deploy to a wider variety. However, for these
-instructions, it is assumed Vagrant will be deployed to VirtualBox.
-
-1. Configure external dependencies on the host machine:
- * Under `{project_root}/karmaworld/secret/`:
- 1. Copy files with the example extension to the corresponding filename
- without the example extension (e.g.
- `cp filepicker.py.example filepicker.py`)
- 1. Modify those files, but ignore `db_settings.py` (Vagrant takes care of that one)
- 1. Copy the Google Drive service account p12 file to `drive.p12`
- (this filename and location may be changed in `drive.py`)
- 1. Ensure `*.py` in `secret/` are never added to the git repo.
- (.gitignore should help warn against taking this action)
-
-1. Install [VirtualBox](http://www.virtualbox.org/)
-
-1. Install [vagrant](http://www.vagrantup.com/) 1.3 or higher
-
-1. Use Vagrant to create the virtual machine.
- * While in `cd {project_root}`, type `vagrant up`
-
-1. Connect to the virtual machine with `vagrant ssh`
-
-Note:
-Port 443 of the virtual machine will be configured as port 6659 on the host
-system. While on the host system, fire up your favorite browser and point it at
-`https://localhost:6659/`. This connects to your host system on port 6659, which
-forwards to your virtual machine's web site using SSL.
-
-Port 80 of the virtual machine will be configured as port 16659 on the host
-system. While on the host system, fire up your favorite browser and point it at
-`http://localhost:16659/`. This connects to your host system on port 16659,
-which forwards to your virtual machine's web site using plain text.
-
-## Completing the Virtual Machine with Fabric
+# Local Install
-*Notice* Fabric might not run properly if you presently in a virtualenv.
-`deactivate` prior to running fab commands.
+KarmaNotes is a Heroku application. Download the [Heroku toolbelt](https://toolbelt.heroku.com/).
-### From the Host Machine
+To run KarmaNotes locally, do `foreman start`. Before your first run, there are
+a few setup steps:
+ 1. `virtualenv venv`
+ 1. `source venv/bin/activate`
+ 1. `pip install -r requirements.txt`
+ 1. `pip install -r requirements-dev.txt`
+ 1. `foreman run python manage.py syncdb --migrate --noinput`
+ 1. `foreman run python manage.py createsuperuser`
+ 1. `foreman run python manage.py fetch_usde_csv ./schools.csv`
+ 1. `foreman run python manage.py import_usde _csv ./schools.csv`
+ 1. `foreman run python manage.py sanitize_usde_schools`
-If Fabric is available on the host machine, you should be able to run Fabric
-commands directly on the host machine, pointed at the virtual machine. If
-Fabric is not available on the Host Machine, see the next section.
-To setup the host machine properly, see the section about
-[accessing the VM via fabric](#accessing-the-vm-via-fabric) and then return to
-this section.
+# Heroku Install
-Assuming those steps were followed with the alias, the following instructions
-should complete the virtual machine setup:
-
-1. `cd {project_root}` on the host machine.
-
-1. type `vmfab first_deploy`.
-
-### From within the Virtual Machine
-
-If Fabric is not available on the host machine, or just for funsies, you may
-run the Fabric commands within the virtual machine.
-
-1. Connect to the virtual machine with `vagrant ssh`.
-
-1. On the virtual machine, type `cd karmanotes` to get into the code
- repository.
-
-1. In the code repo of the VM, type `fab -H 127.0.0.1 first_deploy`
-
- During this process, you will be queried to create a Django site admin.
- Provide information. You will be asked to remove duplicate schools. Respond
- with yes.
-
-# Production Install
-
-These steps are taken care of by automatic utilities. Vagrant performs the
-first subsection of these instructions and Fabric performs the second
-subsection. These instructions are detailed here for good measure, but should
-not generally be needed.
-
-1. Ensure the following are installed:
- * `git`
- * `7zip` (for unzipping US Department of Education files)
- * `PostgreSQL` (server and client)
- * `nginx`
- * `libxslt` and `libxml2` (used by some Python libraries)
- * `RabbitMQ` (server)
- * `memcached`
- * `Python`
- * `PIP`
- * `virtualenv`
- * `virtualenvwrapper` (might not be needed anymore)
- * `pdf2htmlEX`
-
- On a Debian system supporting Apt, this can be done with:
-```
- sudo apt-get install python-pip postgresql python-virtualenv nginx \
- virtualenvwrapper git libxml2-dev p7zip-full libffi-dev \
- postgresql-server-dev-9.1 libxslt1-dev \
- libmemcached-dev python-dev rabbitmq-server \
- cmake libpng-dev libjpeg-dev libgtk2.0-dev \
- pkg-config libfontconfig1-dev autoconf libtool
-
- wget http://poppler.freedesktop.org/poppler-0.24.4.tar.xz
- tar xf poppler-0.24.4.tar.xz
- cd poppler-0.24.4
- ./configure --prefix=/usr --enable-xpdf-headers
- make
- sudo make install
- cd ~/
-
- git clone https://github.com/fontforge/fontforge.git
- cd fontforge
- ./bootstrap
- ./configure --prefix=/usr
- make
- sudo make install
- cd ~/
-
- git clone https://github.com/charlesconnell/pdf2htmlEX.git
- cd pdf2htmlEX
- cmake .
- make
- sudo make install
-```
-
-1. Generate a PostgreSQL database and a role with read/write permissions.
- * For Debian, these instructions are helpful: https://wiki.debian.org/PostgreSql
-
-1. Modify configuration files.
- * There are settings in `{project_root}/karmaworld/settings/prod.py`
- * Most of the setting should work fine by default.
- * There are additional configuration options for external dependencies
- under `{project_root}/karmaworld/secret/`.
- 1. Copy files with the example extension to the corresponding filename
- without the example extension (e.g.
- `cp filepicker.py.example filepicker.py`)
- 1. Modify those files.
- * Ensure `PROD_DB_USERNAME`, `PROD_DB_PASSWORD`, and `PROD_DB_NAME`
- inside `db_settings.py` match the role, password, and database
- generated in the previous step.
- 1. Copy the Google Drive service account p12 file to `drive.p12`
- (this filename and location may be changed in `drive.py`)
- 1. Ensure `*.py` in `secret/` are never added to the git repo.
- (.gitignore should help warn against taking this action)
-
-1. Make sure that /var/www exists, is owned by the www-data group, and that
- the desired user is a member of the www-data group.
-
-1. Configure nginx with a `proxy_pass` to port 8000 (or whatever port gunicorn
- will be running the site on) and any virtual hosting that is desired.
- Here is an example server file to put into `/etc/nginx/sites-available/`
-
- server {
- listen 80;
- server_name localhost;
- return 301 https://$host$request_uri;
- }
-
- server {
- listen 443;
- ssl on;
- server_name localhost;
- client_max_body_size 20M;
-
- location / {
- # pass traffic through to gunicorn
- proxy_pass http://127.0.0.1:8000;
- # pass HTTP(S) status through to Django
- proxy_set_header X-Forwarded-SSL $https;
- proxy_set_header X-Forwarded-Protocol $scheme;
- proxy_set_header X-Forwarded-Proto $scheme;
- # pass nginx site back to Django
- proxy_set_header Host $http_host;
- }
- }
-
-1. Configure the system to start supervisor on boot. An init script for
- supervisor is in the repo at `{project_root}/karmaworld/confs/supervisor`.
- `update-rc.d supervisor defaults` is the Debian command to load the init
- script into the correct directories.
-
-1. Make sure `{project_root)/var/log` and `{project_root}/var/run` exist and
- may be written to, or else put the desired logging and run file paths into
- `{project_root}/confs/prod/supervisord.conf`
-
-1. Create a virtualenv under `/var/www/karmaworld/venv`
-
-1. Change into the virtualenv with `. /var/www/karmaworld/venv/bin/activate`.
- Within the virtualenv:
-
- 1. Update the Python depenencies with `pip -i {project_root}/reqs/prod.txt`
- * If you want debugging on a production-like system:
- 1. run `pip -i {project_root}/reqs/vmdev.txt`
- 1. change `{project_root}/manage.py` to point at `vmdev.py`
- instead of `prod.py`
- 1. ensure firefox is installed on the system (such as by
- `sudo apt-get install firefox`)
-
- 1. Setup the database with `python {project_root}/manage.py syncdb --migrate`
+KarmaNotes is a Heroku application. Download the [Heroku toolbelt](https://toolbelt.heroku.com/).
- 1. Collect static resources and put them in the static hosting location with
- `python {project_root}/manage.py collect_static`
-
-1. The database needs to be populated with schools. A list of accredited schools
- may be found on the US Department of Education website:
- http://ope.ed.gov/accreditation/GetDownloadFile.aspx
-
- Alternatively, use the built-in scripts while in the virtualenv:
+To run KarmaNotes on Heroku, do `heroku create` and `git push heroku master` as typical
+for a Heroku application. This will deploy KarmaNotes to Heroku with a supporting buildpack.
+You will need to import the US Department of Education's list of accredited schools.
1. Fetch USDE schools with
- `python {project_root}/manage.py fetch_usde_csv ./schools.csv`
-
+ `heroku run python manage.py fetch_usde_csv ./schools.csv`
1. Upload the schools into the database with
- `python {project_root}/manage.py import_usde _csv ./schools.csv`
-
+ `heroku run python /manage.py import_usde _csv ./schools.csv`
1. Clean up redundant information with
- `python {project_root}/manage.py sanitize_usde_schools`
-
-1. Startup `supervisor`, which will run `celery` and `gunicorn`. This may be
- done from within the virtualenv by typing
- `python {project_root}/manage.py start_supervisord`
-
-1. If everything went well, gunicorn should be running the website on port 8000
- and nginx should be serving gunicorn on port 80.
-
-# Update a deployed system
-
-Once code has been updated, the running web service will need to be updated
-to stay in sync with the code.
-
-## Fabric
-
-Run the `deploy` fab command. For example:
-`fab -H 127.0.0.1 deploy`
-
-## By Hand
-
-1. pull code in from the repo with `git pull`
-1. If any Python requirements have changed, install/upgrade them:
- `pip install -r --upgrade reqs/prod.txt`
-1. If the database has changed, update the database with:
- `python manage.py syncdb --migrate`
-1. If any static files have changed, synchornize them with;
- `python manage.py collectstatic`
-1. Django will probably need a restart.
- * For a dev system, ctrl-c the running process and restart it.
- * For a production system, there are two options.
- * `python manage.py restart_supervisord` if far reaching changes
- have been made (that might effect celery, beat, etc)
- * `python manage.py restart_gunicorn` if only minor Django changes
- have been made
- * If you are uncertain, best bet is to restart supervisord.
-
-# Accessing the Vagrant Virtual Machine
-
-## Accessing the VM via Fabric
-If you have Fabric on the host machine, you can configure your host machine
-to run Fabric against the virtual machine.
-
-You will need to setup the host machine with the proper SSH credentials to
-access the virtual machine. This is done by running `vagrant ssh-config` from
-`{project_root}` and copying the results into your SSH configuration file
-(usually found at `~/.ssh/config`). This can be done more simply by typing this
-on the host machine:
-
- vagrant ssh-config --host karmavm >> ~/.ssh/config
-
-The VM will, by default, route its SSH connection through localhost port 2222
-on the host machine and the base user with be vagrant. Point Fabric there when
-running fab commands from `{project_root}`. So the command will look like this:
-
- fab -H karmavm <commands>
-
-In unix, it might be convenient to create and use an alias like so:
-
- alias vmfab='fab -H karmavm'
- vmfab <commands>
-
-Removing a unix alias is done with `unalias`.
-
-## Connecting to the VM via SSH
-If you have installed a virtual machine using `vagrant up`, you can connect
-to it by running `vagrant ssh` from `{project_root}`.
-
-## Connecting to the development website on the VM
-To access the website running on the VM, point your browser at
-http://localhost:6659/ using your host computer.
-
-Port 6659 on your local machine is set to forward to the VM's port 80.
-
-Fun fact: 6659 was chosen because of OM (sanskrit) and KW (KarmaWorld) on a
-phone: 66 59.
-
-## Updating the VM code repository
-Once connected to the virtual machine by SSH, you will see `karmaworld` in
-the home directory. That is the `{project_root}` in the virtual machine.
-
-`cd karmaworld` and then use `git fetch; git merge` and/or `git pull origin` as
-desired.
-
-The virtual machine's code repository is set to use your host machine's
-local repository as the origin. So if you make changes locally and commit them,
-without pushing them anywhere, your VM can pull those changes in for testing.
-
-This may seem like duplication. It is. The duplication allows your host machine
-to maintain git credentials and manage repository access control so that your
-virtual machine doesn't need sensitive information. Your virtual machine simply
-pulls from the local repository on your local file system without needing
-credentials, etc.
-
-## Deleting the Virtual Machine
-If you want to start a fresh virtual machine or simply remove the virtual
-machine from your hard drive, Vagrant has a command for that. While in
-`{project_root}` of the host system, type `vagrant destroy` and confirm with
-`y`. This will remove the VM from your hard drive.
-
-If you wanted a fresh VM, the next step is to run `vagrant up`, which will
-start a brand new VM (since the old one is gone).
+ `heroku run python /manage.py sanitize_usde_schools`
-## Other Vagrant commands
-Please see [vagrant documentation](http://docs.vagrantup.com/v2/cli/index.html)
-for more information on how to use the vagrant CLI to manage your development
-VM.
# Django Database management
We have setup Django to use
[south](http://south.aeracode.org/wiki/QuickStartGuide) for migrations. When
changing models, it is important to run
-`python {project_root}/manage.py schemamigration` which will create a migration
+`foreman run python manage.py schemamigration` which will create a migration
to reflect the model changes into the database. These changes can be pulled
-into the database with `python {project_root}/manage.py migrate`.
+into the database with `foreman run python manage.py migrate`.
Sometimes the database already has a migration performed on it, but that
information wasn't told to south. There are subtleties to the process which
A number of assets have been added to the repository which come from external
sources. It would be difficult to keep a complete list in this README and keep
it up to date. Software which originally came from outside parties can
-generally be found in `{project_root}/karmaworld/assets`.
+generally be found in `karmaworld/assets`.
Additionally, all third party Python projects (downloaded and installed with
pip) are listed in these files:
-* `{project_root}/reqs/common.txt`
-* `{project_root}/reqs/dev.txt`
-* `{project_root}/reqs/prod.txt`
-* `{project_root}/reqs/vmdev.txt` (just a combo of dev.txt and prod.txt)
+* `requirements.txt`
+* `requirements-dev.txt`
# Thanks
+++ /dev/null
-# -*- mode: ruby -*-
-# vi: set ft=ruby :
-
-# This file is for use by Vagrant (http://www.vagrantup.com/).
-# It will establish a debian-based (Ubuntu) virtual machine for development.
-
-# The virtual machine environment attempts to match the production environment
-# as closely as possible.
-
-# This file was generated by `vagrant up` and consequently modified.
-
-# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
-VAGRANTFILE_API_VERSION = "2"
-
-# Copy the vagrant SSH key into the VM so vagrant can SSH to localhost within
-# the VM. Continued in the shell script below.
-# http://serverfault.com/questions/491343/how-can-i-move-my-deploy-key-into-vagrant#comment549259_491345
-git_ssh_key = File.read(ENV['HOME'] + '/.vagrant.d/insecure_private_key');
-
-# build a shell script that installs prereqs, copies over the host secrets,
-# configures the database, sets up the user/group associations, creates a self
-# signed SSL cert, pulls in the code from the host machine, sets up some
-# external dependency configs, and then runs fabric.
-shellscript = <<SCRIPT
-cat >>/home/vagrant/.ssh/insecure_private_key <<EOF
-#{git_ssh_key}
-EOF
-chown vagrant:vagrant /home/vagrant/.ssh/insecure_private_key
-chmod 600 /home/vagrant/.ssh/insecure_private_key
-cat >>/home/vagrant/.ssh/config <<EOF
-Host localhost
- User vagrant
- IdentityFile ~/.ssh/insecure_private_key
-
-Host 127.0.0.1
- User vagrant
- IdentityFile ~/.ssh/insecure_private_key
-EOF
-chmod 644 /home/vagrant/.ssh/config
-
-cat >/home/vagrant/localhost.conf <<EOF
-[req]
-default_keyfile=localhost.key.pem
-encrypt_key=no
-default_bits=512
-prompt=no
-utf8=yes
-distinguished_name=dn
-
-[dn]
-C=US
-ST=Massachusetts
-L=Cambridge
-O=FinalsClub Foundation
-CN=localhost
-emailAddress=info@karmanotes.org
-EOF
-cd /home/vagrant
-openssl req -new -config localhost.conf -out localhost.csr.pem
-openssl x509 -req -in localhost.csr.pem -signkey localhost.key.pem -out localhost.cert.pem
-chown vagrant:vagrant localhost*
-cd -
-
-export DEBIAN_FRONTEND=noninteractive
-
-add-apt-repository -y ppa:coolwanglu/pdf2htmlex # pdf2htmlex
-
-apt-get update
-apt-get upgrade -y
-apt-get install -y python-pip postgresql python-virtualenv libffi-dev \
- git nginx postgresql-server-dev-9.1 libxslt1-dev \
- libxml2-dev libmemcached-dev python-dev rabbitmq-server \
- p7zip-full pdf2htmlex
-
-cat >> `dpkg -L pdf2htmlex | grep pdf2htmlEX.js` <<PDF2HTMLEXHACK
-Viewer.prototype['rescale'] = Viewer.prototype.rescale;
-Viewer.prototype['scroll_to'] = Viewer.prototype.scroll_to;
-PDF2HTMLEXHACK
-
-echo "CREATE USER vagrant WITH CREATEROLE CREATEDB LOGIN; CREATE DATABASE karmaworld OWNER vagrant;" | su postgres -c "psql"
-
-mkdir -m 775 -p /var/www
-chown -R :www-data /var/www
-usermod -a -G www-data vagrant
-
-su vagrant -c "git clone /vagrant karmaworld"
-
-SECRETPATH="karmaworld/secret"
-
-su vagrant -c "cp /vagrant/$SECRETPATH/* karmaworld/$SECRETPATH/"
-
-CFILE="karmaworld/$SECRETPATH/db_settings.py"
-cat > $CFILE <<CONFIG
-#!/usr/bin/env python
-# -*- coding:utf8 -*-
-# Copyright (C) 2012 FinalsClub Foundation
-"""
-DO NOT check this file into source control.
-"""
-PROD_DB_NAME = 'karmaworld'
-PROD_DB_USERNAME = 'vagrant'
-PROD_DB_PASSWORD = ''
-CONFIG
-chown vagrant:vagrant karmaworld/$SECRETPATH/*.py
-
-cat > /etc/nginx/sites-available/karmaworld <<CONFIG
-server {
- listen 80;
- server_name localhost;
- return 301 https://\\\$host:6659\\\$request_uri;
-}
-
-server {
- listen 443;
- ssl on;
- # don't do virtual hosting, handle all requests regardless of header
- server_name localhost;
- client_max_body_size 20M;
- ssl_certificate /home/vagrant/localhost.cert.pem;
- ssl_certificate_key /home/vagrant/localhost.key.pem;
-
- location / {
- # pass traffic through to gunicorn
- proxy_pass http://127.0.0.1:8000;
- # pass HTTP(S) status through to Django
- proxy_set_header X-Forwarded-SSL \\\$https;
- proxy_set_header X-Forwarded-Protocol \\\$scheme;
- proxy_set_header X-Forwarded-Proto \\\$scheme;
- # pass nginx site back to Django
- proxy_set_header Host \\\$http_host;
- }
-}
-CONFIG
-rm /etc/nginx/sites-enabled/default
-ln -s /etc/nginx/sites-available/karmaworld /etc/nginx/sites-enabled/karmaworld
-sudo service nginx restart
-
-cp karmaworld/confs/prod/supervisor /etc/init.d
-chmod 755 /etc/init.d/supervisor
-update-rc.d supervisor defaults
-
-pip install fabric
-SCRIPT
-# end of script
-
-Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
- # All Vagrant configuration is done here. The most common configuration
- # options are documented and commented below. For a complete reference,
- # please see the online documentation at vagrantup.com.
-
- # Every Vagrant virtual environment requires a box to build off of.
- config.vm.box = "Official Ubuntu 12.04 daily Cloud Image i386"
- #config.vm.box = "Official Ubuntu 12.04 daily Cloud Image amd64"
- #config.vm.box = "Official Ubuntu 12.10 daily Cloud Image i386"
- #config.vm.box = "Official Ubuntu 12.10 daily Cloud Image amd64"
- #config.vm.box = "Official Ubuntu 13.04 daily Cloud Image i386"
- #config.vm.box = "Official Ubuntu 13.04 daily Cloud Image amd64"
- #config.vm.box = "Official Ubuntu 13.10 daily Cloud Image i386"
- #config.vm.box = "Official Ubuntu 13.10 daily Cloud Image amd64"
-
- # The url from where the 'config.vm.box' box will be fetched if it
- # doesn't already exist on the user's system.
- config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-i386-vagrant-disk1.box"
- #config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box"
- #config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/quantal/current/quantal-server-cloudimg-i386-vagrant-disk1.box"
- #config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/quantal/current/quantal-server-cloudimg-amd64-vagrant-disk1.box"
- #config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/raring/current/raring-server-cloudimg-i386-vagrant-disk1.box"
- #config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/raring/current/raring-server-cloudimg-amd64-vagrant-disk1.box"
- #config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-i386-vagrant-disk1.box"
- #config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-amd64-vagrant-disk1.box"
-
- # Create a forwarded port mapping which allows access to a specific port
- # within the machine from a port on the host machine. In the example below,
- # accessing "localhost:8080" will access port 80 on the guest machine.
- # config.vm.network :forwarded_port, guest: 80, host: 8080
-
- # OM (sanskrit) KW (KarmaWorld) on a phone: 66 59
- config.vm.network :forwarded_port, guest: 443, host: 6659, auto_correct: true
- config.vm.network :forwarded_port, guest: 80, host: 16659, auto_correct: true
-
- # Create a private network, which allows host-only access to the machine
- # using a specific IP.
- #config.vm.network :private_network, ip: "192.168.66.59"
-
- # Create a public network, which generally matched to bridged network.
- # Bridged networks make the machine appear as another physical device on
- # your network.
- # Used to directly access the internet for downloading updates and so forth.
- config.vm.network :public_network
-
- # If true, then any SSH connections made will enable agent forwarding.
- # Default value: false
- # config.ssh.forward_agent = true
-
- # Share an additional folder to the guest VM. The first argument is
- # the path on the host to the actual folder. The second argument is
- # the path on the guest to mount the folder. And the optional third
- # argument is a set of non-required options.
- # config.vm.synced_folder "../data", "/vagrant_data"
-
- # Setup scripts
- config.vm.provision "shell", inline: shellscript
-
- # Provider-specific configuration so you can fine-tune various
- # backing providers for Vagrant. These expose provider-specific options.
- # Example for VirtualBox:
- #
- # config.vm.provider :virtualbox do |vb|
- # # Don't boot with headless mode
- # vb.gui = true
- #
- # # Use VBoxManage to customize the VM. For example to change memory:
- # vb.customize ["modifyvm", :id, "--memory", "1024"]
- # end
- #
- # View the documentation for the provider you're using for more
- # information on available options.
-
- # Enable provisioning with Puppet stand alone. Puppet manifests
- # are contained in a directory path relative to this Vagrantfile.
- # You will need to create the manifests directory and a manifest in
- # the file base.pp in the manifests_path directory.
- #
- # An example Puppet manifest to provision the message of the day:
- #
- # # group { "puppet":
- # # ensure => "present",
- # # }
- # #
- # # File { owner => 0, group => 0, mode => 0644 }
- # #
- # # file { '/etc/motd':
- # # content => "Welcome to your Vagrant-built virtual machine!
- # # Managed by Puppet.\n"
- # # }
- #
- # config.vm.provision :puppet do |puppet|
- # puppet.manifests_path = "manifests"
- # puppet.manifest_file = "site.pp"
- # end
-
- # Enable provisioning with chef solo, specifying a cookbooks path, roles
- # path, and data_bags path (all relative to this Vagrantfile), and adding
- # some recipes and/or roles.
- #
- # config.vm.provision :chef_solo do |chef|
- # chef.cookbooks_path = "../my-recipes/cookbooks"
- # chef.roles_path = "../my-recipes/roles"
- # chef.data_bags_path = "../my-recipes/data_bags"
- # chef.add_recipe "mysql"
- # chef.add_role "web"
- #
- # # You may also specify custom JSON attributes:
- # chef.json = { :mysql_password => "foo" }
- # end
-
- # Enable provisioning with chef server, specifying the chef server URL,
- # and the path to the validation key (relative to this Vagrantfile).
- #
- # The Opscode Platform uses HTTPS. Substitute your organization for
- # ORGNAME in the URL and validation key.
- #
- # If you have your own Chef Server, use the appropriate URL, which may be
- # HTTP instead of HTTPS depending on your configuration. Also change the
- # validation key to validation.pem.
- #
- # config.vm.provision :chef_client do |chef|
- # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
- # chef.validation_key_path = "ORGNAME-validator.pem"
- # end
- #
- # If you're using the Opscode platform, your validator client is
- # ORGNAME-validator, replacing ORGNAME with your organization name.
- #
- # If you have your own Chef Server, the default validation client name is
- # chef-validator, unless you changed the configuration.
- #
- # chef.validation_client_name = "ORGNAME-validator"
-end
+++ /dev/null
-import multiprocessing
-
-bind = '127.0.0.1:8000'
-workers = multiprocessing.cpu_count() * 2 + 1
-pid = 'var/run/gunicorn.pid'
-access_logfile = 'var/log/gunicorn/access.log'
-error_logfile = 'var/log/gunicorn/error.log'
+++ /dev/null
-[supervisord]
-logfile = /var/www/karmaworld/var/log/supervisord.log
-logfile_maxbytes = 10MB
-logfile_backups = 5
-loglevel = info
-pidfile = /var/www/karmaworld/var/run/supervisord.pid
-
-[supervisorctl]
-serverurl = unix:///var/www/karmaworld/var/run/supervisor.sock
-
-[unix_http_server]
-file = /var/www/karmaworld/var/run/supervisor.sock
-chmod = 0777
-
-[rpcinterface:supervisor]
-supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
-
-[program:gunicorn]
-command=/var/www/karmaworld/manage.py run_gunicorn -c confs/prod/gunicorn.conf
-autostart = true
-autorestart = true
-redirect_stderr = true
-stopsignal = QUIT
-
-[program:celeryd]
-command=/var/www/karmaworld/manage.py celery worker --pidfile=/var/www/karmaworld/var/run/celeryd.pid -l info
-autorestart = true
-redirect_stderr = true
-stdout_logfile=/var/www/karmaworld/var/log/celeryd.log
-priority = 2
-stopsignal = QUIT
-
+++ /dev/null
-import multiprocessing
-
-bind = '127.0.0.1:8000'
-workers = multiprocessing.cpu_count() * 2 + 1
-pid = '/var/www/karmaworld/var/run/gunicorn.pid'
-access_logfile = '/var/www/karmaworld/var/log/gunicorn/access.log'
-error_logfile = '/var/www/karmaworld/var/log/gunicorn/error.log'
+++ /dev/null
-upstream django-beta {
- server 127.0.0.1:8000;
-}
-
-server {
- server_name karmanotes.org ;
- client_max_body_size 20M;
-
- location /library/ {
- alias /var/www/djkarma/;
- }
-
- location /static/ {
- alias /var/www/static/;
- }
-
- location / {
- proxy_pass http://django-beta;
- proxy_redirect off;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- }
-
-
-}
-server {
- server_name karmanotes.com www.karmanotes.com;
- rewrite ^ http://karmanotes.org$request_uri? permanent;
-}
+++ /dev/null
-#! /bin/sh
-### BEGIN INIT INFO
-# Provides: supervisord-initscript
-# Required-Start: $remote_fs $syslog $postgresql $rabbitmq-server
-# Required-Stop: $remote_fs $syslog
-# Should-Start: $nginx
-# Default-Start: 30 2 3 4 5
-# Default-Stop: 70 0 1 6
-# Short-Description: supervisord for KarmaWorld within a virtualenv
-# Description: supervisord for KarmaWorld within a virtualenv
-### END INIT INFO
-
-# Modified by Bryan Bonvallet for FinalsClub Foundation
-# Original Author: Nicolas Kuttler
-# Original Script:
-# http://kuttler.eu/code/debian-init-script-virtualenv-gunicorn-django/
-#
-# Enable with update-rc.d gunicorn-example start 30 2 3 4 5 . stop 70 0 1 6 .
-# (parameters might not be necessary, test)
-
-# Do NOT "set -e"
-
-PROJECT=/var/www/karmaworld
-VIRTUALENV=$PROJECT/venv
-CONF=$PROJECT/confs/prod/supervisord.conf
-# PATH should only include /usr/* if it runs after the mountnfs.sh script
-PATH=/bin:/usr/bin
-USER=vagrant
-GROUP=vagrant
-# I am lazy and just call the init script gunicorn-project
-NAME=`basename $0`
-DESC=$NAME
-PIDFILE=$PROJECT/var/run/$NAME.pid
-CMD="supervisord -c $CONF"
-
-# Load the VERBOSE setting and other rcS variables
-. /lib/init/vars.sh
-
-# Define LSB log_* functions.
-# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
-# and status_of_proc is working.
-. /lib/lsb/init-functions
-
-#
-# Function that starts the daemon/service
-#
-do_start() {
- # Return
- # 0 if daemon has been started
- # 1 if daemon was already running
- # 2 if daemon could not be started
- if [ -e $PIDFILE ]; then
- return 1
- fi
- cd $PROJECT
- . $VIRTUALENV/bin/activate
- $CMD
- if [ $? = 0 ]; then
- return 0
- else
- return 2
- fi
-}
-
-#
-# Function that stops the daemon/service
-#
-do_stop() {
- # Return
- # 0 if daemon has been stopped
- # 1 if daemon was already stopped
- # 2 if daemon could not be stopped
- # other if a failure occurred
- if [ -f $PIDFILE ]; then
- PID=`cat $PIDFILE`
- rm $PIDFILE
- kill -15 $PID
- if [ $? = 0 ]; then
- return 0
- else
- return 2
- fi
- else
- return 1
- fi
-}
-
-do_reload() {
- if [ -f $PIDFILE ]; then
- PID=`cat $PIDFILE`
- kill -HUP $PID
- return $?
- fi
- return 2
-}
-
-case "$1" in
- start)
- [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
- do_start
- case "$?" in
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
- esac
- ;;
- stop)
- [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
- do_stop
- case "$?" in
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
- esac
- ;;
- restart)
- log_daemon_msg "Restarting $DESC" "$NAME"
- do_stop
- case "$?" in
- 0|1)
- do_start
- case "$?" in
- 0) log_end_msg 0 ;;
- 1) log_end_msg 1 ;; # Old process is still running
- *) log_end_msg 1 ;; # Failed to start
- esac
- ;;
- *)
- # Failed to stop
- log_end_msg 1
- ;;
- esac
- ;;
- reload)
- log_daemon_msg "Reloading $DESC" "$NAME"
- do_reload
- case "$?" in
- 0) log_end_msg 0 ;;
- *) log_end_msg 1 ;;
- esac
- ;;
- *)
- echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
- exit 3
- ;;
-esac
-
-:
+++ /dev/null
-[supervisord]
-logfile = /var/www/karmaworld/var/log/supervisord.log
-logfile_maxbytes = 10MB
-logfile_backups = 5
-loglevel = info
-pidfile = /var/www/karmaworld/var/run/supervisord.pid
-
-[supervisorctl]
-serverurl = unix:///var/www/karmaworld/var/run/supervisor.sock
-
-[unix_http_server]
-file = /var/www/karmaworld/var/run/supervisor.sock
-chmod = 0777
-
-[rpcinterface:supervisor]
-supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
-
-[program:gunicorn]
-command=/var/www/karmaworld/manage.py run_gunicorn -c confs/prod/gunicorn.conf --log-level=info --log-file=/var/www/karmaworld/var/log/gunicorn.log
-autostart = true
-autorestart = true
-redirect_stderr = true
-stopsignal = QUIT
-
-[program:celeryd]
-command=/var/www/karmaworld/manage.py celery worker --pidfile=/var/www/karmaworld/var/run/celeryd.pid -l info
-autorestart = true
-redirect_stderr = true
-stdout_logfile=/var/www/karmaworld/var/log/celeryd.log
-priority = 2
-stopsignal = QUIT
-
-[program:beat]
-command=/var/www/karmaworld/manage.py celery beat --pidfile=/var/www/karmaworld/var/run/beat.pid -l info
-autorestart = true
-redirect_stderr = true
-stdout_logfile=/var/www/karmaworld/var/log/beat.log
-priority = 2
-stopsignal = QUIT
+++ /dev/null
-""" Karmaworld Fabric management script
- Finals Club (c) 2013"""
-
-import os
-import ConfigParser
-from cStringIO import StringIO
-
-from fabric.api import cd, lcd, prefix, run, sudo, task, local, settings
-from fabric.state import env as fabenv
-from fabric.contrib import files
-
-from dicthelpers import fallbackdict
-
-# Use local SSH config for connections if available.
-fabenv['use_ssh_config'] = True
-
-######## env wrapper
-# global environment variables fallback to fabric env variables
-# (also getting vars will do format mapping on strings with env vars)
-env = fallbackdict(fabenv)
-
-######### GLOBALS
-env.django_user = '{user}' # this will be different when sudo/django users are
-env.group = 'www-data'
-env.proj_repo = 'git@github.com:FinalsClub/karmaworld.git'
-env.repo_root = '/home/{django_user}/karmaworld'
-env.proj_root = '/var/www/karmaworld'
-env.branch = 'prod' # only used for supervisor conf two lines below. cleanup?
-env.code_root = env.proj_root
-env.supervisor_conf = '{code_root}/confs/{branch}/supervisord.conf'
-env.usde_csv = '{code_root}/confs/accreditation.csv'
-
-######## Run Commands in Virtual Environment
-def virtenv_path():
- """
- Find and memoize the virtualenv for use internally.
- """
- default_venv = env.proj_root + '/venv/bin/activate'
-
- # Return environment root if its been memoized
- if 'env_root' in env and env['env_root']:
- return env['env_root']
-
- # Not memoized. Try to find a single unique virtual environment.
- with settings(warn_only=True):
- outp = run("find -L {0} -path '*/bin/activate' | grep -v '/local/'".format(env.proj_root))
- if not len(outp) or len(outp.splitlines()) != 1:
- # Cannot find any virtualenv or found multiple virtualenvs.
- if len(outp) and default_venv not in outp:
- # Multiple venvs and the default is not present.
- raise Exception('Cannot determine the appropriate virtualenv.')
- # If there are no virtualenvs, then use the default (this will create
- # one if being called by make_virtualenv, otherwise it will cause an
- # error).
- # If there are multiple virtualenvs and the default is in their midst,
- # use the default.
- outp = default_venv
- # Pop off the /bin/activate from /venv/bin/activate
- outp = os.path.sep.join(outp.split(os.path.sep)[:-2])
- env['env_root'] = outp
- return outp
-
-def virtenv_exec(command):
- """
- Execute command in Virtualenv
- """
- with prefix('source {0}/bin/activate'.format(virtenv_path())):
- run(command)
-
-######## Sync database
-@task
-def syncdb():
- """
- Sync Database
- """
- virtenv_exec('{0}/manage.py syncdb --migrate --noinput'.format(env.code_root))
-
-
-####### Collect Static Files
-@task
-def collect_static():
- """
- Collect static files (if AWS config. present, push to S3)
- """
-
- virtenv_exec('{0}/manage.py collectstatic --noinput'.format(env.code_root))
-
-####### Compress Static Files
-@task
-def compress_static():
- """
- Compress static files
- """
-
- virtenv_exec('{0}/manage.py compress'.format(env.code_root))
-
-
-####### Run Dev Server
-@task
-def dev_server():
- """
- Runs the built-in django webserver
- """
-
- virtenv_exec('{0}/manage.py runserver'.format(env.code_root))
-
-####### Create Virtual Environment
-
-@task
-def link_code():
- """
- Link the karmaworld repo into the appropriate production location
- """
- if not files.exists(env.code_root):
- run('ln -s {0} {1}'.format(env.repo_root, env.code_root))
-
-@task
-def make_virtualenv():
- """
- Create our Virtualenv
- """
- run('virtualenv {0}'.format(virtenv_path()))
-
-@task
-def start_supervisord():
- """
- Starts supervisord
- """
- virtenv_exec('supervisord -c {0}'.format(env.supervisor_conf))
-
-
-@task
-def stop_supervisord():
- """
- Restarts supervisord
- """
- virtenv_exec('supervisorctl -c {0} shutdown'.format(env.supervisor_conf))
-
-
-@task
-def restart_supervisord():
- """
- Restarts supervisord, also making sure to load in new config data.
- """
- virtenv_exec('supervisorctl -c {0} update; supervisorctl -c {0} restart all'.format(env.supervisor_conf))
-
-
-def supervisorctl(action, process):
- """
- Takes as arguments the name of the process as is
- defined in supervisord.conf and the action that should
- be performed on it: start|stop|restart.
- """
- virtenv_exec('supervisorctl -c {0} {1} {2}'.format(env.supervisor_conf, action, process))
-
-
-@task
-def start_celery():
- """
- Starts the celeryd process
- """
- supervisorctl('start', 'celeryd')
-
-
-@task
-def stop_celery():
- """
- Stops the celeryd process
- """
- supervisorctl('stop', 'celeryd')
-
-
-@task
-def restart_celery():
- """
- Restarts the celeryd process
- """
- supervisorctl('restart', 'celeryd')
-
-
-@task
-def start_gunicorn():
- """
- Starts the gunicorn process
- """
- supervisorctl('start', 'gunicorn')
-
-
-@task
-def stop_gunicorn():
- """
- Stops the gunicorn process
- """
- supervisorctl('stop', 'gunicorn')
-
-
-@task
-def restart_gunicorn():
- """
- Restarts the gunicorn process
- """
- supervisorctl('restart', 'gunicorn')
-
-@task
-def flush_memcache():
- """
- Clear everything cached in memcached
- """
- virtenv_exec('echo "flush_all" | nc localhost 11211')
-
-####### Update Requirements
-@task
-def install_reqs():
- # first install must be done without --upgrade for a few packages that break
- # due to a pip problem.
- virtenv_exec('pip install -r {0}/reqs/prod.txt'.format(env.code_root))
-
-@task
-def update_reqs():
- # this should generally work to install reqs too, save for a pip problem
- # with a few packages.
- virtenv_exec('pip install --upgrade -r {0}/reqs/prod.txt'.format(env.code_root))
-
-####### Pull new code
-@task
-def update_code():
- virtenv_exec('cd {0}; git pull'.format(env.code_root))
-
-def backup():
- """
- Create backup using bup
- """
- pass
-
-@task
-def file_setup():
- """
- Deploy expected files and directories from non-apt system services.
- """
- ini_parser = ConfigParser.SafeConfigParser()
- # read remote data into a file like object
- data_flo = StringIO(run('cat {supervisor_conf}'.format(**env)))
- ini_parser.readfp(data_flo)
- for section, option in (('supervisord','logfile'),
- ('supervisord','pidfile'),
- ('unix_http_server','file'),
- ('program:celeryd','stdout_logfile')):
- if not ini_parser.has_section(section):
- raise Exception("Could not parse INI file {supervisor_conf}".format(**env))
- filepath = ini_parser.get(section, option)
- # generate file's directory structure if needed
- run('mkdir -p {0}'.format(os.path.split(filepath)[0]))
- # touch a file and change ownership if needed
- if 'log' in option and not files.exists(filepath):
- sudo('touch {0}'.format(filepath))
- sudo('chown {0}:{1} {2}'.format(env.django_user, env.group, filepath))
-
-@task
-def check_secrets():
- """
- Ensure secret files exist for syncdb to run.
- """
-
- secrets_path = env.code_root + '/karmaworld/secret'
- secrets_files = ('filepicker.py', 'static_s3.py', 'drive.py', 'client_secrets.json', 'drive.p12')
-
- errors = []
- for sfile in secrets_files:
- ffile = os.path.sep.join((secrets_path,sfile))
- if not files.exists(ffile):
- errors.append('{0} missing. Please add and try again.'.format(ffile))
- if errors:
- raise Exception('\n'.join(errors))
-
-@task
-def fetch_usde():
- """
- Download USDE accreditation school CSV.
- """
- virtenv_exec('{0}/manage.py fetch_usde_csv {1}'.format(env.code_root, env.usde_csv))
-
-@task
-def import_usde():
- """
- Import accreditation school CSV into the database and scrub it.
- """
- virtenv_exec('{0}/manage.py import_usde_csv {1}'.format(env.code_root, env.usde_csv))
- virtenv_exec('{0}/manage.py sanitize_usde_schools'.format(env.code_root))
-
-@task
-def first_deploy():
- """
- Sets up and deploys the project for the first time.
- """
- link_code()
- make_virtualenv()
- file_setup()
- check_secrets()
- install_reqs()
- syncdb()
- compress_static()
- collect_static()
- fetch_usde()
- import_usde()
- start_supervisord()
- print "You should run `manage.py createsuperuser` in the virtual environment"
-
-
-@task
-def deploy():
- """
- Deploys the latest changes
- """
- update_code()
- update_reqs()
- syncdb()
- compress_static()
- collect_static()
- restart_supervisord()
-########## END COMMANDS
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding:utf8 -*-
-# Copyright (C) 2012 FinalsClub Foundation
-""" Production settings and globals. """
-from os import environ
-from datetime import timedelta
-from S3 import CallingFormat
-
-from common import *
-
-from karmaworld.secret.static_s3 import *
-
-try:
- # Include email is settings are there
- from karmaworld.secret.email import SMTP_HOST
- from karmaworld.secret.email import SMTP_USERNAME
- from karmaworld.secret.email import SMTP_PASSWORD
- EMAIL = True
-except:
- EMAIL = False
-
-########## EMAIL CONFIGURATION
-if EMAIL:
- # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
- EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
-
- # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host
- EMAIL_HOST = environ.get('EMAIL_HOST', SMTP_HOST)
-
- # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password
- EMAIL_HOST_PASSWORD = environ.get('EMAIL_HOST_PASSWORD', SMTP_PASSWORD)
-
- # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user
- EMAIL_HOST_USER = environ.get('EMAIL_HOST_USER', SMTP_USERNAME)
-
- # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port
- EMAIL_PORT = environ.get('EMAIL_PORT', 587)
-
- # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
- EMAIL_SUBJECT_PREFIX = 'KarmaNotes '
-
- # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls
- EMAIL_USE_TLS = True
-
- DEFAULT_FROM_EMAIL = 'info@karmanotes.org'
-
- # See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
- SERVER_EMAIL = EMAIL_HOST_USER
-########## END EMAIL CONFIGURATION
-
-
-########## DATABASE CONFIGURATION
-DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.postgresql_psycopg2',
- 'NAME': PROD_DB_NAME,
- 'USER': PROD_DB_USERNAME,
- 'PASSWORD': PROD_DB_PASSWORD,
- 'HOST': '',
- 'PORT': '', # Set to empty string for default. Not used with sqlite3.
- }
-}
-########## END DATABASE CONFIGURATION
-
-
-########## CACHE CONFIGURATION
-# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
-CACHES = {
- 'default': {
- 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
- }
-}
-########## END CACHE CONFIGURATION
-
-
-########## CELERY CONFIGURATION
-# See: http://docs.celeryproject.org/en/latest/configuration.html#broker-transport
-BROKER_TRANSPORT = 'amqplib'
-
-# Set this number to the amount of allowed concurrent connections on your AMQP
-# provider, divided by the amount of active workers you have.
-#
-# For example, if you have the 'Little Lemur' CloudAMQP plan (their free tier),
-# they allow 3 concurrent connections. So if you run a single worker, you'd
-# want this number to be 3. If you had 3 workers running, you'd lower this
-# number to 1, since 3 workers each maintaining one open connection = 3
-# connections total.
-#
-# See: http://docs.celeryproject.org/en/latest/configuration.html#broker-pool-limit
-BROKER_POOL_LIMIT = 3
-
-# See: http://docs.celeryproject.org/en/latest/configuration.html#broker-connection-max-retries
-BROKER_CONNECTION_MAX_RETRIES = 0
-
-# See: http://docs.celeryproject.org/en/latest/configuration.html#broker-url
-BROKER_URL = environ.get('RABBITMQ_URL') or environ.get('CLOUDAMQP_URL')
-
-# See: http://docs.celeryproject.org/en/latest/configuration.html#celery-result-backend
-CELERY_RESULT_BACKEND = 'amqp'
-
-# Periodic tasks
-CELERYBEAT_SCHEDULE = {
- 'tweet-about-notes': {
- 'task': 'tweet_note',
- 'schedule': timedelta(minutes=60),
- },
-}
-
-CELERY_TIMEZONE = 'UTC'
-
-########## END CELERY CONFIGURATION
-
-
-########## STORAGE CONFIGURATION
-# See: http://django-storages.readthedocs.org/en/latest/index.html
-INSTALLED_APPS += (
- 'storages',
- 'gunicorn',
-)
-
-# See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
-STATICFILES_STORAGE = DEFAULT_FILE_STORAGE
-
-# See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
-AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN
-
-# Put static files in the folder 'static' in our S3 bucket.
-# This is so they have the same path as they do when served
-# locally for development.
-AWS_LOCATION = 'static'
-
-# AWS cache settings, don't change unless you know what you're doing:
-AWS_EXPIREY = 60 * 60 * 24 * 7
-AWS_HEADERS = {
- 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
- AWS_EXPIREY)
-}
-
-# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
-STATIC_URL = CLOUDFRONT_URL + AWS_LOCATION + '/'
-########## END STORAGE CONFIGURATION
-
-
-########## SSL FORWARDING CONFIGURATION
-SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
-########## END SSL FORWARDING CONFIGURATION
-
-
-########## COMPRESSION CONFIGURATION
-# See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE
-COMPRESS_OFFLINE = True
-
-# See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
-COMPRESS_STORAGE = DEFAULT_FILE_STORAGE
-
-# Make sure that django-compressor serves from CloudFront
-AWS_S3_CUSTOM_DOMAIN = CLOUDFRONT_DOMAIN
-
-# See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
-COMPRESS_CSS_FILTERS += [
- 'compressor.filters.datauri.CssDataUriFilter',
- 'compressor.filters.cssmin.CSSMinFilter',
-]
-COMPRESS_DATA_URI_MAX_SIZE = 5120
-
-# See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
-COMPRESS_JS_FILTERS += [
- 'compressor.filters.closure.ClosureCompilerFilter',
-]
-COMPRESS_CLOSURE_COMPILER_BINARY = 'java -jar /usr/bin/compiler.jar'
-
-# Links generated by compress are valid for about ten years
-AWS_QUERYSTRING_EXPIRE = 60 * 60 * 24 * 365 * 10
-########## END COMPRESSION CONFIGURATION
-
-
-########## SECRET CONFIGURATION
-# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
-SECRET_KEY = environ.get('SECRET_KEY', SECRET_KEY)
-########## END SECRET CONFIGURATION
-
-########## DEBUG CONFIGURATION
-# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
-DEBUG = True
-
-# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
-TEMPLATE_DEBUG = DEBUG
-########## END DEBUG CONFIGURATION
-
-########## TESTING CONFIGURATION
-# Use django-nose to test our app, see https://github.com/jbalogh/django-nose
-TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
-########## END TESTING CONFIGURATION
-
-########## TOOLBAR CONFIGURATION
-# See: https://github.com/django-debug-toolbar/django-debug-toolbar#installation
-INSTALLED_APPS += (
- 'debug_toolbar',
- 'django_extensions',
- 'django_nose',
-)
-
-DEBUG_TOOLBAR_PANELS = (
- 'debug_toolbar.panels.versions.VersionsPanel',
- 'debug_toolbar.panels.timer.TimerPanel',
- 'debug_toolbar.panels.settings.SettingsPanel',
- 'debug_toolbar.panels.headers.HeadersPanel',
- 'debug_toolbar.panels.request.RequestPanel',
- 'debug_toolbar.panels.sql.SQLPanel',
- 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
- 'debug_toolbar.panels.templates.TemplatesPanel',
- 'debug_toolbar.panels.cache.CachePanel',
- 'debug_toolbar.panels.signals.SignalsPanel',
- 'debug_toolbar.panels.logging.LoggingPanel',
-)
-
-# See: https://github.com/django-debug-toolbar/django-debug-toolbar#installation
-INTERNAL_IPS = ('127.0.0.1',)
-
-# See: https://github.com/django-debug-toolbar/django-debug-toolbar#installation
-MIDDLEWARE_CLASSES += (
- 'debug_toolbar.middleware.DebugToolbarMiddleware',
-)
-########## END TOOLBAR CONFIGURATION
-
-########## PROFILING CONFIGURATION
-MIDDLEWARE_CLASSES += (
- 'karmaworld.apps.courses.middleware.ProfileMiddleware',
-)
-########## END PROFILING CONFIGURATION
-
-########## STATIC CONFIGURATION
-STATIC_URL = CLOUDFRONT_URL
-########## END STATIC CONFIGURATION
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(PROJECT_ROOT, 'karmaworld/apps'))
- os.environ.setdefault("DJANGO_SETTINGS_MODULE", "karmaworld.settings.prod")
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", os.environ['DJANGO_SETTINGS_MODULE'])
from django.core.management import execute_from_command_line