Skip to content

Commit

Permalink
Merge pull request #425 from PnX-SI/develop
Browse files Browse the repository at this point in the history
Develop >> Master
  • Loading branch information
camillemonchicourt committed Sep 20, 2018
2 parents b508c80 + 0b320ea commit c6af666
Show file tree
Hide file tree
Showing 46 changed files with 736 additions and 608 deletions.
7 changes: 3 additions & 4 deletions backend/geonature/core/auth/routes.py
Expand Up @@ -59,7 +59,7 @@ def loginCas():
log.error("Error with the inpn authentification service")
raise CasAuthentificationError(
'Error with the inpn authentification service',
status_code=500
status_code=500
)

info_user = response.json()
Expand All @@ -80,7 +80,7 @@ def loginCas():
)
raise CasAuthentificationError(
'CAS ERROR: no ID or LOGIN provided',
status_code=500
status_code=500
)
# Reconciliation avec base GeoNature
if organism_id:
Expand Down Expand Up @@ -153,8 +153,7 @@ def loginCas():
)
return render_template(
'cas_login_error.html',
cas_logout=current_app.config['CAS']['CAS_URL_LOGOUT'],
cas_logout=current_app.config['CAS_PUBLIC']['CAS_URL_LOGOUT'],
url_geonature=current_app.config['URL_APPLICATION']
)
return jsonify({'message': 'Authentification error'}, 500)

