From 00ba231fbf4151b76738f296ab2a70315345b84a Mon Sep 17 00:00:00 2001 From: grunjol Date: Mon, 24 Dec 2018 12:32:22 -0300 Subject: [PATCH] fix adding an existing language to a book --- cps/web.py | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/cps/web.py b/cps/web.py index e5e4b9d6..446f8b16 100644 --- a/cps/web.py +++ b/cps/web.py @@ -580,24 +580,29 @@ def modify_database_object(input_elements, db_book_object, db_object, db_session db_session.add(new_element) db_book_object.append(new_element) else: - if db_type == 'custom' and db_element.value != add_element: - new_element.value = add_element - # new_element = db_element - elif db_type == 'languages' and db_element.lang_code != add_element: - db_element.lang_code = add_element - # new_element = db_element - elif db_type == 'series' and db_element.name != add_element: - db_element.name = add_element # = add_element # new_element = db_object(add_element, add_element) - db_element.sort = add_element - # new_element = db_element - elif db_type == 'author' and db_element.name != add_element: - db_element.name = add_element - db_element.sort = add_element.replace('|', ',') - # new_element = db_element - if db_type == 'publisher' and db_element.name != add_element: - db_element.name = add_element - db_element.sort = None - # new_element = db_element + if db_type == 'custom': + if db_element.value != add_element: + new_element.value = add_element + # new_element = db_element + elif db_type == 'languages': + if db_element.lang_code != add_element: + db_element.lang_code = add_element + # new_element = db_element + elif db_type == 'series': + if db_element.name != add_element: + db_element.name = add_element # = add_element # new_element = db_object(add_element, add_element) + db_element.sort = add_element + # new_element = db_element + elif db_type == 'author': + if db_element.name != add_element: + db_element.name = add_element + db_element.sort = add_element.replace('|', ',') + # new_element = db_element + elif db_type == 'publisher': + if db_element.name != add_element: + db_element.name = add_element + db_element.sort = None + # new_element = db_element elif db_element.name != add_element: db_element.name = add_element # new_element = db_element