Commit 02b4b7dc authored by Lucas Détré's avatar Lucas Détré

Merge branch 'master' of ssh://git.beta.pole-emploi.fr:23/open-source/trefle into new-simulator

parents cb48562f 531eb5da
Pipeline #2876 passed with stage
in 1 minute and 28 seconds
__pycache__/
.mypy_cache/
.pytest_cache/
**/*/docs/
tmp/
*.egg-info
build/
......
......@@ -77,7 +77,6 @@ deploy Backoffice to staging:
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- ssh gitlab@${STAGING_SERVEUR_IP} "cd /home/docker && BACK_VERSION=${CI_COMMIT_TAG} docker-compose up -d --no-deps web && echo \"BACK_VERSION=${CI_COMMIT_TAG}\" | tee -a .env >> update.log"
only:
......
......@@ -9,7 +9,7 @@ server {
set $upstream_endpoint trefle;
location @gunicorn-master {
proxy_pass http://$upstream_endpoint:8000;
proxy_pass http://trefle:8000;
proxy_redirect off;
proxy_set_header Host $host;
}
......@@ -78,18 +78,4 @@ server {
location /legacy {
root /srv/trefle/legacy-backoffice;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location /legacy/explorer {
alias /srv/trefle/legacy-backoffice/;
index index.html;
}
rewrite /legacy/(.*) /$1 break;
try_files $uri @gunicorn-master;
}
}
FROM ubuntu:xenial
LABEL maintainer="labonneformation@pole-emploi.fr"
ENV LANG C.UTF-8
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get -y install \
apt-utils\
software-properties-common\
unzip \
nginx \
vim \
bzip2 \
cron \
logrotate \
iptables \
git \
dnsutils
ARG TREFLE_GIT
ARG TREFLE_BACK_VERSION
RUN git clone -b ${TREFLE_BACK_VERSION} ${TREFLE_GIT} /srv/trefle && \
chown -R www-data: /srv/trefle && \
chmod -R u+rwx /srv/trefle
ARG TREFLE_GIT
ARG TREFLE_OLD_VERSION
RUN git clone -b ${TREFLE_OLD_VERSION} ${TREFLE_GIT} /srv/trefle-old && \
chown -R www-data: /srv/trefle-old && \
chmod -R u+rwx /srv/trefle-old
CMD service nginx start; \
cron -f
......@@ -32,6 +32,24 @@ async def simulate(data, financements):
del data[key]
async def simulate_remuneration(data, remunerations):
# Prepare context
flatten(data)
context = Context(data.copy())
routine.extrapolate_context(context)
routine.preprocess(context)
for remuneration in remunerations:
copy = context.copy()
routine.check_remuneration(context, remuneration)
data.update(copy.cleaned_data)
# FIXME (limits of the single-store-all context object)
# Clean keys not meant to be exposed
for key in list(data.keys()):
if key.startswith("remuneration"):
del data[key]
def get_financements(tags=None):
financements = [config.Financement(f) for f in config.FINANCEMENTS]
for tag in tags or []:
......
......@@ -10,7 +10,13 @@ from roll.extensions import cors
import ujson as json
from . import VERSION, get_financements, get_remunerations, simulate
from . import (
VERSION,
get_financements,
get_remunerations,
simulate,
simulate_remuneration,
)
from . import routine
from .config import AUTHORIZED, FINANCEMENTS, COMMIT_AUTHORIZED, GLOSSARY, IDCC, NAF, CERTIFINFO, RAW_RULES, SCHEMA, GITLAB_TOKEN
from .context import Context
......@@ -81,8 +87,8 @@ async def simulate_(request, response):
body = {"financements": financements}
if request.query.bool("context", False):
body["context"] = {
k: v for k, v in context.items()
if k in SCHEMA and "label" in SCHEMA[k]}
k: v for k, v in context.items() if k in SCHEMA and "label" in SCHEMA[k]
}
if request.query.bool("scenario", False):
body["scenario"] = make_scenario(context, financements)
response.json = body
......@@ -93,24 +99,10 @@ async def simulate_(request, response):
# TODO : add pointer error for bad region number + test
@app.route("/remuneration", methods=["POST"])
async def remuneration_(request, response):
data = request.json
context = request.json
remunerations = get_remunerations(tags=request.query.list("tags", []))
try: