From a6c7ab4a5c26ff5f387b5fd038a3d12a388886a3 Mon Sep 17 00:00:00 2001 From: "joel.clement" Date: Fri, 1 Oct 2021 11:12:25 +0200 Subject: [PATCH] ref #49 --- app/modules/oeasc/chasse/models.py | 21 ++++++++++++++----- .../chasse/config/store-realisation.js | 5 +++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/modules/oeasc/chasse/models.py b/app/modules/oeasc/chasse/models.py index 25b9d8a9..59b1fcfc 100644 --- a/app/modules/oeasc/chasse/models.py +++ b/app/modules/oeasc/chasse/models.py @@ -6,10 +6,10 @@ from utils_flask_sqla.serializers import serializable from geoalchemy2 import Geometry from sqlalchemy.orm import column_property, object_session -from sqlalchemy import select, func, and_, join +from sqlalchemy import select, func, and_, join, exists from sqlalchemy.sql.expression import case -from ..commons.models import TEspeces, TNomenclatures, TSecteurs +from ..commons.models import TEspeces, TNomenclatures, TSecteurs config = current_app.config DB = config['DB'] @@ -140,7 +140,7 @@ class TSaisonDates(DB.Model): date_fin = DB.Column(DB.Date) id_nomenclature_type_chasse = DB.Column(DB.Integer, DB.ForeignKey('ref_nomenclatures.t_nomenclatures.id_nomenclature')) nomenclature_type_chasse = DB.relationship(TNomenclatures, foreign_keys=id_nomenclature_type_chasse) - + @serializable @@ -205,7 +205,6 @@ class TAttributions(DB.Model): type_bracelet = DB.relationship(TTypeBracelets) - @serializable class TRealisationsChasse(DB.Model): ''' @@ -300,6 +299,18 @@ class TRealisationsChasse(DB.Model): # meta_create_date = DB.Column(DB.DateTime) # meta_update_date = DB.Column(DB.DateTime) +''' +relation : TAttributions.realisation + +ou + +column_property : TAttributions.has_realisation +''' + +# TAttributions.realisation = DB.relationship(TRealisationsChasse) +TAttributions.has_realisation = column_property(exists().where(TRealisationsChasse.id_attribution == TAttributions.id_attribution)) + +TAttributions = serializable(TAttributions) @serializable class VChasseBilan(DB.Model): @@ -310,7 +321,7 @@ class VChasseBilan(DB.Model): __tablename__ = 'v_bilan_pretty' __table_args__ = { 'schema': 'oeasc_chasse', - 'extend_existing': True, + 'extend_existing': True, } id_espece = DB.Column(DB.Integer(), primary_key=True) diff --git a/frontend/src/modules/chasse/config/store-realisation.js b/frontend/src/modules/chasse/config/store-realisation.js index 69a09896..3b10a24d 100644 --- a/frontend/src/modules/chasse/config/store-realisation.js +++ b/frontend/src/modules/chasse/config/store-realisation.js @@ -51,7 +51,7 @@ export default { } ] } - + ] }, { @@ -187,7 +187,8 @@ export default { returnObject: true, displayFieldName: "numero_bracelet", params: ({ baseModel }) => ({ - id_saison: baseModel.saison && baseModel.saison.id_saison + id_saison: baseModel.saison && baseModel.saison.id_saison, + has_realisation: false }), disabled: ({ baseModel }) => !(baseModel.saison && baseModel.saison.id_saison),