fixed bug in referenceadding to books
This commit is contained in:
parent
e14ab5e580
commit
cc4eadc885
|
@ -85,7 +85,7 @@ q_edit_category = \
|
||||||
'WHERE id=%(id)s'
|
'WHERE id=%(id)s'
|
||||||
q_add_bookreference = \
|
q_add_bookreference = \
|
||||||
'INSERT INTO bookreference (book, reftype, value) ' \
|
'INSERT INTO bookreference (book, reftype, value) ' \
|
||||||
'VALUES (%(isbn)s, %(reftype)s, %(value))'
|
'VALUES (%(isbn)s, %(reftype)s, %(value)s)'
|
||||||
|
|
||||||
def connect_to_db():
|
def connect_to_db():
|
||||||
connection = pgdb.connect(database='oysteini_pbb2',
|
connection = pgdb.connect(database='oysteini_pbb2',
|
||||||
|
@ -313,11 +313,11 @@ def do_action(connection, action):
|
||||||
'relation': relation})
|
'relation': relation})
|
||||||
if action['references']:
|
if action['references']:
|
||||||
c.execute('SELECT referencetype.id FROM referencetype')
|
c.execute('SELECT referencetype.id FROM referencetype')
|
||||||
refs = c.fetchone()
|
legal_reftypes = [a for list in c.fetchall() for a in list]
|
||||||
for (reftype, reflist) in action['references'].items():
|
for (reftype, reflist) in action['references'].items():
|
||||||
for ref in reflist:
|
for ref in reflist:
|
||||||
if ref in refs:
|
if reftype in legal_reftypes:
|
||||||
c.execute(q_add_reference,
|
c.execute(q_add_bookreference,
|
||||||
{'isbn': action['isbn'],
|
{'isbn': action['isbn'],
|
||||||
'reftype': reftype,
|
'reftype': reftype,
|
||||||
'value': ref})
|
'value': ref})
|
||||||
|
|
Reference in New Issue