Skip to content

Commit

Permalink
Merge branch 'master' into feature/djmail
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-m committed May 6, 2016
2 parents a535a2f + 39299cc commit be16bb2
Show file tree
Hide file tree
Showing 137 changed files with 7,676 additions and 4,894 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@ bower_components/

# Upload's directory
poradnia/media/


docs/_build/
22 changes: 12 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,36 @@ cache:
- $HOME/.cache/pip

env:
fast_finish: true
global:
- DATABASE_URL="mysql://root:@localhost/test_feder"
- DJANGO_CONFIGURATION="Local"
matrix:
- TOX_ENV=coverage-py27-dj17
- TOX_ENV=flake8
- TOX_ENV=py27-dj18
- TOX_ENV=py27-djmaster
- TOX_ENV=py33-dj18
- TOX_ENV=py33-djmaster
- TOX_ENV=py27-dj18-coveralls
- TOX_ENV=py27-dj19-coveralls
- TOX_ENV=py27-djmaster-coveralls
- TOX_ENV=py33-dj18-coveralls
- TOX_ENV=py33-djmaster-coveralls

matrix:
allow_failures:
- env: TOX_ENV=flake8
- env: TOX_ENV=py27-djmaster
- env: TOX_ENV=py33-dj18
- env: TOX_ENV=py33-djmaster
- env: TOX_ENV=py27-dj19-coveralls
- env: TOX_ENV=py27-djmaster-coveralls
- env: TOX_ENV=py33-dj18-coveralls
- env: TOX_ENV=py33-djmaster-coveralls
- env: TOX_ENV=py33-dj19-coveralls


install:
- pip install -U pip wheel
- pip install tox
script:
- tox -e $TOX_ENV
- travis_retry tox -e $TOX_ENV

notifications:
slack: watchdogpolska:mQq180xGu9UcuJgK73hVWECD

