Skip to content

Commit

Permalink
Merge pull request #364 from PnX-SI/develop
Browse files Browse the repository at this point in the history
Develop > Master / Prepa 1.5.0
  • Loading branch information
camillemonchicourt authored Dec 2, 2021
2 parents 6fe9aba + 09805a5 commit 4e5aebc
Show file tree
Hide file tree
Showing 478 changed files with 13,446 additions and 72,333 deletions.
55 changes: 34 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
*.pyc
tests/*
config/settings.ini
config/config.py
.htpasswd
log/*
static/conf/custom.js
atlas/static/conf/custom.js
atlas/debug.py
data/ref/emprise_territoire.*
static/territoire.json
static/images/ancien
atlas/configuration/config.py
atlas/configuration/settings.ini
robots.txt
.htaccess
venv/*
venv3/*

data/ref/communes.shp
data/ref/communes.shx
data/ref/communes.dbf
data/ref/communes.prj
atlas/configuration/config.py
atlas/configuration/settings.ini

atlas/static/conf/custom.js
atlas/static/territoire.json
atlas/static/images/ancien
atlas/static/node_modules
atlas/static/territoire.json
atlas/static/images/ancie
n
atlas/static/custom/territoire.json
atlas/static/custom/glossaire.json
atlas/static/custom/custom.css
atlas/static/custom/maps-custom.js

static/custom/territoire.json
static/custom/glossaire.json
static/custom/custom.css
static/custom/maps-custom.js
static/custom/images/logo-structure.png
static/custom/images/accueil-intro.jpg
atlas/static/custom/images/logo-structure.png
atlas/static/custom/images/accueil-intro.jpg
static/custom/images/favicon.ico
static/custom/images/logo_patrimonial.png
atlas/static/custom/images/logo_patrimonial.png

static/custom/templates/presentation.html
static/custom/templates/footer.html
static/custom/templates/introduction.html
static/custom/templates/credits.html
static/custom/templates/mentions-legales.html
atlas/static/custom/templates/bandeaulogoshome.html
atlas/static/custom/templates/presentation.html
atlas/static/custom/templates/footer.html
atlas/static/custom/templates/introduction.html
atlas/static/custom/templates/credits.html
atlas/static/custom/templates/mentions-legales.html

data/ref/emprise_territoire.*
data/ref/communes.dbf
data/ref/communes.prj
data/ref/communes.shp
Expand All @@ -45,7 +50,15 @@ data/ref/territoire.prj
data/ref/territoire.shp
data/ref/territoire.shx

data/ref/L93*
data/ref/mailles*

# Pycharm
.idea/

.vscode

.coverage
.tox
*.swp
*.swo
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include VERSION
include README.txt
include LICENCE.txt
include requirements.in
include tox.ini
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Atlas en ligne utilisant GeoNature-atlas :
- `Société Herpétologique de France <https://atlas.lashf.org>`_
- `Picardie Nature <https://clicnat.fr>`_
- `Métropole clermontoise <https://atlas.cbiodiv.org>`_
- `PNR Forêt d'Orient <https://biodiversite.pnr-foret-orient.fr/>`_
- `Archipel des Mascareignes <https://obs.maeoproject.org/>`_

Archipel des Mascareignes

Technologies
------------
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.2
1.5.0
6 changes: 0 additions & 6 deletions atlas-service.conf

This file was deleted.

52 changes: 26 additions & 26 deletions initAtlas.py → atlas/app.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import os
import sys
from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy

from werkzeug.serving import run_simple

from atlas.configuration import config
from atlas.utils import format_number
from sqlalchemy import create_engine, MetaData, Table
from flask import Flask, request, session, redirect, url_for, g
from flask_compress import Compress
from flask_sqlalchemy import SQLAlchemy
from flask_babel import Babel, format_date, gettext, ngettext, get_locale

from atlas.configuration.config_parser import read_and_validate_conf
from atlas.configuration.config_schema import AtlasConfig, SecretSchemaConf
from atlas.configuration import config
from atlas.env import config, secret_conf
from atlas.utils import format_number

db = SQLAlchemy()
compress = Compress()
Expand Down Expand Up @@ -45,21 +39,27 @@ def __call__(self, environ, start_response):

def create_app():
"""
renvoie une instance de l'app Flask
renvoie une instance de l'app Flask
"""

# validation de la configuration
# configuration publique
valid_config = read_and_validate_conf(config, AtlasConfig)

app = Flask(__name__, template_folder=APP_DIR)
# push the config in app config at 'PUBLIC' key
app.config.update(valid_config)

app.debug = valid_config["modeDebug"]
app.config.update(config)
babel = Babel(app)

@babel.localeselector
def get_locale():
# if MULTILINGUAL, valid language is in g via before_request_hook
if config["MULTILINGUAL"]:
return g.lang_code
return config["DEFAULT_LANGUAGE"]

app.debug = secret_conf["modeDebug"]
app.config["SECRET_KEY"] = secret_conf["SECRET_KEY"]
with app.app_context() as context:
from atlas.atlasRoutes import main as main_blueprint

if config["MULTILINGUAL"]:
app.register_blueprint(main_blueprint, url_prefix="/<lang_code>")
app.register_blueprint(main_blueprint)

from atlas.atlasAPI import api
Expand All @@ -68,12 +68,12 @@ def create_app():
compress.init_app(app)

app.wsgi_app = ReverseProxied(
app.wsgi_app, script_name=valid_config["URL_APPLICATION"]
app.wsgi_app, script_name=config["URL_APPLICATION"]
)

@app.context_processor
def inject_config():
return dict(configuration=valid_config)
return dict(configuration=config)

@app.template_filter("pretty")
def pretty(val):
Expand All @@ -82,11 +82,11 @@ def pretty(val):
return app


app = create_app()
if __name__ == "__main__":
# validation de la configuration secrète
secret_conf = read_and_validate_conf(config, SecretSchemaConf)
app = create_app()
app.run(
host="0.0.0.0", port=secret_conf["GUNICORN_PORT"], debug=app.config["modeDebug"]
host="0.0.0.0",
port=secret_conf["GUNICORN_PORT"],
debug=secret_conf["modeDebug"],
)

35 changes: 30 additions & 5 deletions atlas/atlasAPI.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# -*- coding:utf-8 -*-

from flask import jsonify, Blueprint, request, current_app
from werkzeug.wrappers import Response
from . import utils
from .modeles.repositories import (

from atlas import utils
from atlas.modeles.repositories import (
vmSearchTaxonRepository,
vmObservationsRepository,
vmObservationsMaillesRepository,
vmMedias,
vmCommunesRepository,
)
from .configuration import config

api = Blueprint("api", __name__)

Expand All @@ -31,6 +30,7 @@ def searchCommuneAPI():
search = request.args.get("search", "")
limit = request.args.get("limit", 50)
results = vmCommunesRepository.getCommunesSearch(session, search, limit)
session.close()
return jsonify(results)

if not current_app.config['AFFICHAGE_MAILLE']:
Expand Down Expand Up @@ -70,6 +70,8 @@ def getObservationsMailleAPI(cd_ref, year_min=None, year_max=None):
return jsonify(observations)




if not current_app.config['AFFICHAGE_MAILLE']:
@api.route("/observationsPoint/<int:cd_ref>", methods=["GET"])
def getObservationsPointAPI(cd_ref):
Expand All @@ -78,6 +80,29 @@ def getObservationsPointAPI(cd_ref):
session.close()
return jsonify(observations)



@api.route("/observations/<int:cd_ref>", methods=["GET"])
def getObservationsGenericApi(cd_ref: int):
"""[summary]
Args:
cd_ref (int): [description]
Returns:
[type]: [description]
"""
session = utils.loadSession()
observations = vmObservationsMaillesRepository.getObservationsMaillesChilds(
session,
cd_ref,
year_min=request.args.get("year_min"),
year_max=request.args.get("year_max"),
) if current_app.config['AFFICHAGE_MAILLE'] else vmObservationsRepository.searchObservationsChilds(session, cd_ref)
session.close()
return jsonify(observations)


if not current_app.config['AFFICHAGE_MAILLE']:
@api.route("/observations/<insee>/<int:cd_ref>", methods=["GET"])
def getObservationsCommuneTaxonAPI(insee, cd_ref):
Expand Down Expand Up @@ -133,4 +158,4 @@ def test():
current_app.config["ATTR_OTHER_PHOTO"],
)
connection.close()
return jsonify(photos)
return jsonify(photos)
Loading

0 comments on commit 4e5aebc

Please sign in to comment.