implemented search-person
This commit is contained in:
parent
a9f1ac6a66
commit
4449493bbd
|
@ -7,8 +7,6 @@ import pgdb
|
||||||
from fileformat import read_actionlist, write_actionlist
|
from fileformat import read_actionlist, write_actionlist
|
||||||
from util import *
|
from util import *
|
||||||
|
|
||||||
file_encoding = 'utf8'
|
|
||||||
|
|
||||||
# connection = pgdb.connect(database='oysteini_pbb2',
|
# connection = pgdb.connect(database='oysteini_pbb2',
|
||||||
# user='oysteini_pbb',
|
# user='oysteini_pbb',
|
||||||
# password='lio5Aide',
|
# password='lio5Aide',
|
||||||
|
@ -215,7 +213,7 @@ def show(connection, ids, commit_format=False, tmp_file=False):
|
||||||
else:
|
else:
|
||||||
output = '\n'.join(objects)
|
output = '\n'.join(objects)
|
||||||
if tmp_file:
|
if tmp_file:
|
||||||
filename = write_tmpfile('.'.join(ids), output, file_encoding)
|
filename = write_tmpfile('.'.join(ids), output)
|
||||||
print filename
|
print filename
|
||||||
return filename
|
return filename
|
||||||
else:
|
else:
|
||||||
|
@ -277,7 +275,15 @@ def search_book(connection, search_strings, search_description=False):
|
||||||
|
|
||||||
|
|
||||||
def search_person(connection, search_strings):
|
def search_person(connection, search_strings):
|
||||||
pass
|
c = connection.cursor()
|
||||||
|
result_strings = []
|
||||||
|
for s in search_strings:
|
||||||
|
for i in range(3):
|
||||||
|
result_strings.append(s)
|
||||||
|
c.execute('SELECT * FROM person LEFT JOIN bookperson ON person.id=bookperson.person WHERE person.lastname ILIKE %s or person.firstname ILIKE %s OR person.id ILIKE %s', result_strings)
|
||||||
|
for i in xrange(c.rowcount):
|
||||||
|
person = fetchone_dict(c)
|
||||||
|
print person['lastname'], ', ', person['firstname'], '\t', person['book']
|
||||||
|
|
||||||
def do_action(connection, action):
|
def do_action(connection, action):
|
||||||
print 'ACTION %s ' % action
|
print 'ACTION %s ' % action
|
||||||
|
@ -289,7 +295,7 @@ def do_action(connection, action):
|
||||||
'new-category': q_new_category,
|
'new-category': q_new_category,
|
||||||
'edit-category': q_edit_category}
|
'edit-category': q_edit_category}
|
||||||
action_type = action['action']
|
action_type = action['action']
|
||||||
execute_query(c, queries[action_type], action)
|
c.execute(queries[action_type], action)
|
||||||
if action_type in ['new-book', 'edit-book']:
|
if action_type in ['new-book', 'edit-book']:
|
||||||
print 'FIXING PERSONS: REMOVING'
|
print 'FIXING PERSONS: REMOVING'
|
||||||
c.execute(q_remove_bookpersons, {'isbn': action['isbn']})
|
c.execute(q_remove_bookpersons, {'isbn': action['isbn']})
|
||||||
|
@ -329,10 +335,7 @@ def commit(connection, filename=None):
|
||||||
commit_actions(connection, actions)
|
commit_actions(connection, actions)
|
||||||
|
|
||||||
def edit(connection, ids):
|
def edit(connection, ids):
|
||||||
filename = show(connection, ids, commit_format=True, tmp_file=True)
|
pass
|
||||||
print filename
|
|
||||||
run_editor(filename)
|
|
||||||
commit(connection, filename)
|
|
||||||
|
|
||||||
def map_cmd(connection, shelfname=None, category=None):
|
def map_cmd(connection, shelfname=None, category=None):
|
||||||
pass
|
pass
|
||||||
|
|
Reference in New Issue