Installation¶
Connect is currently tested with Python 3.4
and Django 1.7 & 1.8
.
Dependencies¶
You will need to have the following installed:
- Python 3
- pip
- virtualenv-wrapper
- PostgreSQL (although sqlite can be used on dev machines)
You may also need to install libyaml:
# On Ubuntu
$ sudo apt-get install libyaml-dev
# Or Fedora
$ sudo yum install libyaml-devel
Next setup your virtualenv with:
$ mkvirtualenv --python=/usr/bin/python3 connect
$ pip install -r requirements/dev.txt
Postgres setup¶
Postgres is not required for local development, but it can be a good idea – running tests against the same database as production can sometimes pick up edge case bugs early.
If you’re setting up a staging, production, or CI server, postgres is strongly
recommended. Install it with sudo apt-get install postgresql-9.4
or similar,
and then set up a database for the connect app:
$ createdb connectdb
$ createuser -P connectuser # note password chosen
$ psql
=# GRANT ALL PRIVILEGES ON DATABASE connectdb TO connectuser;
=# ALTER USER connectuser CREATEDB;
=# \l # Check database access permissions
=# \q # (or Ctrl-D) Exit from psql
(You can substitute connectdb and connectuser as you wish, you will just need to reflect that in the DATABASE_URL
you set below.)
Environment variables¶
A fully configured connect instance requires the following environment variables:
DATABASE_URL
– db config syntax:"postgres://USER:PASSWORD@HOST:PORT/DB-NAME"
SECRET_KEY
– this should not be stored in your repository.ALLOWED_HOSTS
– required whenDEBUG=False
, so for staging/ci/prod.DEFAULT_FROM_EMAIL
– the from address for in-app emailsMANDRILL_API_KEY
– Mandrill is recommend for sending emails from the serverDJANGO_MODE
– outside dev, set this to “Production” or “Staging”
All of these have working defaults in dev, but if you want to override any of them (eg to use postgres), you can set them like this:
export DATABASE_URL="postgres://connectuser:<password>@localhost:5432/connectdb"
export SECRET_KEY="a long string of random characters"
export DEFAULT_FROM_EMAIL="admin@mentorconnect.com"
#... etc
Tip
A good place to set them is in the postactivate
virtualenv hook,
which will be somewhere like ~/.virtualenvs/connect/bin/postactivate. For
neatness, unset them in the predeactivate
virtualenv hook too:
unset DATABASE_URL
unset SECRET_KEY
unset DEFAULT_FROM_EMAIL
#... etc
Initial database setup¶
First sync the database:
$ python manage.py migrate
Then create a superuser:
$ python manage.py createsuperuser
Now you can run your local sever:
$ python manage.py runserver
And you’ll be able to open up the development site in your web browser at http://localhost:8000/
Important
Now that your site is up and running, you will need to login to the admin and:
- Set
is_moderator
toTrue
for your superuser. - Set up some additional data in your database. (See Site Configuration for more information.)
Running Tests¶
$ python manage.py test #to test the entire project.
$ python manage.py test connect/appname #to test a specific django app
To run Connect’s Behave tests, you will need to have PhantomJS installed.
$ npm install phantomjs
Run the BDD tests with:
$ python manage.py test bdd
To run an individual test feature, use
$ npm install phantomjs
$ python manage.py test bdd --behave_include featurename
Alternatively you can use any other supported browser (e.g. Chrome, Firefox) by installing it on your system and specifying it when you run your tests:
$ python manage.py test bdd --behave_browser <browser>
Editing SCSS files (style)¶
Connect is built with Sass and Compass.
To use them you will also need ruby
- the installation process for this is beyond the scope of these instructions. Please refer to the Saas and Compass documentation for more information.
To compile your SCSS into CSS, use:
compass compile connect/static/css # where final argument is a path to the css folder
Or you can automatically update your changes with:
compass watch connect/static/css # where final argument is a path to the css folder
Example: Changing the highlighting color
You can change the default pink highlight color by editing the $highlight
variable at the top of static/css/sass/_color.scss
Additional configuration¶
In settings.py
, you may also wish to override:
- Admins
- Timezone
- Gravatar Settings