add prefix requirement for some document types (BQR, CRI)
This commit is contained in:
parent
ed0a09de5c
commit
005e1810b1
|
@ -20,7 +20,17 @@ def redirect(request, sess, no, nodoc=None, anx=None):
|
|||
else:
|
||||
query += ' AND anx IS NULL'
|
||||
|
||||
cur.execute(query, {'sess': sess, 'no': no, 'nodoc': nodoc, 'anx': anx})
|
||||
distinct_types = ('BQR', 'CRI')
|
||||
type_ = None
|
||||
for prefix in distinct_types:
|
||||
if no.startswith(prefix + '-'):
|
||||
type_, no = no.split('-', 1)
|
||||
if type_:
|
||||
query += ' AND type = %(type)s'
|
||||
else:
|
||||
query += ' AND type NOT IN %(distinct_types)s'
|
||||
|
||||
cur.execute(query, {'sess': sess, 'no': no, 'nodoc': nodoc, 'anx': anx, 'type': type_, 'distinct_types': distinct_types})
|
||||
rows = cur.fetchall()
|
||||
if rows:
|
||||
url = 'https://archives.pfwb.be/%s' % rows[0][0]
|
||||
|
|
Loading…
Reference in New Issue