after_script:
- rm $HOME/.cache/pip/log/*

149 changes: 34 additions & 115 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ poradnia
:target: https://requires.io/github/watchdogpolska/poradnia/requirements/?branch=master
:alt: Requirements Status

.. image:: https://img.shields.io/badge/translations-pl%20|%20en-brightgreen.svg
:target: https://crowdin.com/project/poradnia
:alt: Translations

.. image:: https://img.shields.io/github/issues/watchdogpolska/poradnia.svg
:target: https://github.com/watchdogpolska/poradnia/issues
:alt: GitHub issues counter
Expand All @@ -24,149 +20,72 @@ poradnia
:target: https://waffle.io/watchdogpolska/poradnia
:alt: 'Stories in High'

.. image:: https://www.quantifiedcode.com/api/v1/project/0b4753d4b3bd41f797b40458c3cea67a/badge.svg
:target: https://www.quantifiedcode.com/app/project/0b4753d4b3bd41f797b40458c3cea67a
:alt: Code issues

.. image:: https://coveralls.io/repos/watchdogpolska/poradnia/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/watchdogpolska/poradnia?branch=master

.. image:: https://badges.gitter.im/watchdogpolska/poradnia.svg
:target: https://gitter.im/watchdogpolska/poradnia?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
:alt: Gitter

Settings
------------

poradnia relies extensively on environment settings which **will not work with Apache/mod_wsgi setups**. It has been deployed successfully with both Gunicorn/Nginx and even uWSGI/Nginx.

For configuration purposes, the following table maps the 'poradnia' environment variables to their Django setting:

======================================= =========================== ============================================== ===========================================
Environment Variable Django Setting Development Default Production Default
======================================= =========================== ============================================== ===========================================
DJANGO_AWS_ACCESS_KEY_ID AWS_ACCESS_KEY_ID n/a raises error
DJANGO_AWS_SECRET_ACCESS_KEY AWS_SECRET_ACCESS_KEY n/a raises error
DJANGO_AWS_STORAGE_BUCKET_NAME AWS_STORAGE_BUCKET_NAME n/a raises error
DJANGO_CACHES CACHES locmem memcached
DJANGO_DATABASES DATABASES See code See code
DJANGO_DEBUG DEBUG True False
DJANGO_EMAIL_BACKEND EMAIL_BACKEND django.core.mail.backends.console.EmailBackend django.core.mail.backends.smtp.EmailBackend
DJANGO_SECRET_KEY SECRET_KEY CHANGEME!!! raises error
DJANGO_SECURE_BROWSER_XSS_FILTER SECURE_BROWSER_XSS_FILTER n/a True
DJANGO_SECURE_SSL_REDIRECT SECURE_SSL_REDIRECT n/a True
DJANGO_SECURE_CONTENT_TYPE_NOSNIFF SECURE_CONTENT_TYPE_NOSNIFF n/a True
DJANGO_SECURE_FRAME_DENY SECURE_FRAME_DENY n/a True
DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS HSTS_INCLUDE_SUBDOMAINS n/a True
DJANGO_SESSION_COOKIE_HTTPONLY SESSION_COOKIE_HTTPONLY n/a True
DJANGO_SESSION_COOKIE_SECURE SESSION_COOKIE_SECURE n/a False
======================================= =========================== ============================================== ===========================================

* TODO: Add vendor-added settings in another table

Getting up and running
----------------------

The steps below will get you up and running with a local development environment. We assume you have the following installed:
The steps below will get you up and running with a local development environment. We assume you have the following installed
First make sure to install all requires OS-level libraries and application (dependencies)::

* pip
* virtualenv
* PostgreSQL
$ sudo apt-get install python2.7 mariadb-server git libmariadbclient-dev virtualenv python-dev libffi-dev libssl-dev libjpeg-dev libpng12-dev libxml2-dev libxslt1-dev python-dev

First make sure to create and activate a virtualenv_, then open a terminal at the project root and install the requirements for local development::
Next to create and activate a virtualenv_::
$ virtualenv env
$ source env/bin/activate

$ pip install -r requirements/local.txt
.. _virtualenv: http://docs.python-guide.org/en/latest/dev/virtualenvs/

.. _virtualenv: http://docs.python-guide.org/en/latest/dev/virtualenvs/
Next to open a terminal at the project root and install the requirements for local development::

You can now run the usual Django ``runserver`` command (replace ``yourapp`` with the name of the directory containing the Django project)::
$ pip install pip wheel -U
$ pip install -r requirements/local.txt

$ python yourapp/manage.py runserver
Next to create MySQL database::
$ echo "CREATE DATABASE poradnia CHARACTER SET utf8 COLLATE utf8_polish_ci;" | mysql

The base app will run but you'll need to carry out a few steps to make the sign-up and login forms work. These are currently detailed in `issue #39`_.
Next to set up enviroment variables::

.. _issue #39: https://github.com/pydanny/cookiecutter-django/issues/39
$ export DJANGO_SETTINGS_MODULE="config.local"
$ export DATABASE_URL="mysql://user:pass@localhost/poradnia"

**Live reloading and Sass CSS compilation**
Next to push migrations into database::

If you'd like to take advantage of live reloading and Sass / Compass CSS compilation you can do so with the included Grunt task.
$ python poradnia/manage.py migrate

Make sure that nodejs_ is installed. Then in the project root run::
You can now run the usual Django ``runserver`` command::

$ npm install grunt
$ python poradnia/manage.py runserver

.. _nodejs: http://nodejs.org/download/
To run tests use::

Now you just need::
$ function run_test(){ DATABASE_URL="sqlite://" DJANGO_SETTINGS_MODULE='config.tests' python manage.py test $@ -v2}
$ pip install -r requirements/test.txt
$ run_test

$ grunt serve
**Live reloading and Sass CSS compilation**

The base app will now run as it would with the usual ``manage.py runserver`` but with live reloading and Sass compilation enabled.
If you'd like to take advantage of live reloading and Sass / Compass CSS compilation you can do so with the included Gulpfile task.

To get live reloading to work you'll probably need to install an `appropriate browser extension`_
Make sure that nodejs_ is installed. Then in the project root run::

.. _appropriate browser extension: http://feedback.livereload.com/knowledgebase/articles/86242-how-do-i-install-and-use-the-browser-extensions-
.. note:: TODO (see issue #207)

It's time to write the code!!!


Deployment
------------

It is possible to deploy to Heroku or to your own server by using Dokku, an open source Heroku clone.

Heroku
^^^^^^

Run these commands to deploy the project to Heroku:

.. code-block:: bash
heroku create --buildpack https://github.com/heroku/heroku-buildpack-python
heroku addons:create cleardb
heroku addons:create sendgrid:starter
heroku addons:create memcachier:dev
heroku config:set DATABASE_URL=$(heroku config | grep CLEARDB_DATABASE_URL | cut -d ' ' -f2)
heroku config:set DJANGO_CONFIGURATION=Production
heroku config:set DJANGO_SETTINGS_MODULE="config"
heroku config:set DJANGO_SECRET_KEY=RANDOM_SECRET_KEY_HERE
heroku config:set DJANGO_EMAIL_HOST_USER=$(heroku config | grep SENDGRID_USERNAME | cut -d ' ' -f2)
heroku config:set DJANGO_EMAIL_HOST_PASSWORD=$(heroku config | grep SENDGRID_PASSWORD | cut -d ' ' -f2)
heroku config:set DJANGO_SERVER_EMAIL="smtp.sendgrid.com"
heroku config:set WHITENOISE_USE="True"
git push heroku master
heroku run python poradnia/manage.py migrate
heroku run python poradnia/manage.py createsuperuser
heroku open
Dokku
^^^^^

You need to make sure you have a server running Dokku with at least 1GB of RAM. Backing services are
added just like in Heroku however you must ensure you have the relevant Dokku plugins installed.

.. code-block:: bash
cd /var/lib/dokku/plugins
git clone https://github.com/rlaneve/dokku-link.git link
git clone https://github.com/jezdez/dokku-memcached-plugin memcached
git clone https://github.com/jezdez/dokku-postgres-plugin postgres
dokku plugins-install
You can specify the buildpack you wish to use by creating a file name .env containing the following.

.. code-block:: bash
export BUILDPACK_URL=<repository>
You can then deploy by running the following commands.

.. code-block:: bash
git remote add dokku dokku@yourservername.com:poradnia
git push dokku master
ssh -t dokku@yourservername.com dokku memcached:create poradnia-memcached
ssh -t dokku@yourservername.com dokku memcached:link poradnia-memcached poradnia
ssh -t dokku@yourservername.com dokku mysql:create poradnia-mysql
ssh -t dokku@yourservername.com dokku mysql:link poradnia-mysq ploradnia
ssh -t dokku@yourservername.com dokku config:set .... # See heroku installation
ssh -t dokku@yourservername.com dokku run poradnia python poradnia/manage.py migrate
ssh -t dokku@yourservername.com dokku run poradnia python poradnia/manage.py createsuperuser
When deploying via Dokku make sure you backup your database in some fashion as it is NOT done automatically.
It is possible to deploy to Heroku or to your own server by using Dokku, an open source Heroku clone. The recomend way is using Virtual Private Server with Ubuntu Server and Nginx.
6 changes: 3 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"tests"
],
"dependencies": {
"font-awesome": "~4.3.0",
"font-awesome": "4.5.0",
"bootstrap-sass": "~3.3.4",
"pikaday-time": "~1.3.3",
"moment": "~2.10.3"
"pikaday-time": "1.4.0",
"moment": "2.12.0"
}
}

0 comments on commit be16bb2

Please sign in to comment.