Skip to content

Commit

Permalink
add in type site in bib_type_site on install
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoLechemia committed Aug 1, 2024
1 parent bad8ee4 commit c94136c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion backend/gn_module_monitoring/command/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
cor_object_module,
)
from geonature.core.gn_commons.models import TModules

from geonature.core.gn_monitoring.models import BibTypeSite
from pypnnomenclature.models import TNomenclatures, BibNomenclaturesTypes

from gn_module_monitoring.config.utils import (
Expand Down Expand Up @@ -342,6 +342,13 @@ def insert_update_nomenclature(data):

DB.session.add(nomenclature)
DB.session.commit()
if data["type"] == "TYPE_SITE":
existing_bib_type_site = DB.session.get(BibTypeSite, nomenclature.id_nomenclature)
if not existing_bib_type_site:
bib_type_site = BibTypeSite(id_nomenclature_type_site=nomenclature.id_nomenclature)
DB.session.add(bib_type_site)
DB.session.commit()

print(
"nomenclature {} - {} - {}".format(
nomenclature.cd_nomenclature, nomenclature.label_default, action
Expand Down

0 comments on commit c94136c

Please sign in to comment.