Skip to content

Commit

Permalink
ref #49
Browse files Browse the repository at this point in the history
  • Loading branch information
joelclems committed Oct 1, 2021
1 parent b0500c9 commit a6c7ab4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
21 changes: 16 additions & 5 deletions app/modules/oeasc/chasse/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -205,7 +205,6 @@ class TAttributions(DB.Model):
type_bracelet = DB.relationship(TTypeBracelets)



@serializable
class TRealisationsChasse(DB.Model):
'''
Expand Down Expand Up @@ -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):
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/modules/chasse/config/store-realisation.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default {
}
]
}

]
},
{
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit a6c7ab4

Please sign in to comment.