From 9abaa2c3e8fc0f93eda041409a65e2274bc94563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 8 Jun 2021 08:33:50 +0200 Subject: [PATCH] allow filtering out some document types --- pfwb_archives_proxy/settings.py | 1 + pfwb_archives_proxy/views.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/pfwb_archives_proxy/settings.py b/pfwb_archives_proxy/settings.py index 811b614..8f61389 100644 --- a/pfwb_archives_proxy/settings.py +++ b/pfwb_archives_proxy/settings.py @@ -196,6 +196,7 @@ TABELLIO_DOCUMENT_TYPES = { 'texte-adopte-en-commission': 'TEXTCOM', } +TABELLIO_FILTERED_TYPES = ['BTR'] local_settings_file = os.environ.get( 'PFWB_ARCHIVES_PROXY_SETTINGS_FILE', os.path.join(os.path.dirname(__file__), 'local_settings.py') diff --git a/pfwb_archives_proxy/views.py b/pfwb_archives_proxy/views.py index 3f4a4ec..3a6525c 100644 --- a/pfwb_archives_proxy/views.py +++ b/pfwb_archives_proxy/views.py @@ -31,6 +31,9 @@ def redirect(request, sess, no=None, nodoc=None, anx=None, doctype=None, date=No if date: query += ' AND date = %(date)s' + if settings.TABELLIO_FILTERED_TYPES: + query += ' AND type NOT IN %(filtered_types)s' + cur.execute( query, { @@ -40,6 +43,7 @@ def redirect(request, sess, no=None, nodoc=None, anx=None, doctype=None, date=No 'anx': anx, 'doctype': doctype, 'date': date, + 'filtered_types': tuple(settings.TABELLIO_FILTERED_TYPES or []), }, ) rows = cur.fetchall()