Skip to content

Commit

Permalink
fix call to cor_nom_liste
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoLechemia committed Nov 10, 2023
1 parent 7788af3 commit b3f7856
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions apptax/admin/admin_view.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import csv
import logging

from flask import request, json, url_for, redirect, flash, g, current_app
from flask_admin.model.template import macro
Expand Down Expand Up @@ -34,6 +35,8 @@
BibAttributs,
CorTaxonAttribut,
TMedias,
BibListes,
cor_nom_liste,
)
from apptax.admin.utils import taxref_media_file_name, get_user_permission
from pypnusershub.utils import get_current_app_id
Expand All @@ -48,6 +51,8 @@
FilterAttributes,
)

log = logging.getLogger(__name__)


class FlaskAdminProtectedMixin:
# Define permission level for extra actions
Expand Down Expand Up @@ -159,7 +164,6 @@ def can_edit(self):
def can_delete(self):
return self._can_action(6)

extra_actions_perm = {".import_cd_nom_view": 6}
list_template = "admin/list_biblist.html"
extra_actions_perm = {".import_cd_nom_view": 6, "custom_row_actions.truncate_bib_liste": 6}

Expand Down Expand Up @@ -199,7 +203,11 @@ def delete_model(self, model):
"""
Delete model test if cd_nom in list
"""
nb_noms = CorNomListe.query.filter(CorNomListe.id_liste == model.id_liste).count()
nb_noms = (
db.session.query(cor_nom_liste)
.filter(cor_nom_liste.c.id_liste == model.id_liste)
.count()
)
if nb_noms > 0:
flash(
f"Impossible de supprimer la liste {model.nom_liste} car il y a des noms associés",
Expand All @@ -224,6 +232,7 @@ def truncate_bib_liste(self):
flash("Liste purgée de ses noms")
return redirect(self.get_url(".index_view"))
except Exception as ex:
log.error(str(ex))
flash("Erreur, liste non purgée", "error")
return redirect(self.get_url(".index_view"))

Expand Down

0 comments on commit b3f7856

Please sign in to comment.