fixes for merge

This commit is contained in:
andreas 2010-07-10 23:26:09 +02:00
parent d6fe2d1c9f
commit ab179f8e12
1 changed files with 12 additions and 31 deletions

View File

@ -138,26 +138,18 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
""" """
Returns True when the given Author is already in the list elsewise False. Returns True when the given Author is already in the list elsewise False.
""" """
new_author_first_name = new_author.first_name
new_author_last_name = new_author.last_name
new_author_display_name = new_author.display_name
authors = self.songmanager.get_all_objects(Author) authors = self.songmanager.get_all_objects(Author)
author_exists = False author_exists = False
for author in authors: for author in authors:
author_fist_name = author.first_name if author.fist_name == new_author.first_name and \
author_last_name = author.last_name author.last_name == new_author.last_name and \
author_display_name = author.display_name author.display_name == new_author.display_name:
if author_fist_name == new_author_first_name and \
author_last_name == new_author_last_name and \
author_display_name == new_author_display_name:
author_exists = True author_exists = True
#If we edit an exsisting Author, we need to make sure that we do #If we edit an exsisting Author, we need to make sure that we do
#not return True when nothing has changed (because this would #not return True when nothing has changed (because this would
#cause an error message later on) #cause an error message later on)
if edit: if edit:
new_author_id = new_author.id if new_author.id == author.id:
author_id = author.id
if new_author_id == author_id:
author_exists = False author_exists = False
return author_exists return author_exists
@ -165,20 +157,16 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
""" """
Returns True when the given Topic is already in the list elsewise False. Returns True when the given Topic is already in the list elsewise False.
""" """
new_topic_name = new_topic.name
topics = self.songmanager.get_all_objects(Topic) topics = self.songmanager.get_all_objects(Topic)
topic_exists = False topic_exists = False
for topic in topics: for topic in topics:
topic_name = topic.name if topic.name == new_topic.name:
if topic_name == new_topic_name:
topic_exists = True topic_exists = True
#If we edit an exsisting Topic, we need to make sure that we do #If we edit an exsisting Topic, we need to make sure that we do
#not return True when nothing has changed (because this would #not return True when nothing has changed (because this would
#cause an error message later on) #cause an error message later on)
if edit: if edit:
new_topic_id = new_topic.id if new_topic.id == topic.id:
topic_id = topic.id
if new_topic_id == topic_id:
topic_exists = False topic_exists = False
return topic_exists return topic_exists
@ -186,23 +174,17 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
""" """
Returns True when the given Book is already in the list elsewise False. Returns True when the given Book is already in the list elsewise False.
""" """
new_book_name = new_book.name
new_book_publisher = new_book.publisher
books = self.songmanager.get_all_objects(Book) books = self.songmanager.get_all_objects(Book)
book_exists = False book_exists = False
for book in books: for book in books:
book_name = book.name if book.publisher == new_book.publisher and \
book_publisher = book.publisher book.name == new_book.name:
if book_publisher == new_book_publisher and \
book_name == new_book_name:
book_exists = True book_exists = True
#If we edit an exsisting Book, we need to make sure that we do #If we edit an exsisting Book, we need to make sure that we do
#not return True when nothing has changed (because this would #not return True when nothing has changed (because this would
#cause an error message later on) #cause an error message later on)
if edit: if edit:
new_book_id = new_book.id if new_book.id == book.id:
book_id = book.id
if new_book_id == book_id:
book_exists = False book_exists = False
return book_exists return book_exists
@ -213,7 +195,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
first_name=unicode(self.authorform.FirstNameEdit.text()), first_name=unicode(self.authorform.FirstNameEdit.text()),
last_name=unicode(self.authorform.LastNameEdit.text()), last_name=unicode(self.authorform.LastNameEdit.text()),
display_name=unicode(self.authorform.DisplayEdit.text())) display_name=unicode(self.authorform.DisplayEdit.text()))
if self.checkAuthor(author) is False and \ if not self.checkAuthor(author) and \
self.songmanager.save_object(author): self.songmanager.save_object(author):
self.resetAuthors() self.resetAuthors()
else: else:
@ -225,7 +207,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
def onTopicAddButtonClick(self): def onTopicAddButtonClick(self):
if self.topicform.exec_(): if self.topicform.exec_():
topic = Topic.populate(name=unicode(self.topicform.NameEdit.text())) topic = Topic.populate(name=unicode(self.topicform.NameEdit.text()))
if self.checkTopic(topic) is False and \ if not self.checkTopic(topic) and \
self.songmanager.save_object(topic): self.songmanager.save_object(topic):
self.resetTopics() self.resetTopics()
else: else:
@ -239,8 +221,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
book = Book.populate( book = Book.populate(
name=unicode(self.bookform.NameEdit.text()), name=unicode(self.bookform.NameEdit.text()),
publisher=unicode(self.bookform.PublisherEdit.text())) publisher=unicode(self.bookform.PublisherEdit.text()))
if self.checkBook(book) is False and \ if not self.checkBook(book) and self.songmanager.save_object(book):
self.songmanager.save_object(book):
self.resetBooks() self.resetBooks()
else: else:
QtGui.QMessageBox.critical(self, QtGui.QMessageBox.critical(self,