Sith/README.md

103 lines
4.1 KiB
Markdown
Raw Normal View History

[![pipeline status](https://ae-dev.utbm.fr/ae/Sith/badges/master/pipeline.svg)](https://ae-dev.utbm.fr/ae/Sith/commits/master)
[![coverage report](https://ae-dev.utbm.fr/ae/Sith/badges/master/coverage.svg)](https://ae-dev.utbm.fr/ae/Sith/commits/master)
2018-10-04 19:29:19 +00:00
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
2018-11-08 20:26:49 +00:00
[![project chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://ae-dev.zulipchat.com)
2015-11-19 07:47:24 +00:00
## Sith AE
2015-11-19 07:45:21 +00:00
2016-01-29 15:29:24 +00:00
### Get started
2015-11-19 07:45:21 +00:00
To start working on the project, just run the following commands:
```bash
git clone https://ae-dev.utbm.fr/ae/Sith.git
cd Sith
virtualenv --system-site-packages --python=python3 env
source env/bin/activate
pip install -r requirements.txt
./manage.py setup
```
2015-11-19 07:45:21 +00:00
2016-01-29 15:29:24 +00:00
To start the simple development server, just run `python3 manage.py runserver`
2015-11-24 09:55:15 +00:00
2018-10-06 01:37:36 +00:00
### Logging errors with sentry
To connect the app to sentry.io, you must set the variable SENTRY_DSN in your settings custom. It's composed of the full link given on your sentry project
2016-01-29 15:29:24 +00:00
### Generating documentation
2015-11-24 09:55:15 +00:00
2016-01-29 15:29:24 +00:00
There is a Doxyfile at the root of the project, meaning that if you have Doxygen, you can run `doxygen Doxyfile` to
generate a complete HTML documentation that will be available in the *./doc/html/* folder.
2015-11-19 07:45:21 +00:00
2016-01-29 15:29:24 +00:00
### Dependencies:
2016-02-05 15:59:42 +00:00
See requirements.txt
2016-01-29 15:29:24 +00:00
2018-11-26 18:54:51 +00:00
You may need to install some dev libraries like `libmysqlclient-dev`, `libssl-dev`, `libjpeg-dev`, `python3-xapian`, or `zlib1g-dev` to install all the
2017-01-10 23:35:04 +00:00
requiered dependancies with pip. You may also need `mysql-client`. Don't also forget `python3-dev` if you don't have it
already.
You can check all of them with:
```bash
2018-11-26 18:54:51 +00:00
sudo apt install libmysqlclient-dev libssl-dev libjpeg-dev zlib1g-dev python3-dev libffi-dev python3-dev libgraphviz-dev pkg-config python3-xapian
2017-01-10 23:35:04 +00:00
```
2016-07-28 11:02:10 +00:00
On macos, you will need homebrew
```bash
2018-12-18 22:16:00 +00:00
brew install xapian
```
If it doesn't work it's because it need [this pull request](https://github.com/Homebrew/homebrew-core/pull/34835) to be validated.
2016-01-29 15:29:24 +00:00
The development is done with sqlite, but it is advised to set a more robust DBMS for production (Postgresql for example)
2017-05-01 13:48:45 +00:00
### Collecting statics for production:
2017-05-10 08:58:51 +00:00
We use scss in the project. In development environment (DEBUG=True), scss is compiled every time the file is needed. For production, it assumes you have already compiled every files and to do so, you need to use the following commands :
```bash
2017-05-10 08:58:51 +00:00
./manage.py collectstatic # To collect statics
./manage.py compilestatic # To compile scss in those statics
2017-05-01 13:48:45 +00:00
```
2015-11-19 07:45:21 +00:00
2016-02-05 15:59:42 +00:00
### Misc about development
#### Controlling the rights
When you need to protect an object, there are three levels:
* Editing the object properties
* Editing the object various values
* Viewing the object
Now you have many solutions in your model:
* You can define a `is_owned_by(self, user)`, a `can_be_edited_by(self, user)`, and/or a `can_be_viewed_by(self, user)`
method, each returning True is the user passed can edit/view the object, False otherwise.
This allows you to make complex request when the group solution is not powerful enough.
It's useful too when you want to define class-wide permissions, e.g. the club members, that are viewable only for
Subscribers.
* You can add an `owner_group` field, as a ForeignKey to Group. Second is an `edit_groups` field, as a ManyToMany to
Group, and third is a `view_groups`, same as for edit.
Finally, when building a class based view, which is highly advised, you just have to inherit it from CanEditPropMixin,
CanEditMixin, or CanViewMixin, which are located in core.views. Your view will then be protected using either the
appropriate group fields, or the right method to check user permissions.
2017-02-27 14:40:48 +00:00
#### Counting the number of line of code
```bash
sudo apt install cloc
cloc --exclude-dir=doc,env .
2017-02-27 14:40:48 +00:00
```
2016-02-05 15:59:42 +00:00
#### Updating doc/SYNTAX.md
If you make an update in the Markdown syntax parser, it's good to document
update the syntax reference page in `doc/SYNTAX.md`. But updating this file will
break the tests if you don't update the corresponding `doc/SYNTAX.html` file at
the same time.
To do that, simply run `./manage.py markdown > doc/SYNTAX.html`,
and the tests should pass again.
2016-02-05 15:59:42 +00:00