Bjwebb / bookish

0 stars 2 forks source link

Bookish

.. image:: https://travis-ci.org/Bjwebb/bookish.svg?branch=master :target: https://travis-ci.org/Bjwebb/bookish

.. image:: https://requires.io/github/Bjwebb/bookish/requirements.svg?branch=master :target: https://requires.io/github/Bjwebb/bookish/requirements/?branch=master :alt: Requirements Status

.. image:: https://coveralls.io/repos/Bjwebb/bookish/badge.png?branch=master :target: https://coveralls.io/r/Bjwebb/bookish?branch=master

.. image:: https://img.shields.io/badge/license-AGPLv3-blue.svg :target: https://github.com/Bjwebb/bookish/blob/master/AGPLv3.txt

Introduction

This project is a work in progress and does very little at the moment.

Demo

WARNING: All data entered into the demo will be DELETED periodically.

A demo instance is currently available at http://bookish.bjwebb.co.uk/

This has been Deployed using Salt and Docker, see Deployment_ for more.

Demo login details

The demo install is set up with the following accounts:

=============== =============== username password =============== =============== demo_admin demo_admin demo_accountant demo_accountant demo_client demo_client =============== ===============

Local Demo - Using Docker

WARNING: All data entered into the demo will be DELETED when it stops running.

To run the demo, you must have docker installed: https://docs.docker.com/installation/

However, once you have Docker installed (or if you have it installed already), you only need one command to run the demo:

.. code:: bash

sudo docker run -p 8000:8000 bjwebb/bookish-demo

This will download the image needed to run the demo, and then end with "Status: Downloaded newer image for bjwebb/bookish-demo:latest". Once this has happened, the demo site will be available at http://localhost:8000/ <http://localhost:8000/>__

If you want, you can choose a port other than 8000 e.g. 1234:

.. code:: bash

sudo docker run -p 1234:8000 bjwebb/bookish-demo

The demo can then be viewed at http://localhost:1234/ <http://localhost:1234/>__

If you've previously run the demo, and want to update it to the latest copy of the code:

.. code:: bash

sudo docker pull bjwebb/bookish-demo

Local Demo - Without Docker

.. code:: bash

git clone git@github.com:Bjwebb/bookish.git
cd bookish
virtualenv pyenv --python=/usr/bin/python3
source pyenv/bin/activate
pip install -r requirements.txt
cp env.demo .env
python manage.py migrate
python manage.py createdemodata
python manage.py runserver

The demo site should now be available at http://localhost:8000/ <http://localhost:8000/>__

Flushing the database

Sometimes in development you want flush the database and reload the demo data

.. code:: bash

python manage.py flush --noinput; python manage.py createdemodata

Installation

If you want to build your own docker image (for example if you want to make local changes and then test):

.. code:: bash

git clone git@github.com:Bjwebb/bookish.git
cd bookish
docker build -t bookish .
cp env.example .env # and edit
docker run --rm --env-file=.env bookish python manage.py migrate
docker run --rm -ti --env-file=.env bookish python manage.py createsuperuser
docker run --rm -p 8000:8000 --env-file=.env bookish

If you want to run the code without docker:

.. code:: bash

git clone git@github.com:Bjwebb/bookish.git
cd bookish
virtualenv pyenv --python=/usr/bin/python3
source pyenv/bin/activate
pip install -r requirements.txt
cp env.example .env # and edit
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver

Setting up a postgres database

.. code:: bash

sudo -u postgres createuser bookish -P
sudo -u postgres createdb bookish -O bookish -E utf8

The first command will prompt for a password, it's probably best to use a random one (e.g. generated by openssl rand -hex 32).

Setting up your local system for development

Set up flake8 to run on every git commit:

.. code:: bash

flake8 --install-hook

By default this still opens your text editor to make the commit message, and prints the flake8 errors to STDOUT where you might miss them. Only show the flake8 errors and not open the editor (until the flake8 errors are fixed), set STRICT to True in .git/hooks/pre-commit.

Running the tests

Ensure you have the requirements for the tests installed:

.. code:: bash

source pyenv/bin/activate
pip install -r requirements_test.txt

Then run the tests:

.. code:: bash

SECRET_KEY=test DATABASE_URL=sqlite:///test.db py.test --ignore=pyenv

With the most recent version of firefox, selenium webdriver doesn't run properly. You can use chrome instead with the USE_CHROME environment variable:

.. code:: bash

USE_CHROME=1 SECRET_KEY=test DATABASE_URL=sqlite:///test.db py.test --ignore=pyenv

If you want to generate your own coverage report, you can run:

.. code:: bash

USE_CHROME=1 SECRET_KEY=test DATABASE_URL=sqlite:///test.db py.test --ignore=pyenv --cov . --cov-report html

Then open htmlcov/index.html in a web browser.

Deployment

We will make deployments of Bookish using Salt <http://docs.saltstack.com/en/latest/>. Currently there are no production deployments of Bookish. However, the demo deployment is described in the bookish-deploy <https://github.com/bjwebb/bookish-deploy> repository.

License

::

Copyright (C) 2014-2015 Ben Webb <bjwebb67@googlemail.com>
Copyright (C) 2014-2015 David Carpenter <caprenter@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.