Partly fixed #661: Right order of Authors is still not shown
This commit is contained in:
		
							parent
							
								
									f821580b50
								
							
						
					
					
						commit
						4dcac07582
					
				| 
						 | 
					@ -262,11 +262,14 @@ def delete_book_file(book, calibrepath, book_format=None):
 | 
				
			||||||
                return False
 | 
					                return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def update_dir_structure_file(book_id, calibrepath):
 | 
					def update_dir_structure_file(book_id, calibrepath, first_author):
 | 
				
			||||||
    localbook = db.session.query(db.Books).filter(db.Books.id == book_id).first()
 | 
					    localbook = db.session.query(db.Books).filter(db.Books.id == book_id).first()
 | 
				
			||||||
    path = os.path.join(calibrepath, localbook.path)
 | 
					    path = os.path.join(calibrepath, localbook.path)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    authordir = localbook.path.split('/')[0]
 | 
					    authordir = localbook.path.split('/')[0]
 | 
				
			||||||
 | 
					    if first_author:
 | 
				
			||||||
 | 
					        new_authordir = get_valid_filename(first_author)
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
        new_authordir = get_valid_filename(localbook.authors[0].name)
 | 
					        new_authordir = get_valid_filename(localbook.authors[0].name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    titledir = localbook.path.split('/')[1]
 | 
					    titledir = localbook.path.split('/')[1]
 | 
				
			||||||
| 
						 | 
					@ -300,11 +303,14 @@ def update_dir_structure_file(book_id, calibrepath):
 | 
				
			||||||
    return False
 | 
					    return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def update_dir_structure_gdrive(book_id):
 | 
					def update_dir_structure_gdrive(book_id, first_author):
 | 
				
			||||||
    error = False
 | 
					    error = False
 | 
				
			||||||
    book = db.session.query(db.Books).filter(db.Books.id == book_id).first()
 | 
					    book = db.session.query(db.Books).filter(db.Books.id == book_id).first()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    authordir = book.path.split('/')[0]
 | 
					    authordir = book.path.split('/')[0]
 | 
				
			||||||
 | 
					    if first_author:
 | 
				
			||||||
 | 
					        new_authordir = get_valid_filename(first_author)
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
        new_authordir = get_valid_filename(book.authors[0].name)
 | 
					        new_authordir = get_valid_filename(book.authors[0].name)
 | 
				
			||||||
    titledir = book.path.split('/')[1]
 | 
					    titledir = book.path.split('/')[1]
 | 
				
			||||||
    new_titledir = get_valid_filename(book.title) + " (" + str(book_id) + ")"
 | 
					    new_titledir = get_valid_filename(book.title) + " (" + str(book_id) + ")"
 | 
				
			||||||
| 
						 | 
					@ -356,11 +362,11 @@ def generate_random_password():
 | 
				
			||||||
 | 
					
 | 
				
			||||||
################################## External interface
 | 
					################################## External interface
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def update_dir_stucture(book_id, calibrepath):
 | 
					def update_dir_stucture(book_id, calibrepath, first_author = None):
 | 
				
			||||||
    if ub.config.config_use_google_drive:
 | 
					    if ub.config.config_use_google_drive:
 | 
				
			||||||
        return update_dir_structure_gdrive(book_id)
 | 
					        return update_dir_structure_gdrive(book_id, first_author)
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        return update_dir_structure_file(book_id, calibrepath)
 | 
					        return update_dir_structure_file(book_id, calibrepath, first_author)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def delete_book(book, calibrepath, book_format):
 | 
					def delete_book(book, calibrepath, book_format):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										19
									
								
								cps/web.py
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								cps/web.py
									
									
									
									
									
								
							| 
						 | 
					@ -532,6 +532,7 @@ def modify_database_object(input_elements, db_book_object, db_object, db_session
 | 
				
			||||||
            type_elements = c_elements.name
 | 
					            type_elements = c_elements.name
 | 
				
			||||||
        for inp_element in input_elements:
 | 
					        for inp_element in input_elements:
 | 
				
			||||||
            if inp_element.lower() == type_elements.lower():
 | 
					            if inp_element.lower() == type_elements.lower():
 | 
				
			||||||
 | 
					                # if inp_element == type_elements:
 | 
				
			||||||
                found = True
 | 
					                found = True
 | 
				
			||||||
                break
 | 
					                break
 | 
				
			||||||
        # if the element was not found in the new list, add it to remove list
 | 
					        # if the element was not found in the new list, add it to remove list
 | 
				
			||||||
| 
						 | 
					@ -3656,22 +3657,24 @@ def edit_book(book_id):
 | 
				
			||||||
        # we have all author names now
 | 
					        # we have all author names now
 | 
				
			||||||
        if input_authors == ['']:
 | 
					        if input_authors == ['']:
 | 
				
			||||||
            input_authors = [_(u'unknown')]  # prevent empty Author
 | 
					            input_authors = [_(u'unknown')]  # prevent empty Author
 | 
				
			||||||
        if book.authors:
 | 
					
 | 
				
			||||||
            author0_before_edit = book.authors[0].name
 | 
					 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
            author0_before_edit = db.Authors(_(u'unknown'), '', 0)
 | 
					 | 
				
			||||||
        modify_database_object(input_authors, book.authors, db.Authors, db.session, 'author')
 | 
					        modify_database_object(input_authors, book.authors, db.Authors, db.session, 'author')
 | 
				
			||||||
        if book.authors:
 | 
					
 | 
				
			||||||
            if author0_before_edit != book.authors[0].name:
 | 
					        sort_authors_list = list()
 | 
				
			||||||
 | 
					        for inp in input_authors:
 | 
				
			||||||
 | 
					            sort_authors_list.append(helper.get_sorted_author(inp))
 | 
				
			||||||
 | 
					        sort_authors = ' & '.join(sort_authors_list)
 | 
				
			||||||
 | 
					        if book.author_sort != sort_authors:
 | 
				
			||||||
            edited_books_id = book.id
 | 
					            edited_books_id = book.id
 | 
				
			||||||
                book.author_sort = helper.get_sorted_author(input_authors[0])
 | 
					            book.author_sort = sort_authors
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if config.config_use_google_drive:
 | 
					        if config.config_use_google_drive:
 | 
				
			||||||
            gdriveutils.updateGdriveCalibreFromLocal()
 | 
					            gdriveutils.updateGdriveCalibreFromLocal()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        error = False
 | 
					        error = False
 | 
				
			||||||
        if edited_books_id:
 | 
					        if edited_books_id:
 | 
				
			||||||
            error = helper.update_dir_stucture(edited_books_id, config.config_calibre_dir)
 | 
					            error = helper.update_dir_stucture(edited_books_id, config.config_calibre_dir, input_authors[0])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if not error:
 | 
					        if not error:
 | 
				
			||||||
            if to_save["cover_url"]:
 | 
					            if to_save["cover_url"]:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user