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'
|
||||
q_add_bookreference = \
|
||||
'INSERT INTO bookreference (book, reftype, value) ' \
|
||||
'VALUES (%(isbn)s, %(reftype)s, %(value))'
|
||||
'VALUES (%(isbn)s, %(reftype)s, %(value)s)'
|
||||
|
||||
def connect_to_db():
|
||||
connection = pgdb.connect(database='oysteini_pbb2',
|
||||
|
@ -313,11 +313,11 @@ def do_action(connection, action):
|
|||
'relation': relation})
|
||||
if action['references']:
|
||||
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 ref in reflist:
|
||||
if ref in refs:
|
||||
c.execute(q_add_reference,
|
||||
if reftype in legal_reftypes:
|
||||
c.execute(q_add_bookreference,
|
||||
{'isbn': action['isbn'],
|
||||
'reftype': reftype,
|
||||
'value': ref})
|
||||
|
|
Reference in New Issue