Collab is a Django project with a standard set of configurations to provide services to reusable apps.
Core Collab comes with:
- Tagging (using a customized version of django-taggit)
- Notifications
- Search (using Haystack and Elasticsearch)
- Migrations (using South)
- jQuery
- Improved Caching
Requirements:
- Python (>= 2.6)
- Mysql
Follow these steps to set up collab:
-
Clone this repo or a fork of it
git clone https://github.com/cfpb/collab.git cd collab
-
Make sure you have
pip
andvirtualenv
installed:easy_install -U pip pip install -U pip pip install -U virtualenv
You may have to prepend these commands with
sudo
, depending on your setup. -
Create a virtual environment for the project and install the necessary packages:
virtualenv --no-site-packages --distribute venv # creates the virtualenv named "venv" source venv/bin/activate # activates (places you in) the virtualenv pip install -r requirements.txt # installs main required packages for collab pip install -r requirements-test.txt # installs packages required for testing
Important Note: Anytime you restart your terminal and return to work on this project, you will need to reactivate the virtualenv by running the
source venv/bin/activate
command from the collab root. See virtualenv for more details. -
Copy
collab/local_settings_template.py
tocollab/local_settings.py
and edit to match your current environment. In particular, update theDATABASES
information. You will need to create the database you choose for the default schema.- Edit
DATABASES
(in theelse
block) to set the database user and password to whatever user you have set up in MySQL (probablyroot
with no password, since it's local to your machine). - Set a
SECRET KEY
. This can be any string you want. - If you have already set up any other child apps besides the four required, uncomment them in
INSTALLED_APPS
.
- Edit
-
Set up the database:
mysql.server start mysql -u <user> -e 'create database collab' python ./manage.py syncdb python ./manage.py syncdb --noinput --migrate python ./manage.py loaddata core/fixtures/core-test-fixtures.json
Optionally, you can create random users for local testing.
python ./manage.py create_users <number of users>
-
Run the Django server:
python ./manage.py runserver
-
Go to http://localhost:8000 in your browser and log in with user
test1@example.com
and password1
. -
You are a winner!
To run tests:
python manage.py test
Models should have a robust set of unit tests.
When writing unit tests for models, try to separate functionality which needs the DB from functionality which does not. Aim to avoid hitting the DB in a test for optimal results.
Views should have unit testing for functional parts of them: that is, try to extract functionality without side effects from the view functions, and then test those extracted functions.
Views should have system testing using WebTest for page interaction.