Skip to content

Commit 1eb2984

Browse files
authored
Merge pull request #1 from jurismarches/sirene_v3
Sirene v3
2 parents a5faa02 + 9e3fe22 commit 1eb2984

30 files changed

+1958
-1092
lines changed

.circleci/config.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
version: 2
22
jobs:
33
build:
4-
docker:
5-
- image: technekes/circleci
4+
machine:
5+
image: ubuntu-1604:201903-01
66

77
working_directory: /tmp/app
88

99
steps:
1010
- checkout
11-
- setup_remote_docker
1211

1312
- run:
1413
name: Build the image(s)
1514
command: |
16-
docker build -t sirene:latest .
15+
cp .env.sample .env
16+
docker-compose build
1717
1818
- run:
1919
name: Run quality
2020
command: |
21-
docker run sirene make quality
21+
docker-compose run --rm sirene make quality
2222
2323
- run:
2424
name: Run test and coverage
2525
command: |
26-
docker run sirene /bin/bash -c "make coverage; codecov --token=03f9df38-f1e3-4f0d-bfa1-0e8626319b14"
26+
docker-compose run --rm sirene /bin/bash -c "make coverage; codecov --token=03f9df38-f1e3-4f0d-bfa1-0e8626319b14"

.env.sample

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# database
2+
POSTGRES_NAME=postgres
3+
POSTGRES_USER=postgres
4+
POSTGRES_PASSWORD=postgres

Dockerfile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM python:3
22

33
ENV PYTHONBUFFERED 1
4-
ENV APPLICATION_ROOT /app/
4+
ARG APPLICATION_ROOT=/app/
55

66
RUN mkdir -p $APPLICATION_ROOT
77

@@ -13,14 +13,25 @@ RUN set -x && apt-get update && apt-get -y install \
1313
lib32z1-dev \
1414
# psycopg2
1515
libpq-dev \
16-
postgresql-client
16+
postgresql-client\
17+
# wait for it
18+
wait-for-it
1719

1820
ADD requirements_dev.txt requirements_dev.txt
1921

2022
ADD . $APPLICATION_ROOT
2123

24+
RUN useradd ubuntu --create-home
25+
2226
WORKDIR $APPLICATION_ROOT
2327

2428
RUN pip3 install pip -U && \
2529
pip3 install -r requirements_dev.txt
2630

31+
RUN chown -R ubuntu $APPLICATION_ROOT
32+
RUN chown -R ubuntu /home/ubuntu
33+
34+
USER ubuntu
35+
36+
# compile python files
37+
RUN python -m compileall .

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ These are settings you will want to redefine::
2424
| Setting | Default | Details |
2525
| ---------------------------------- | ------- | ------------------------------------------------------- |
2626
| `DJANGO_SIRENE_LOCAL_PATH` | `/tmp` | define where files will be downloaded |
27-
| `DJANGO_SIRENE_DAYS_TO_KEEP_FILES` | `30` | define how many days you want to keep downloaded files |
2827

2928
Make the migration
3029
```
@@ -38,34 +37,34 @@ manage.py populate_sirene_database
3837
```
3938
It will import the last 'stock' file then all next 'daily' files published.
4039

41-
You can populate database at a past date with `at` parameter.
40+
You can see further option in the command help.
4241
```
43-
manage.py populate_sirene_database --at '2017-11-30'
42+
manage.py populate_sirene_database --help'
4443
```
4544

4645
## Contributing
4746

48-
### Build, start and attach to docker container
47+
### Build, start docker container
4948

5049
```
51-
docker-compose up -d
52-
docker exec -ti CONTAINER_ID bash
50+
cp .env.sample .env
51+
docker-compose build
5352
```
5453

5554
### Test django admin
5655

5756
Create superuser
5857
```
59-
example/manage.py createsuperuser
58+
docker-compose exec sirene example/manage.py createsuperuser
6059
```
6160

6261
Run django server
6362
```
64-
example/manage.py runserver 0:8000
63+
docker-compose exec sirene example/manage.py runserver 0:8000
6564
```
6665

6766
### Run tests
6867

6968
```
70-
make tests
69+
docker-compose run --rm sirene make tests
7170
```

django_sirene/admin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
class InstitutionAdmin(admin.ModelAdmin):
66
search_fields = (
77
'siret',
8+
"name",
9+
"commercial_name"
810
)
911
list_select_related = (
1012
'legal_status',
@@ -22,7 +24,6 @@ class InstitutionAdmin(admin.ModelAdmin):
2224
'is_expired',
2325
'updated',
2426
'created',
25-
'updated_from_filename',
2627
)
2728

2829

django_sirene/base_documents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class InstitutionDocumentMixin:
2323
)
2424

2525
legal_status = fields.ObjectField(properties=_properties_code_name)
26-
activity = fields.ObjectField(properties=_properties_code_name)
26+
municipality = fields.ObjectField(properties=_properties_code_name)
2727
activity = fields.ObjectField(properties=_properties_code_name)
2828

2929
class Meta:

django_sirene/db_utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django.db import connection
2+
3+
4+
def toggle_postgres_vacuum(autovacuum_enabled):
5+
with connection.cursor() as cursor:
6+
cursor.execute(
7+
f"ALTER TABLE django_sirene_institution SET (autovacuum_enabled={autovacuum_enabled})"
8+
)

0 commit comments

Comments
 (0)