README.md 2.2 KB
Newer Older
luxcem's avatar
Readme    
luxcem committed
1
2
3
4
5
6
# LQDN RP

This project uses Django 1.11 and python >= 3.5

## Requirements

cynddl's avatar
cynddl committed
7
8
9
10
11
12
To run the project, start a virtual environment:

    $ virtualenv -p python3 env
    $ source ./env/bin/activate

and install all required Python dependencies for development and build:
luxcem's avatar
Readme    
luxcem committed
13
14
15
16

    $ pip install -r requirements.txt
    $ pip install -r requirements-dev.txt

17
To compile the CSS stylesheets and JS scripts, [install npm](https://www.npmjs.com/get-npm), then run
cynddl's avatar
cynddl committed
18
19
20
21
22
the following commands to run yarn (to fetch and install dependencies) and
webpack (to compile local assets)

    $ npm install -g yarn webpack
    $ yarn install
cynddl's avatar
cynddl committed
23
    $ yarn run webpack
cynddl's avatar
cynddl committed
24

25
26
In case you want to use the fixtures, you will need to install (git-lfs)[https://git-lfs.github.com/].

luxcem's avatar
Readme    
luxcem committed
27
28
29
## Settings

Create a file in `project/settings/env.py` which contains django
30
settings for **DEBUG**, **SECRET_KEY** and **SITE_ID**.
luxcem's avatar
Readme    
luxcem committed
31

32
33
For testing you can use `DEBUG = True`, a random string for
`SECRET_KEY` and `SITE_ID=1`.
luxcem's avatar
Readme    
luxcem committed
34
35
36
37
38
39

In production you can use env variables with

```python
os.environ["DJANGO_DEBUG"]
os.environ["DJANGO_SECRET_KEY"]
40
os.environ["DJANGO_SITE_ID"]
luxcem's avatar
Readme    
luxcem committed
41
42
```

nono's avatar
nono committed
43
You'll also need to define 
44

nono's avatar
nono committed
45
46
47
48
49
50
51
```python
os.environ["DJANGO_ALLOWED_HOSTS"]
```

containing the FQDN of the RP before being able to run in production.

**Warning** :If DEBUG is defined as True, ALLOWED_HOSTS is set to allow connections
52
53
from any hosts.

luxcem's avatar
Readme    
luxcem committed
54
55
## Database

56
You can run database migrations with :
luxcem's avatar
Readme    
luxcem committed
57

Okhin's avatar
Okhin committed
58
```sh
luxcem's avatar
Readme    
luxcem committed
59
    $ python manage.py migrate
Okhin's avatar
Okhin committed
60
61
```

62
63
64
65
66
Groups are initialized with the following command:
```sh
    $ python manage.py init_groups
```

Okhin's avatar
Okhin committed
67
68
69
70
71
72
You can seed the database with a provided fixtures
located in apps/rp/fixtures/all_articles.json:

```sh
    $ python manage.py loaddata all_articles.json
```
luxcem's avatar
Readme    
luxcem committed
73
74
75
76
77

## Dev server

To launch the dev server :

Okhin's avatar
Okhin committed
78
```sh
luxcem's avatar
Readme    
luxcem committed
79
    $ python manage.py runserver
Okhin's avatar
Okhin committed
80
```
luxcem's avatar
Readme    
luxcem committed
81

nono's avatar
nono committed
82
83
84
85
## Installation in production

You can use any uWSGI server configuration to run it as a normal Django app. See [this tutorial for more information.](https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-16-04).

luxcem's avatar
Readme    
luxcem committed
86
87
88
89
## Tests

To launch tests install requirements-tests.txt

Okhin's avatar
Okhin committed
90
```sh
luxcem's avatar
Readme    
luxcem committed
91
92
    $ pip install -r requirements-tests.txt
    $ pytest
Okhin's avatar
Okhin committed
93
```
luxcem's avatar
Readme    
luxcem committed
94
95
96

Coverage with

Okhin's avatar
Okhin committed
97
```sh
luxcem's avatar
Readme    
luxcem committed
98
    $ pytest --cov=.
Okhin's avatar
Okhin committed
99
```