forked from openlp/openlp
Clean up files and correct mapper issues
Update Author Delete UI State bzr-revno: 282
This commit is contained in:
parent
29c4379275
commit
cc0ca326c3
@ -40,7 +40,6 @@ class AuthorsForm(QDialog, Ui_AuthorsDialog):
|
|||||||
self.AuthorListView.setColumnHidden(0, True)
|
self.AuthorListView.setColumnHidden(0, True)
|
||||||
self.AuthorListView.setColumnWidth(1, 300)
|
self.AuthorListView.setColumnWidth(1, 300)
|
||||||
self.AuthorListView.setHorizontalHeaderLabels(QtCore.QStringList([" ","Author"]))
|
self.AuthorListView.setHorizontalHeaderLabels(QtCore.QStringList([" ","Author"]))
|
||||||
self.candelete = False
|
|
||||||
self.currentrow = 0
|
self.currentrow = 0
|
||||||
self.author = None
|
self.author = None
|
||||||
|
|
||||||
@ -72,7 +71,6 @@ class AuthorsForm(QDialog, Ui_AuthorsDialog):
|
|||||||
"""
|
"""
|
||||||
Delete the author is the Author is not attached to any songs
|
Delete the author is the Author is not attached to any songs
|
||||||
"""
|
"""
|
||||||
if self.candelete == True:
|
|
||||||
self.songmanager.delete_author(self.author.id)
|
self.songmanager.delete_author(self.author.id)
|
||||||
self.on_ClearButton_clicked()
|
self.on_ClearButton_clicked()
|
||||||
self.load_form()
|
self.load_form()
|
||||||
@ -101,13 +99,14 @@ class AuthorsForm(QDialog, Ui_AuthorsDialog):
|
|||||||
self.FirstNameEdit.setText("")
|
self.FirstNameEdit.setText("")
|
||||||
self.LastNameEdit.setText("")
|
self.LastNameEdit.setText("")
|
||||||
self.MessageLabel.setText("")
|
self.MessageLabel.setText("")
|
||||||
self.candelete = True
|
self.DeleteButton.setEnabled(True)
|
||||||
self.author = None
|
self.author = None
|
||||||
|
|
||||||
@pyqtSignature("QTableWidgetItem*")
|
@pyqtSignature("QTableWidgetItem*")
|
||||||
def on_AuthorListView_itemClicked(self, item):
|
def on_AuthorListView_itemClicked(self, item):
|
||||||
"""
|
"""
|
||||||
Slot documentation goes here.
|
An Author has been selected display it
|
||||||
|
If the author is attached to a Song prevent delete
|
||||||
"""
|
"""
|
||||||
self.currentrow = self.AuthorListView.currentRow()
|
self.currentrow = self.AuthorListView.currentRow()
|
||||||
id = int(self.AuthorListView.item(self.currentrow, 0).text())
|
id = int(self.AuthorListView.item(self.currentrow, 0).text())
|
||||||
@ -119,8 +118,7 @@ class AuthorsForm(QDialog, Ui_AuthorsDialog):
|
|||||||
songs = self.songmanager.get_song_authors_for_author(id)
|
songs = self.songmanager.get_song_authors_for_author(id)
|
||||||
if len(songs) > 0:
|
if len(songs) > 0:
|
||||||
self.MessageLabel.setText("Author in use 'Delete' is disabled")
|
self.MessageLabel.setText("Author in use 'Delete' is disabled")
|
||||||
self.candelete = False
|
self.DeleteButton.setEnabled(False)
|
||||||
else:
|
else:
|
||||||
self.MessageLabel.setText("Author is not used")
|
self.MessageLabel.setText("Author is not used")
|
||||||
self.candelete = True
|
self.DeleteButton.setEnabled(True)
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ from songbookform import SongBookForm
|
|||||||
|
|
||||||
from editsongdialog import Ui_EditSongDialog
|
from editsongdialog import Ui_EditSongDialog
|
||||||
|
|
||||||
from openlp.plugins.songs.lib.songtable import Author
|
from openlp.plugins.songs.lib.songtable import *
|
||||||
|
|
||||||
class EditSongForm(QWidget, Ui_EditSongDialog):
|
class EditSongForm(QWidget, Ui_EditSongDialog):
|
||||||
"""
|
"""
|
||||||
|
@ -26,10 +26,11 @@ import string
|
|||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
from sqlalchemy.sql import select
|
from sqlalchemy.sql import select
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation, clear_mappers
|
from sqlalchemy.orm import scoped_session, sessionmaker
|
||||||
|
|
||||||
|
from openlp.plugins.songs.lib.songtables import *
|
||||||
|
from openlp.plugins.songs.lib.songclasses import *
|
||||||
|
|
||||||
from openlp.plugins.songs.lib.tables import *
|
|
||||||
from openlp.plugins.songs.lib.classes import *
|
|
||||||
from openlp.core.utils import ConfigHelper
|
from openlp.core.utils import ConfigHelper
|
||||||
|
|
||||||
class SongDBException(Exception):
|
class SongDBException(Exception):
|
||||||
@ -37,17 +38,6 @@ class SongDBException(Exception):
|
|||||||
class SongInvalidDatabaseError(Exception):
|
class SongInvalidDatabaseError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
clear_mappers() # some reason we need this
|
|
||||||
mapper(Author, authors_table)
|
|
||||||
mapper(Book, song_books_table)
|
|
||||||
mapper(Song, songs_table,
|
|
||||||
properties={'authors': relation(Author, backref='songs',
|
|
||||||
secondary=authors_songs_table),
|
|
||||||
'book': relation(Book, backref='songs'),
|
|
||||||
'topics': relation(Topic, backref='songs',
|
|
||||||
secondary=songs_topics_table)})
|
|
||||||
mapper(Topic, topics_table)
|
|
||||||
|
|
||||||
class SongDBImpl():
|
class SongDBImpl():
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger("SongDBImpl")
|
log=logging.getLogger("SongDBImpl")
|
||||||
@ -118,7 +108,7 @@ class SongDBImpl():
|
|||||||
|
|
||||||
def delete_author(self, authorid):
|
def delete_author(self, authorid):
|
||||||
log.debug( "delete_author %s" , authorid)
|
log.debug( "delete_author %s" , authorid)
|
||||||
# metadata.bind.echo = True
|
metadata.bind.echo = True
|
||||||
# s = text (""" delete FROM authors where authorid = :i """)
|
# s = text (""" delete FROM authors where authorid = :i """)
|
||||||
# return self.db.execute(s, i=authorid)
|
# return self.db.execute(s, i=authorid)
|
||||||
session = self.Session()
|
session = self.Session()
|
||||||
@ -126,6 +116,7 @@ class SongDBImpl():
|
|||||||
session.delete(author)
|
session.delete(author)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
|
|
||||||
def update_author(self, authorid, author_name, first_name, last_name):
|
def update_author(self, authorid, author_name, first_name, last_name):
|
||||||
log.debug( "update_author %s,%s,%s,%s" , authorid, author_name, first_name, last_name)
|
log.debug( "update_author %s,%s,%s,%s" , authorid, author_name, first_name, last_name)
|
||||||
metadata.bind.echo = True
|
metadata.bind.echo = True
|
||||||
|
@ -16,6 +16,8 @@ You should have received a copy of the GNU General Public License along with
|
|||||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
"""
|
"""
|
||||||
|
from sqlalchemy.orm import mapper, relation
|
||||||
|
from openlp.plugins.songs.lib.tables import *
|
||||||
|
|
||||||
class BaseModel(object):
|
class BaseModel(object):
|
||||||
"""
|
"""
|
||||||
@ -56,3 +58,14 @@ class Topic(BaseModel):
|
|||||||
Topic model
|
Topic model
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
mapper(Author, authors_table)
|
||||||
|
mapper(Book, song_books_table)
|
||||||
|
mapper(Song, songs_table,
|
||||||
|
properties={'authors': relation(Author, backref='songs',
|
||||||
|
secondary=authors_songs_table),
|
||||||
|
'book': relation(Book, backref='songs'),
|
||||||
|
'topics': relation(Topic, backref='songs',
|
||||||
|
secondary=songs_topics_table)})
|
||||||
|
mapper(Topic, topics_table)
|
@ -1,31 +0,0 @@
|
|||||||
"""
|
|
||||||
OpenLP - Open Source Lyrics Projection
|
|
||||||
Copyright (c) 2008 Raoul Snyman
|
|
||||||
Portions copyright (c) 2008 Martin Thompson, Tim Bentley
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
|
||||||
Foundation; version 2 of the License.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
||||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along with
|
|
||||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
||||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
"""
|
|
||||||
class Author(object):
|
|
||||||
def __init__(self, authorname, first_name, last_name):
|
|
||||||
self.authorname =authorname
|
|
||||||
self.first_name =first_name
|
|
||||||
self.last_name =last_name
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return "<authormeta(%r,%r,%r)>" %(self.authorname, self.first_name, self.last_name)
|
|
||||||
|
|
||||||
def get_author(self):
|
|
||||||
return self.authorname, self.first_name, self.last_name
|
|
||||||
|
|
||||||
def get_author_name(self):
|
|
||||||
return self.authorname
|
|
@ -26,7 +26,7 @@ from openlp.core.lib import Plugin,PluginUtils, MediaManagerItem
|
|||||||
from forms import EditSongForm, OpenLPImportForm, OpenSongImportForm, \
|
from forms import EditSongForm, OpenLPImportForm, OpenSongImportForm, \
|
||||||
OpenLPExportForm, OpenSongExportForm
|
OpenLPExportForm, OpenSongExportForm
|
||||||
from openlp.plugins.songs.lib import SongManager
|
from openlp.plugins.songs.lib import SongManager
|
||||||
from openlp.plugins.songs.lib.classes import *
|
from openlp.plugins.songs.lib.songclasses import *
|
||||||
|
|
||||||
class SongsPlugin(Plugin, PluginUtils):
|
class SongsPlugin(Plugin, PluginUtils):
|
||||||
global log
|
global log
|
||||||
|
Loading…
Reference in New Issue
Block a user