Commit a88430d4 authored by Soldat's avatar Soldat 🤦🏻

Merge branch 'black' into 'master'

Passer black sur tout le repo et l'imposer

See merge request !159
parents d1d1ba4a d2fe9e56
Pipeline #1537 passed with stage
in 7 minutes and 46 seconds
...@@ -4,6 +4,7 @@ db.sqlite3 ...@@ -4,6 +4,7 @@ db.sqlite3
*.mo *.mo
*__pycache__* *__pycache__*
.DS_Store .DS_Store
.vscode/
env/ env/
doc/html doc/html
data/ data/
......
stages:
- test
test: test:
stage: test
script: script:
- apt-get update - apt-get update
- apt-get install -y gettext - apt-get install -y gettext
...@@ -11,3 +15,9 @@ test: ...@@ -11,3 +15,9 @@ test:
artifacts: artifacts:
paths: paths:
- coverage_report/ - coverage_report/
black:
stage: test
script:
- pip install black
- black --check .
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
Hey ! Tu veux devenir un mec bien et en plus devenir bon en python si tu l'es pas déjà ? Hey ! Tu veux devenir un mec bien et en plus devenir bon en python si tu l'es pas déjà ?
Il se trouve que le sith AE prévu pour l'été 2016 a besoin de toi ! Il se trouve que le sith AE prévu pour l'été 2016 a besoin de toi !
Pour faire le sith, on utilise le framework Web [Django](https://docs.djangoproject.com/fr/1.8/intro/) Pour faire le sith, on utilise le framework Web [Django](https://docs.djangoproject.com/fr/1.11/intro/)
N'hésite pas à lire les tutos et à nous demander (ae.info@utbm.fr). N'hésite pas à lire les tutos et à nous demander (ae.info@utbm.fr).
Bon, passons aux choses sérieuses, pour bidouiller le sith sans le casser : Bon, passons aux choses sérieuses, pour bidouiller le sith sans le casser :
...@@ -17,31 +17,81 @@ Ensuite, tu fais : ...@@ -17,31 +17,81 @@ Ensuite, tu fais :
`git clone https://ae-dev.utbm.fr/ae/Sith.git` `git clone https://ae-dev.utbm.fr/ae/Sith.git`
Avec cette commande, tu clones le sith AE dans le dossier courant. Avec cette commande, tu clones le sith AE dans le dossier courant.
```bash
cd Sith cd Sith
virtualenv --clear --python=python3 env_sith virtualenv --clear --python=python3 env_sith
source env_sith/bin/activate source env_sith/bin/activate
pip install -r requirements.txt pip install -r requirements.txt
```
Maintenant, faut passer le sith en mode debug dans le fichier de settings personnalisé. Maintenant, faut passer le sith en mode debug dans le fichier de settings personnalisé.
```bash
echo "DEBUG=True" > sith/settings_custom.py echo "DEBUG=True" > sith/settings_custom.py
echo 'EXTERNAL_RES = "False"' >> sith/settings_custom.py echo 'EXTERNAL_RES = "False"' >> sith/settings_custom.py
echo 'SITH_URL = "localhost:8000"' >> sith/settings_custom.py echo 'SITH_URL = "localhost:8000"' >> sith/settings_custom.py
```
Enfin, il s'agit de créer la base de donnée de test lors de la première utilisation Enfin, il s'agit de créer la base de donnée de test lors de la première utilisation
```bash
./manage.py setup ./manage.py setup
répondre no ```
Et pour lancer le sith, tu fais `python3 manage.py runserver` Et pour lancer le sith, tu fais `python3 manage.py runserver`
Voilà, c'est le sith AE. Il y a des issues dans le gitlab qui sont à régler. Si tu as un domaine qui t'intéresse, une appli que tu voudrais développer, n'hésites pas et contacte-nous. Voilà, c'est le sith AE. Il y a des issues dans le gitlab qui sont à régler. Si tu as un domaine qui t'intéresse, une appli que tu voudrais développer, n'hésites pas et contacte-nous.
Va, et que l'AE soit avec toi. Va, et que l'AE soit avec toi.
# Black
Pour uniformiser le formattage du code nous utilisons [Black](https://github.com/ambv/black). Cela permet d'avoir le même codestyle et donc le codereview prend moins de temps. Tout étant dans le même format, il est plus facile pour chacun de comprendre le code de chacun ! Cela permet aussi d'éviter des erreurs (y parait 🤷‍♀️).
Installation de black:
```bash
pip install black
```
## Sous VsCode:
Attention, pour VsCode, Black doit être installé dans votre virtualenv !
Ajouter ces deux lignes dans les settings de VsCode
```json
{
"python.formatting.provider": "black",
"editor.formatOnSave": true
}
```
## Sous Sublime Text
Il faut installer le plugin [sublack](https://packagecontrol.io/packages/sublack) depuis Package Control.
Il suffit ensuite d'ajouter dans les settings du projet (ou en global)
```json
{
"sublack.black_on_save": true
}
```
Si vous utilisez le plugin [anaconda](http://damnwidget.github.io/anaconda/), pensez à modifier les paramètres du linter pep8 pour éviter de recevoir des warnings dans le formatage de black
```json
{
"pep8_ignore": [
"E203",
"E266",
"E501",
"W503"
]
}
```
Sites et doc cools Sites et doc cools
------------------ ------------------
[Classy Class-Based Views](http://ccbv.co.uk/projects/Django/1.8/) [Classy Class-Based Views](http://ccbv.co.uk/projects/Django/1.11/)
Helpers: Helpers:
......
[![pipeline status](https://ae-dev.utbm.fr/ae/Sith/badges/master/pipeline.svg)](https://ae-dev.utbm.fr/ae/Sith/commits/master) [![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) [![coverage report](https://ae-dev.utbm.fr/ae/Sith/badges/master/coverage.svg)](https://ae-dev.utbm.fr/ae/Sith/commits/master)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
## Sith AE ## Sith AE
......
...@@ -21,4 +21,3 @@ ...@@ -21,4 +21,3 @@
# Place - Suite 330, Boston, MA 02111-1307, USA. # Place - Suite 330, Boston, MA 02111-1307, USA.
# #
# #
This diff is collapsed.
...@@ -7,54 +7,88 @@ from django.db import migrations, models ...@@ -7,54 +7,88 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('club', '0001_initial'), ("club", "0001_initial"),
('accounting', '0001_initial'), ("accounting", "0001_initial"),
('core', '0001_initial'), ("core", "0001_initial"),
] ]
operations = [ operations = [
migrations.AddField( migrations.AddField(
model_name='operation', model_name="operation",
name='invoice', name="invoice",
field=models.ForeignKey(null=True, related_name='operations', verbose_name='invoice', to='core.SithFile', blank=True), field=models.ForeignKey(
null=True,
related_name="operations",
verbose_name="invoice",
to="core.SithFile",
blank=True,
),
), ),
migrations.AddField( migrations.AddField(
model_name='operation', model_name="operation",
name='journal', name="journal",
field=models.ForeignKey(verbose_name='journal', to='accounting.GeneralJournal', related_name='operations'), field=models.ForeignKey(
verbose_name="journal",
to="accounting.GeneralJournal",
related_name="operations",
),
), ),
migrations.AddField( migrations.AddField(
model_name='operation', model_name="operation",
name='linked_operation', name="linked_operation",
field=models.OneToOneField(blank=True, to='accounting.Operation', null=True, related_name='operation_linked_to', verbose_name='linked operation', default=None), field=models.OneToOneField(
blank=True,
to="accounting.Operation",
null=True,
related_name="operation_linked_to",
verbose_name="linked operation",
default=None,
),
), ),
migrations.AddField( migrations.AddField(
model_name='operation', model_name="operation",
name='simpleaccounting_type', name="simpleaccounting_type",
field=models.ForeignKey(null=True, related_name='operations', verbose_name='simple type', to='accounting.SimplifiedAccountingType', blank=True), field=models.ForeignKey(
null=True,
related_name="operations",
verbose_name="simple type",
to="accounting.SimplifiedAccountingType",
blank=True,
),
), ),
migrations.AddField( migrations.AddField(
model_name='generaljournal', model_name="generaljournal",
name='club_account', name="club_account",
field=models.ForeignKey(verbose_name='club account', to='accounting.ClubAccount', related_name='journals'), field=models.ForeignKey(
verbose_name="club account",
to="accounting.ClubAccount",
related_name="journals",
),
), ),
migrations.AddField( migrations.AddField(
model_name='clubaccount', model_name="clubaccount",
name='bank_account', name="bank_account",
field=models.ForeignKey(verbose_name='bank account', to='accounting.BankAccount', related_name='club_accounts'), field=models.ForeignKey(
verbose_name="bank account",
to="accounting.BankAccount",
related_name="club_accounts",
),
), ),
migrations.AddField( migrations.AddField(
model_name='clubaccount', model_name="clubaccount",
name='club', name="club",
field=models.ForeignKey(verbose_name='club', to='club.Club', related_name='club_account'), field=models.ForeignKey(
verbose_name="club", to="club.Club", related_name="club_account"
),
), ),
migrations.AddField( migrations.AddField(
model_name='bankaccount', model_name="bankaccount",
name='club', name="club",
field=models.ForeignKey(verbose_name='club', to='club.Club', related_name='bank_accounts'), field=models.ForeignKey(
verbose_name="club", to="club.Club", related_name="bank_accounts"
),
), ),
migrations.AlterUniqueTogether( migrations.AlterUniqueTogether(
name='operation', name="operation", unique_together=set([("number", "journal")])
unique_together=set([('number', 'journal')]),
), ),
] ]
...@@ -7,44 +7,44 @@ import phonenumber_field.modelfields ...@@ -7,44 +7,44 @@ import phonenumber_field.modelfields
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [("accounting", "0002_auto_20160824_2152")]
('accounting', '0002_auto_20160824_2152'),
]
operations = [ operations = [
migrations.AddField( migrations.AddField(
model_name='company', model_name="company",
name='city', name="city",
field=models.CharField(blank=True, verbose_name='city', max_length=60), field=models.CharField(blank=True, verbose_name="city", max_length=60),
), ),
migrations.AddField( migrations.AddField(
model_name='company', model_name="company",
name='country', name="country",
field=models.CharField(blank=True, verbose_name='country', max_length=32), field=models.CharField(blank=True, verbose_name="country", max_length=32),
), ),
migrations.AddField( migrations.AddField(
model_name='company', model_name="company",
name='email', name="email",
field=models.EmailField(blank=True, verbose_name='email', max_length=254), field=models.EmailField(blank=True, verbose_name="email", max_length=254),
), ),
migrations.AddField( migrations.AddField(
model_name='company', model_name="company",
name='phone', name="phone",
field=phonenumber_field.modelfields.PhoneNumberField(blank=True, verbose_name='phone', max_length=128), field=phonenumber_field.modelfields.PhoneNumberField(
blank=True, verbose_name="phone", max_length=128
),
), ),
migrations.AddField( migrations.AddField(
model_name='company', model_name="company",
name='postcode', name="postcode",
field=models.CharField(blank=True, verbose_name='postcode', max_length=10), field=models.CharField(blank=True, verbose_name="postcode", max_length=10),
), ),
migrations.AddField( migrations.AddField(
model_name='company', model_name="company",
name='street', name="street",
field=models.CharField(blank=True, verbose_name='street', max_length=60), field=models.CharField(blank=True, verbose_name="street", max_length=60),
), ),
migrations.AddField( migrations.AddField(
model_name='company', model_name="company",
name='website', name="website",
field=models.CharField(blank=True, verbose_name='website', max_length=64), field=models.CharField(blank=True, verbose_name="website", max_length=64),
), ),
] ]
...@@ -7,26 +7,45 @@ import django.db.models.deletion ...@@ -7,26 +7,45 @@ import django.db.models.deletion
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [("accounting", "0003_auto_20160824_2203")]
('accounting', '0003_auto_20160824_2203'),
]
operations = [ operations = [
migrations.CreateModel( migrations.CreateModel(
name='Label', name="Label",
fields=[ fields=[
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True, serialize=False)), (
('name', models.CharField(max_length=64, verbose_name='label')), "id",
('club_account', models.ForeignKey(related_name='labels', verbose_name='club account', to='accounting.ClubAccount')), models.AutoField(
verbose_name="ID",
primary_key=True,
auto_created=True,
serialize=False,
),
),
("name", models.CharField(max_length=64, verbose_name="label")),
(
"club_account",
models.ForeignKey(
related_name="labels",
verbose_name="club account",
to="accounting.ClubAccount",
),
),
], ],
), ),
migrations.AddField( migrations.AddField(
model_name='operation', model_name="operation",
name='label', name="label",
field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, related_name='operations', null=True, blank=True, verbose_name='label', to='accounting.Label'), field=models.ForeignKey(
on_delete=django.db.models.deletion.SET_NULL,
related_name="operations",
null=True,
blank=True,
verbose_name="label",
to="accounting.Label",
),
), ),
migrations.AlterUniqueTogether( migrations.AlterUniqueTogether(
name='label', name="label", unique_together=set([("name", "club_account")])
unique_together=set([('name', 'club_account')]),
), ),
] ]
...@@ -6,14 +6,14 @@ from django.db import migrations, models ...@@ -6,14 +6,14 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [("accounting", "0004_auto_20161005_1505")]
('accounting', '0004_auto_20161005_1505'),
]
operations = [ operations = [
migrations.AlterField( migrations.AlterField(
model_name='operation', model_name="operation",
name='remark', name="remark",
field=models.CharField(null=True, max_length=128, blank=True, verbose_name='comment'), field=models.CharField(
), null=True, max_length=128, blank=True, verbose_name="comment"
),
)
] ]
This diff is collapsed.
This diff is collapsed.
...@@ -28,46 +28,125 @@ from accounting.views import * ...@@ -28,46 +28,125 @@ from accounting.views import *
urlpatterns = [ urlpatterns = [
# Accounting types # Accounting types
url(r'^simple_type$', SimplifiedAccountingTypeListView.as_view(), name='simple_type_list'), url(
url(r'^simple_type/create$', SimplifiedAccountingTypeCreateView.as_view(), name='simple_type_new'), r"^simple_type$",
url(r'^simple_type/(?P<type_id>[0-9]+)/edit$', SimplifiedAccountingTypeEditView.as_view(), name='simple_type_edit'), SimplifiedAccountingTypeListView.as_view(),
name="simple_type_list",
),
url(
r"^simple_type/create$",
SimplifiedAccountingTypeCreateView.as_view(),
name="simple_type_new",
),
url(
r"^simple_type/(?P<type_id>[0-9]+)/edit$",
SimplifiedAccountingTypeEditView.as_view(),
name="simple_type_edit",
),
# Accounting types # Accounting types
url(r'^type$', AccountingTypeListView.as_view(), name='type_list'), url(r"^type$", AccountingTypeListView.as_view(), name="type_list"),
url(r'^type/create$', AccountingTypeCreateView.as_view(), name='type_new'), url(r"^type/create$", AccountingTypeCreateView.as_view(), name="type_new"),
url(r'^type/(?P<type_id>[0-9]+)/edit$', AccountingTypeEditView.as_view(), name='type_edit'), url(
r"^type/(?P<type_id>[0-9]+)/edit$",
AccountingTypeEditView.as_view(),
name="type_edit",
),
# Bank accounts # Bank accounts
url(r'^$', BankAccountListView.as_view(), name='bank_list'), url(r"^$", BankAccountListView.as_view(), name="bank_list"),
url(r'^bank/create$', BankAccountCreateView.as_view(), name='bank_new'), url(r"^bank/create$", BankAccountCreateView.as_view(), name="bank_new"),
url(r'^bank/(?P<b_account_id>[0-9]+)$', BankAccountDetailView.as_view(), name='bank_details'), url(
url(r'^bank/(?P<b_account_id>[0-9]+)/edit$', BankAccountEditView.as_view(), name='bank_edit'), r"^bank/(?P<b_account_id>[0-9]+)$",
url(r'^bank/(?P<b_account_id>[0-9]+)/delete$', BankAccountDeleteView.as_view(), name='bank_delete'), BankAccountDetailView.as_view(),
name="bank_details",
),
url(
r"^bank/(?P<b_account_id>[0-9]+)/edit$",
BankAccountEditView.as_view(),
name="bank_edit",
),
url(
r"^bank/(?P<b_account_id>[0-9]+)/delete$",
BankAccountDeleteView.as_view(),
name="bank_delete",
),
# Club accounts # Club accounts
url(r'^club/create$', ClubAccountCreateView.as_view(), name='club_new'), url(r"^club/create$", ClubAccountCreateView.as_view(), name="club_new"),
url(r'^club/(?P<c_account_id>[0-9]+)$', ClubAccountDetailView.as_view(), name='club_details'), url(
url(r'^club/(?P<c_account_id>[0-9]+)/edit$', ClubAccountEditView.as_view(), name='club_edit'), r"^club/(?P<c_account_id>[0-9]+)$",
url(r'^club/(?P<c_account_id>[0-9]+)/delete$', ClubAccountDeleteView.as_view(), name='club_delete'), ClubAccountDetailView.as_view(),
name="club_details",
),
url(
r"^club/(?P<c_account_id>[0-9]+)/edit$",
ClubAccountEditView.as_view(),
name="club_edit",
),
url(
r"^club/(?P<c_account_id>[0-9]+)/delete$",
ClubAccountDeleteView.as_view(),
name="club_delete",
),
# Journals # Journals
url(r'^journal/create$', JournalCreateView.as_view(), name='journal_new'), url(r"^journal/create$", JournalCreateView.as_view(), name="journal_new"),
url(r'^journal/(?P<j_id>[0-9]+)$', JournalDetailView.as_view(), name='journal_details'), url(
url(r'^journal/(?P<j_id>[0-9]+)/edit$', JournalEditView.as_view(), name='journal_edit'), r"^journal/(?P<j_id>[0-9]+)$",
url(r'^journal/(?P<j_id>[0-9]+)/delete$', JournalDeleteView.as_view(), name='journal_delete'), JournalDetailView.as_view(),
url(r'^journal/(?P<j_id>[0-9]+)/statement/nature$', JournalNatureStatementView.as_view(), name='journal_nature_statement'), name="journal_details",
url(r'^journal/(?P<j_id>[0-9]+)/statement/person$', JournalPersonStatementView.as_view(), name='journal_person_statement'), ),
url(r'^journal/(?P<j_id>[0-9]+)/statement/accounting$', JournalAccountingStatementView.as_view(), name='journal_accounting_statement'), url(
r"^journal/(?P<j_id>[0-9]+)/edit$",
JournalEditView.as_view(),
name="journal_edit",
),
url(
r"^journal/(?P<j_id>[0-9]+)/delete$",
JournalDeleteView.as_view(),
name="journal_delete",
),
url(
r"^journal/(?P<j_id>[0-9]+)/statement/nature$",
JournalNatureStatementView.as_view(),
name="journal_nature_statement",
),
url(
r"^journal/(?P<j_id>[0-9]+)/statement/person$",
JournalPersonStatementView.as_view(),
name="journal_person_statement",
),
url(
r"^journal/(?P<j_id>[0-9]+)/statement/accounting$",
JournalAccountingStatementView.as_view(),
name="journal_accounting_statement",
),
# Operations # Operations
url(r'^operation/create/(?P<j_id>[0-9]+)$', OperationCreateView.as_view(), name='op_new'), url(
url(r'^operation/(?P<op_id>[0-9]+)$', OperationEditView.as_view(), name='op_edit'), r"^operation/create/(?P<j_id>[0-9]+)$",
url(r'^operation/(?P<op_id>[0-9]+)/pdf$', OperationPDFView.as_view(), name='op_pdf'), OperationCreateView.as_view(),
name="op_new",
),
url(r"^operation/(?P<op_id>[0-9]+)$", OperationEditView.as_view(), name="op_edit"),
url(
r"^operation/(?P<op_id>[0-9]+)/pdf$", OperationPDFView.as_view(), name="op_pdf"
),
# Companies # Companies
url(r'^company/list$', CompanyListView.as_view(), name='co_list'), url(r"^company/list$", CompanyListView.as_view(), name="co_list"),
url(r'^company/create$', CompanyCreateView.as_view(), name='co_new'), url(r"^company/create$", CompanyCreateView.as_view(), name="co_new"),
url(r'^company/(?P<co_id>[0-9]+)$', CompanyEditView.as_view(), name='co_edit'), url(r"^company/(?P<co_id>[0-9]+)$", CompanyEditView.as_view(), name="co_edit"),
# Labels # Labels
url(r'^label/new$', LabelCreateView.as_view(), name='label_new'), url(r"^label/new$", LabelCreateView.as_view(), name="label_new"),
url(r'^label/(?P<clubaccount_id>[0-9]+)$', LabelListView.as_view(), name='label_list'), url(