Skip to content

Commit

Permalink
Use get_current_app_id
Browse files Browse the repository at this point in the history
  • Loading branch information
amandine-sahl committed Aug 8, 2024
1 parent fc80f95 commit 8428c8c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 8 additions & 4 deletions apptax/admin/admin_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,14 @@ def _get_attributes_value(self, taxon_name, theme_attributs_def):
]

if taxon_att:
attributes_val[a.id_attribut]["taxon_attr_value"] = eval(
taxon_att[0].valeur_attribut
)
try:
attributes_val[a.id_attribut]["taxon_attr_value"] = eval(
taxon_att[0].valeur_attribut
)
except NameError:
attributes_val[a.id_attribut]["taxon_attr_value"] = taxon_att[
0
].valeur_attribut
return attributes_val

def render(self, template, **kwargs):
Expand Down Expand Up @@ -449,7 +454,6 @@ def edit_view(self):
if taxon_name.cd_nom == taxon_name.cd_ref:
theme_attributs_def = self._get_theme_attributes(taxon_name)
attributes_val = self._get_attributes_value(taxon_name, theme_attributs_def)
print(attributes_val)
self._template_args["theme_attributs_def"] = theme_attributs_def
self._template_args["attributes_val"] = attributes_val
if request.method == "POST":
Expand Down
16 changes: 6 additions & 10 deletions apptax/admin/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import csv
from werkzeug.utils import secure_filename
from sqlalchemy import select

from pypnusershub.db.models import AppUser, Application
from pypnusershub.utils import get_current_app_id
Expand All @@ -16,18 +17,13 @@ def taxref_media_file_name(obj, file_data):


def get_user_permission(id_role):
id_app = (
Application.query.filter_by(
code_application="TH",
)
.one()
.id_application
)
id_app = get_current_app_id()

query = AppUser.query.filter(AppUser.id_application == id_app).filter(
AppUser.id_role == id_role
query = (
select(AppUser).where(AppUser.id_application == id_app).where(AppUser.id_role == id_role)
)
return query.scalar()

return db.session.scalar(query)


class PopulateBibListeException(Exception):
Expand Down

0 comments on commit 8428c8c

Please sign in to comment.