2 changes: 1 addition & 1 deletion backend/geonature/core/gn_meta/routes.py
Expand Up @@ -55,7 +55,7 @@ def get_datasets(info_role):
"""
with_mtd_error = False
if current_app.config['CAS']['CAS_AUTHENTIFICATION']:
if current_app.config['CAS_PUBLIC']['CAS_AUTHENTIFICATION']:
# synchronise the CA and JDD from the MTD WS
try:
mtd_utils.post_jdd_from_user(
Expand Down
4 changes: 0 additions & 4 deletions backend/geonature/core/gn_synthese/models.py
Expand Up @@ -109,10 +109,6 @@ class TSources(DB.Model):
desc_source = DB.Column(DB.Unicode)
entity_source_pk_field = DB.Column(DB.Unicode)
url_source = DB.Column(DB.Unicode)
target = DB.Column(DB.Unicode)
picto_source = DB.Column(DB.Unicode)
groupe_source = DB.Column(DB.Unicode)
active = DB.Column(DB.Boolean)
meta_create_date = DB.Column(DB.DateTime)
meta_update_date = DB.Column(DB.DateTime)

Expand Down
15 changes: 9 additions & 6 deletions backend/geonature/core/gn_synthese/utils/query.py
@@ -1,4 +1,4 @@
from flask import current_app
from flask import current_app, request
from shapely.wkt import loads
from geoalchemy2.shape import from_shape
from sqlalchemy import func, or_, and_
Expand Down Expand Up @@ -50,7 +50,6 @@ def filter_taxonomy(model, q, filters):
-Tuple: the SQLAlchemy query and the filter dictionnary
"""
if 'cd_ref' in filters:
from flask import request
# find all cd_nom where cd_ref = filter['cd_ref']
sub_query_synonym = DB.session.query(
Taxref.cd_nom
Expand All @@ -74,15 +73,19 @@ def filter_taxonomy(model, q, filters):
q = q.filter(model.cd_nom.in_(sub_query_lr))

aliased_cor_taxon_attr = {}
join_on_taxref = False
for colname, value in filters.items():
if colname.startswith('taxhub_attribut'):
if not join_on_taxref:
q = q.join(Taxref, Taxref.cd_nom == model.cd_nom)
join_on_taxref = True
taxhub_id_attr = colname[16:]
aliased_cor_taxon_attr[taxhub_id_attr] = aliased(CorTaxonAttribut)
q = q.join(
aliased_cor_taxon_attr[taxhub_id_attr],
and_(
aliased_cor_taxon_attr[taxhub_id_attr].id_attribut == taxhub_id_attr,
aliased_cor_taxon_attr[taxhub_id_attr].cd_ref == Taxref.cd_ref
aliased_cor_taxon_attr[taxhub_id_attr].cd_ref == func.taxonomie.find_cdref(model.cd_nom)
)
).filter(
aliased_cor_taxon_attr[taxhub_id_attr].valeur_attribut.in_(value)
Expand Down Expand Up @@ -144,7 +147,7 @@ def filter_query_all_filters(model, q, filters, user, allowed_datasets):

if 'geoIntersection' in filters:
# Insersect with the geom send from the map
geom_wkt = loads(filters['geoIntersection'][0])
geom_wkt = loads(request.args['geoIntersection'])
# if the geom is a circle
if 'radius' in filters:
radius = filters.pop('radius')[0]
Expand All @@ -154,8 +157,8 @@ def filter_query_all_filters(model, q, filters, user, allowed_datasets):
filters.pop('geoIntersection')

if 'period_start' in filters and 'period_end' in filters:
period_start = filters.pop('period_min')[0]
period_end = filters.pop('period_max')[0]
period_start = filters.pop('period_start')[0]
period_end = filters.pop('period_end')[0]
q = q.filter(or_(
func.gn_commons.is_in_period(
func.date(model.date_min),
Expand Down
31 changes: 19 additions & 12 deletions backend/geonature/utils/config_schema.py
Expand Up @@ -25,14 +25,17 @@ class CasUserSchemaConf(Schema):
)


class CasSchemaConf(Schema):
class CasFrontend(Schema):
CAS_AUTHENTIFICATION = fields.Boolean(missing='false')
CAS_URL_LOGIN = fields.Url(
missing='https://preprod-inpn.mnhn.fr/auth/login'
)
CAS_URL_LOGOUT = fields.Url(
missing='https://preprod-inpn.mnhn.fr/auth/logout'
)


class CasSchemaConf(Schema):
CAS_URL_VALIDATION = fields.String(
missing='https://preprod-inpn.mnhn.fr/auth/serviceValidate'
)
Expand All @@ -51,6 +54,17 @@ class RightsSchemaConf(Schema):
ALL_DATA = fields.Integer(missing=3)


class MailErrorConf(Schema):
MAIL_ON_ERROR = fields.Boolean(missing=False)
MAIL_HOST = fields.String(missing="")
HOST_PORT = fields.Integer(missing=465)
MAIL_FROM = fields.String(missing="")
MAIL_USERNAME = fields.String(missing="")
MAIL_PASS = fields.String(missing="")
MAIL_TO = fields.List(fields.String(), missing=list())


# class a utiliser pour les paramètres que l'on ne veut pas passer au frontend
class GnPySchemaConf(Schema):
SQLALCHEMY_DATABASE_URI = fields.String(
required=True,
Expand All @@ -73,6 +87,8 @@ class GnPySchemaConf(Schema):
BASE_DIR = fields.String(
missing=os.path.dirname(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
)
MAILERROR = fields.Nested(MailErrorConf, missing=dict())
CAS = fields.Nested(CasSchemaConf, missing=dict())


class GnFrontEndConf(Schema):
Expand Down Expand Up @@ -113,15 +129,7 @@ class Synthese(Schema):
# Nombre des "dernières observations" affiché à l'arrive sur la synthese
NB_LAST_OBS = fields.Integer(missing=100)


class MailErrorConf(Schema):
MAIL_ON_ERROR = fields.Boolean(missing=False)
MAIL_HOST = fields.String(missing="")
HOST_PORT = fields.Integer(missing=465)
MAIL_FROM = fields.String(missing="")
MAIL_USERNAME = fields.String(missing="")
MAIL_PASS = fields.String(missing="")
MAIL_TO = fields.List(fields.String(), missing=list())
# class a utiliser pour les paramètres que l'on veut passer au frontend


class GnGeneralSchemaConf(Schema):
Expand All @@ -139,10 +147,9 @@ class GnGeneralSchemaConf(Schema):
ID_APPLICATION_GEONATURE = fields.Integer(missing=3)
XML_NAMESPACE = fields.String(missing="{http://inpn.mnhn.fr/mtd}")
MTD_API_ENDPOINT = fields.Url(missing="https://preprod-inpn.mnhn.fr/mtd")
CAS = fields.Nested(CasSchemaConf, missing=dict())
CAS_PUBLIC = fields.Nested(CasFrontend, missing=dict())
RIGHTS = fields.Nested(RightsSchemaConf, missing=dict())
FRONTEND = fields.Nested(GnFrontEndConf, missing=dict())
MAILERROR = fields.Nested(MailErrorConf, missing=dict())
SYNTHESE = fields.Nested(Synthese, missing=dict())
# Ajoute la surchouche 'taxonomique' sur l'API nomenclature
ENABLE_NOMENCLATURE_TAXONOMIC_FILTERS = fields.Boolean(missing=True)
Expand Down
4 changes: 2 additions & 2 deletions backend/requirements-travis.txt
Expand Up @@ -10,8 +10,8 @@
# `Pipfile.lock` and then regenerate `requirements*.txt`.
################################################################################

https://github.com/PnX-SI/UsersHub-authentification-module/archive/1.1.1.zip
https://github.com/PnX-SI/Nomenclature-api-module/archive/develop.zip
https://github.com/PnX-SI/UsersHub-authentification-module/archive/1.2.0.zip
https://github.com/PnX-SI/Nomenclature-api-module/archive/1.2.1.zip
certifi==2017.11.5
chardet==3.0.4
click==6.7
Expand Down
4 changes: 2 additions & 2 deletions backend/requirements.txt
Expand Up @@ -10,8 +10,8 @@
# `Pipfile.lock` and then regenerate `requirements*.txt`.
################################################################################

https://github.com/PnX-SI/UsersHub-authentification-module/archive/develop.zip
https://github.com/PnX-SI/Nomenclature-api-module/archive/develop.zip
https://github.com/PnX-SI/UsersHub-authentification-module/archive/1.2.0.zip
https://github.com/PnX-SI/Nomenclature-api-module/archive/1.2.1.zip
certifi==2017.11.5
chardet==3.0.4
click==6.7
Expand Down
3 changes: 0 additions & 3 deletions backend/tests/sample_data.sql
Expand Up @@ -61,9 +61,6 @@ INSERT INTO gn_meta.cor_dataset_protocol (id_dataset, id_protocol) VALUES
;
SELECT pg_catalog.setval('gn_meta.sinp_datatype_protocols_id_protocol_seq', (SELECT max(id_protocol)+1 FROM gn_meta.cor_dataset_protocol), true);

-- INSERT INTO gn_synthese.t_sources (id_source, name_source, desc_source, entity_source_pk_field, url_source, target, picto_source, groupe_source, active) VALUES
-- (1, 'Contact faune flore', 'Données issues du occtax aléatoire', 'pr_occtax.cor_counting_occtax.id_counting_occtax', '/occtax', NULL, NULL, 'CONTACT', true);


INSERT INTO pr_occtax.t_releves_occtax (id_releve_occtax,id_dataset,id_digitiser,observers_txt,id_nomenclature_obs_technique,id_nomenclature_grp_typ,date_min,date_max,hour_min,hour_max,altitude_min,altitude_max,meta_device_entry,comment,geom_local,geom_4326,precision) VALUES
(1,1,1,'Obervateur test insert',ref_nomenclatures.get_id_nomenclature('TECHNIQUE_OBS', '133'),ref_nomenclatures.get_id_nomenclature('TYP_GRP', 'OBS'),'2017-01-01','2017-01-01','12:05:02','12:05:02',1500,1565,'web','Exemple test','01010000206A0800002E988D737BCC2D41ECFA38A659805841','0101000020E61000000000000000001A40CDCCCCCCCC6C4640',10)
Expand Down
14 changes: 8 additions & 6 deletions config/default_config.toml.example
Expand Up @@ -29,15 +29,17 @@ MTD_API_ENDPOINT = "https://preprod-inpn.mnhn.fr/mtd"
UPLOAD_FOLDER = 'static/medias'

# CAS authentification (Optional, instead of UsersHub local authentification)
[CAS]
[CAS_PUBLIC]
CAS_AUTHENTIFICATION = false
CAS_URL_LOGIN = 'https://preprod-inpn.mnhn.fr/auth/login'
CAS_URL_LOGOUT = 'https://preprod-inpn.mnhn.fr/auth/logout'
CAS_URL_VALIDATION = 'https://preprod-inpn.mnhn.fr/auth/serviceValidate'
[CAS.CAS_USER_WS]
URL = 'https://inpn2.mnhn.fr/authentication/information'
ID = 'mon_id'
PASSWORD = 'mon_pass'

[CAS]
CAS_URL_VALIDATION = 'https://preprod-inpn.mnhn.fr/auth/serviceValidate'
[CAS.CAS_USER_WS]
URL = 'https://inpn2.mnhn.fr/authentication/information'
ID = 'mon_id'
PASSWORD = 'mon_pass'

[RIGHTS]
NOTHING = 0
Expand Down
6 changes: 3 additions & 3 deletions config/settings.ini.sample
Expand Up @@ -57,13 +57,13 @@ add_sample_data=true
# Les trois paramètres ci-dessous visent à indiquer dans quelle version (release, branche ou tag) les scripts doivent être récupés

# Définir dans quelle version de UsersHub (release, branche ou tag) prendre le code SQL permettant la création du schéma utilisateurs de la base de données de GeoNature
usershub_release=1.3.1
usershub_release=1.3.2

# Définir dans quelle version de TaxHub (release, branche ou tag) prendre le code SQL permettant la création du schéma taxonomie de la base de données de GeoNature
taxhub_release=pre-1.3.3
taxhub_release=1.5.0

# Définir dans quelle version du sous-module des nomenclatures (realease, branche ou tag) prendre le code SQL permettant la création du schéma 'ref_nomenvclature' de la base de données GeoNature
nomenclature_release=develop
nomenclature_release=1.2.1


#Configuration python
Expand Down

0 comments on commit c6af666

Please sign in to comment.