Skip to content

Commit

Permalink
Filtrer sur les modules depuis le gestionnaire des groupes de site
Browse files Browse the repository at this point in the history
  • Loading branch information
amandine-sahl committed Jul 26, 2024
1 parent 7e1a7c5 commit 5c39c30
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions backend/gn_module_monitoring/monitoring/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,18 @@ def filter_by_scope(cls, query: Select, scope, user=None):
def filter_by_params(cls, query: Select, params: MultiDict = None, **kwargs):
if "modules" in params:
value = params["modules"]
if not isinstance(value, list):
value = [value]
query = query.filter(cls.modules.any(Models.TMonitoringModules.id_module.in_(value)))

# Cas ou le filtre provient du gestionnaire des groupes de sites.
# La valeur est passée en chaine de caractère
if not value.isdigit():
query = query.filter(
cls.modules.any(Models.TMonitoringModules.module_label.ilike(f"%{value}%"))
)
else:
if not isinstance(value, list):
value = [value]
query = query.filter(
cls.modules.any(Models.TMonitoringModules.id_module.in_(value))
)
query = super().filter_by_params(query, params)

return query
Expand Down

0 comments on commit 5c39c30

Please sign in to comment.