Tim Bentley has proposed merging lp:~trb143/openlp/audit into lp:openlp. Requested reviews: openlp.org Core (openlp-core)
Clean up audit to use database instead of CSV file Add code to add records Clean up files no longer needed. Clean up comments Custom plugin Standarize Songs/ Custom and Audit database code. -- https://code.launchpad.net/~trb143/openlp/audit/+merge/12300 Your team openlp.org Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/__init__.py' --- openlp/core/lib/__init__.py 2009-09-21 18:59:35 +0000 +++ openlp/core/lib/__init__.py 2009-09-21 19:23:51 +0000 @@ -127,7 +127,6 @@ from rendermanager import RenderManager from mediamanageritem import MediaManagerItem from baselistwithdnd import BaseListWithDnD -from listwithpreviews import ListWithPreviews __all__ = [ 'translate', 'file_to_xml', 'str_to_bool', 'contextMenuAction', 'contextMenuSeparator','ServiceItem'] === removed file 'openlp/core/lib/listwithpreviews.py' --- openlp/core/lib/listwithpreviews.py 2009-09-08 19:58:05 +0000 +++ openlp/core/lib/listwithpreviews.py 1970-01-01 00:00:00 +0000 @@ -1,122 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2009 Raoul Snyman # -# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # -# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # -# --------------------------------------------------------------------------- # -# 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 # -############################################################################### - -import os -import logging -from PyQt4 import QtCore, QtGui - -class ListWithPreviews(QtCore.QAbstractListModel): - """ - An abstract list of unicodeings and the preview icon to go with them - """ - global log - log = logging.getLogger(u'ListWithPreviews') - log.info(u'started') - - def __init__(self, new_preview_function=None): - QtCore.QAbstractListModel.__init__(self) - # will be a list of (full filename, QPixmap, shortname) tuples - self.items = [] - self.rowheight = 50 - self.maximagewidth = self.rowheight * 16 / 9.0; - self.preview_function = new_preview_function - - def make_preview(self, filename): - if os.path.exists(filename): - if self.preview_function is not None: - preview=self.preview_function(filename) - else: - preview = QtGui.QImage(filename) - else: - preview = None - - if preview is not None: - w = self.maximagewidth; - h = self.rowheight - preview = preview.scaled(w, h, QtCore.Qt.KeepAspectRatio, - QtCore.Qt.SmoothTransformation) - realw = preview.width(); - realh = preview.height() - # and move it to the centre of the preview space - p = QtGui.QImage(w, h, QtGui.QImage.Format_ARGB32_Premultiplied) - p.fill(QtCore.Qt.transparent) - painter = QtGui.QPainter(p) - painter.drawImage((w-realw) / 2, (h-realh) / 2, preview) - else: - w = self.maximagewidth; - h = self.rowheight - p = QtGui.QImage(w, h, QtGui.QImage.Format_ARGB32_Premultiplied) - p.fill(QtCore.Qt.transparent) - return p - - def rowCount(self, parent): - return len(self.items) - - def insertRow(self, row, filename): - self.beginInsertRows(QtCore.QModelIndex(), row, row) - #log.info(u'insert row %d:%s' % (row,filename)) - # get short filename to display next to image - filename = unicode(filename) - (prefix, shortfilename) = os.path.split(filename) - #log.info(u'shortfilename=%s' % (shortfilename)) - # create a preview image - p=self.make_preview(filename) - # finally create the row - self.items.insert(row, (filename, p, shortfilename)) - self.endInsertRows() - - def removeRow(self, row): - self.beginRemoveRows(QtCore.QModelIndex(), row, row) - self.items.pop(row) - self.endRemoveRows() - - def addRow(self, filename): - self.insertRow(len(self.items), filename) - - def data(self, index, role): - row = index.row() - if row > len(self.items): - # If the last row is selected and deleted, we then get called - # with an empty row! - return QtCore.QVariant() - if role == QtCore.Qt.DisplayRole: - retval = self.items[row][2] - elif role == QtCore.Qt.DecorationRole: - retval = self.items[row][1] - elif role == QtCore.Qt.ToolTipRole: - retval = self.items[row][0] - else: - retval = QtCore.QVariant() - if type(retval) is not type(QtCore.QVariant): - return QtCore.QVariant(retval) - else: - return retval - - def getFileList(self): - filelist = [item[0] for item in self.items]; - return filelist - - def getFilename(self, index): - row = index.row() - return self.items[row][0] === modified file 'openlp/core/ui/mainwindow.py' --- openlp/core/ui/mainwindow.py 2009-09-21 17:56:36 +0000 +++ openlp/core/ui/mainwindow.py 2009-09-23 15:51:03 +0000 @@ -405,11 +405,11 @@ self.action_Preview_Panel.setStatusTip(translate(u'mainWindow', u'Toggle the visibility of the Preview Panel')) self.action_Preview_Panel.setShortcut(translate(u'mainWindow', u'F11')) - self.ToolsAlertItem.setText(translate(u'mainWindow', u'&Alert')) + self.ToolsAlertItem.setText(translate(u'mainWindow', u'Trigger &Alert')) self.ToolsAlertItem.setStatusTip( translate(u'mainWindow', u'Show an alert message')) self.ToolsAlertItem.setShortcut(translate(u'mainWindow', u'F7')) - self.PluginItem.setText(translate(u'mainWindow', u'&Plugin')) + self.PluginItem.setText(translate(u'mainWindow', u'List &Plugins')) self.PluginItem.setStatusTip( translate(u'mainWindow', u'List the Plugins')) self.PluginItem.setShortcut(translate(u'mainWindow', u'Alt+F7')) @@ -510,16 +510,16 @@ QtCore.SIGNAL(u'triggered()'), self.onOptionsSettingsItemClicked) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'update_global_theme'), self.defaultThemeChanged) - QtCore.QObject.connect(self.FileNewItem, + QtCore.QObject.connect(self.FileNewItem, QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.onNewService) - QtCore.QObject.connect(self.FileOpenItem, + QtCore.QObject.connect(self.FileOpenItem, QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.onLoadService) - QtCore.QObject.connect(self.FileSaveItem, + QtCore.QObject.connect(self.FileSaveItem, QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.onQuickSaveService) - QtCore.QObject.connect(self.FileSaveAsItem, + QtCore.QObject.connect(self.FileSaveAsItem, QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.onSaveService) #warning cyclic dependency === modified file 'openlp/plugins/audit/auditplugin.py' --- openlp/plugins/audit/auditplugin.py 2009-09-21 17:56:36 +0000 +++ openlp/plugins/audit/auditplugin.py 2009-09-23 17:36:22 +0000 @@ -22,13 +22,14 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +from datetime import datetime import logging from PyQt4 import QtCore, QtGui -from datetime import date from openlp.core.lib import Plugin, Receiver, translate, str_to_bool -from openlp.plugins.audit.lib import AuditTab +from openlp.plugins.audit.lib import AuditTab, AuditManager +from openlp.plugins.audit.lib.models import AuditItem class AuditPlugin(Plugin): global log @@ -97,16 +98,10 @@ QtCore.SIGNAL(u'audit_live'), self.onReceiveAudit) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'audit_changed'), self.onUpdateAudit) - self.auditFileName = self.config.get_config(u'audit file', u'') self.auditActive = str_to_bool( self.config.get_config(u'audit active', False)) - if self.auditFileName == u'': - self.auditActive = False - self.ToolsAuditItem.setEnabled(False) - self.auditFile = None - else: - self.auditFile = open(self.auditFileName, u'a') self.ToolsAuditItem.setChecked(self.auditActive) + self.auditmanager = AuditManager(self.config) def toggleAuditState(self): self.auditActive = not self.auditActive @@ -117,17 +112,21 @@ Audit a live song from SlideController """ if self.auditActive: + audititem = AuditItem() + audititem.auditdate = datetime.today() + audititem.audittime = datetime.now().time() + audititem.title = auditData[0] + audititem.ccl_id = auditData[2] + audititem.authors = u'' for author in auditData[1]: - self.auditFile.write(u'\"%s\",\"%s\",\"%s\",\"%s\"\n' % \ - (date.today(), auditData[0], author, auditData[2])) - self.auditFile.flush() + audititem.authors += author + u' ' + self.auditmanager.insert_audit(audititem) def onUpdateAudit(self): """ Someone may have changed to audit details Sort out the file and the auditing state """ - self.auditFileNameNew = self.config.get_config(u'audit file', u'') self.auditActive = str_to_bool( self.config.get_config(u'audit active', False)) if self.auditFileNameNew == u'': @@ -141,7 +140,3 @@ self.auditFile.close() self.auditFile = open(self.auditFileNameNew, u'a') - def finalise(self): - log.debug(u'Finalise') - if self.auditFile is not None: - self.auditFile.close() === modified file 'openlp/plugins/audit/lib/__init__.py' --- openlp/plugins/audit/lib/__init__.py 2009-09-17 18:24:13 +0000 +++ openlp/plugins/audit/lib/__init__.py 2009-09-23 16:33:30 +0000 @@ -23,3 +23,4 @@ ############################################################################### from audittab import AuditTab +from manager import AuditManager === modified file 'openlp/plugins/audit/lib/audittab.py' --- openlp/plugins/audit/lib/audittab.py 2009-09-21 17:56:36 +0000 +++ openlp/plugins/audit/lib/audittab.py 2009-09-23 15:51:03 +0000 @@ -39,27 +39,12 @@ self.AuditModeGroupBox.setObjectName(u'AuditModeGroupBox') self.verticalLayout = QtGui.QVBoxLayout(self.AuditModeGroupBox) self.verticalLayout.setObjectName("verticalLayout") - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.AuditFileName = QtGui.QLineEdit(self) - self.AuditFileName.setObjectName("AuditFileName") - self.horizontalLayout.addWidget(self.AuditFileName) - icon1 = QtGui.QIcon() - icon1.addPixmap(QtGui.QPixmap(u':/imports/import_load.png'), - QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.AuditFileButton = QtGui.QPushButton(self) - self.AuditFileButton.setObjectName("AuditFileButton") - self.AuditFileButton.setIcon(icon1) - self.horizontalLayout.addWidget(self.AuditFileButton) - self.verticalLayout.addLayout(self.horizontalLayout) self.AuditActive = QtGui.QCheckBox(self) self.AuditActive.setObjectName("AuditActive") self.verticalLayout.addWidget(self.AuditActive) self.WarningLabel = QtGui.QLabel(self) self.WarningLabel.setObjectName("WarningLabel") self.verticalLayout.addWidget(self.WarningLabel) - QtCore.QObject.connect(self.AuditFileButton, - QtCore.SIGNAL(u'pressed()'), self.onAuditFileButtonClicked) def retranslateUi(self): self.AuditModeGroupBox.setTitle(translate(u'AuditTab', u'Audit File')) @@ -68,19 +53,9 @@ u'A restart is needed for this change to become effective')) def load(self): - self.AuditFileName.setText(self.config.get_config(u'Audit file', u'')) self.AuditActive.setChecked(int(self.config.get_config(u'startup', 0))) - def onAuditFileButtonClicked(self): - filename = QtGui.QFileDialog.getOpenFileName( - self, u'Audit File',self.AuditFileName.text()) - if filename != u'': - filename = unicode(filename) - self.AuditFileName.setText(filename) - def save(self): self.config.set_config( - u'Audit file', unicode(self.AuditFileName.text())) - self.config.set_config( u'startup', unicode(self.AuditActive.checkState())) Receiver().send_message(u'audit_changed') === added file 'openlp/plugins/audit/lib/classes.py' --- openlp/plugins/audit/lib/classes.py 1970-01-01 00:00:00 +0000 +++ openlp/plugins/audit/lib/classes.py 2009-09-23 15:51:03 +0000 @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # +# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # +# --------------------------------------------------------------------------- # +# 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 BaseModel(object): + """ + BaseModel provides a base object with a set of generic functions + """ + + @classmethod + def populate(cls, **kwargs): + """ + Creates an instance of a class and populates it, returning the instance + """ + me = cls() + keys = kwargs.keys() + for key in keys: + me.__setattr__(key, kwargs[key]) + return me + +class AuditItem(BaseModel): + """ + Audit model + """ + pass === added file 'openlp/plugins/audit/lib/manager.py' --- openlp/plugins/audit/lib/manager.py 1970-01-01 00:00:00 +0000 +++ openlp/plugins/audit/lib/manager.py 2009-09-23 17:36:22 +0000 @@ -0,0 +1,111 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # +# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### + +import os, os.path +import sys + +from sqlalchemy import asc, desc +from openlp.plugins.audit.lib.models import init_models, metadata, session, \ + engine, AuditItem, audit_table + +import logging + +class AuditManager(): + """ + The Song Manager provides a central location for all database code. This + class takes care of connecting to the database and running all the queries. + """ + + global log + log=logging.getLogger(u'AuditManager') + log.info(u'Audit manager loaded') + + def __init__(self, config): + """ + Creates the connection to the database, and creates the tables if they + don't exist. + """ + self.config = config + log.debug(u'Audit Initialising') + self.db_url = u'' + db_type = self.config.get_config(u'db type', u'sqlite') + if db_type == u'sqlite': + self.db_url = u'sqlite:///%s/audit.sqlite' % \ + self.config.get_data_path() + else: + self.db_url = u'%s://%s:%...@%s/%s' % \ + (db_type, self.config.get_config(u'db username'), + self.config.get_config(u'db password'), + self.config.get_config(u'db hostname'), + self.config.get_config(u'db database')) + self.session = init_models(self.db_url) + metadata.create_all(checkfirst=True) + + log.debug(u'Audit Initialised') + + def get_all_audits(self): + """ + Returns the details of a audit + """ + return self.session.query(AuditItem).order_by(AuditItem.title).all() + + def insert_audit(self, audititem): + """ + Saves an audit to the database + """ + log.debug(u'Audit added') + try: + self.session.add(audititem) + self.session.commit() + return True + except: + self.session.rollback() + log.exception(u'Audit item failed to save') + return False + + def get_audit(self, id=None): + """ + Returns the details of an audit + """ + if id is None: + return AuditItem() + else: + return self.session.query(AuditItem).get(id) + + def delete_audit(self, id): + """ + Delete a audit record + """ + if id !=0: + audititem = self.get_audit(id) + try: + self.session.delete(audititem) + self.session.commit() + return True + except: + self.session.rollback() + log.excertion(u'Audit Item failed to delete') + return False + else: + return True === added file 'openlp/plugins/audit/lib/meta.py' --- openlp/plugins/audit/lib/meta.py 1970-01-01 00:00:00 +0000 +++ openlp/plugins/audit/lib/meta.py 2009-09-22 19:37:36 +0000 @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # +# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### + +from sqlalchemy import MetaData +from sqlalchemy.orm import scoped_session, sessionmaker + +__all__ = ['session', 'metadata', 'engine'] + +# SQLAlchemy database engine. Updated by model.init_model() +engine = None + +# SQLAlchemy session manager. Updated by model.init_model() +session = None + +# Global metadata. If you have multiple databases with overlapping table +# names, you'll need a metadata for each database +metadata = MetaData() === added file 'openlp/plugins/audit/lib/models.py' --- openlp/plugins/audit/lib/models.py 1970-01-01 00:00:00 +0000 +++ openlp/plugins/audit/lib/models.py 2009-09-23 15:51:03 +0000 @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # +# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### + +from sqlalchemy import create_engine +from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation + +from openlp.plugins.audit.lib.meta import session, metadata, engine +from openlp.plugins.audit.lib.tables import * +from openlp.plugins.audit.lib.classes import * + +def init_models(url): + engine = create_engine(url) + metadata.bind = engine + session = scoped_session(sessionmaker(autoflush=True, autocommit=False, + bind=engine)) + mapper(AuditItem, audit_table) + return session === added file 'openlp/plugins/audit/lib/tables.py' --- openlp/plugins/audit/lib/tables.py 1970-01-01 00:00:00 +0000 +++ openlp/plugins/audit/lib/tables.py 2009-09-23 16:33:30 +0000 @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # +# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### + +from sqlalchemy import Column, Table, ForeignKey, types + +from openlp.plugins.audit.lib.meta import metadata + +# Definition of the "songs" table +audit_table = Table(u'audit_data', metadata, + Column(u'id', types.Integer(), primary_key=True), + Column(u'auditdate', types.Date, index=True, nullable=False), + Column(u'audittime', types.Time, index=True, nullable=False), + Column(u'title', types.Unicode(255), nullable=False), + Column(u'authors', types.Unicode(255), nullable=False), + Column(u'ccl_id', types.Unicode(65), nullable=False) +) === modified file 'openlp/plugins/custom/lib/classes.py' --- openlp/plugins/custom/lib/classes.py 2009-09-08 19:58:05 +0000 +++ openlp/plugins/custom/lib/classes.py 2009-09-23 15:51:03 +0000 @@ -40,6 +40,6 @@ class CustomSlide(BaseModel): """ - Author model + Custom Slide model """ pass === modified file 'openlp/plugins/custom/lib/manager.py' --- openlp/plugins/custom/lib/manager.py 2009-09-08 19:58:05 +0000 +++ openlp/plugins/custom/lib/manager.py 2009-09-23 15:51:03 +0000 @@ -51,8 +51,8 @@ self.db_url = u'' db_type = self.config.get_config(u'db type', u'sqlite') if db_type == u'sqlite': - self.db_url = u'sqlite:///' + self.config.get_data_path() + \ - u'/custom.sqlite' + self.db_url = u'sqlite:///%s/custom.sqlite' % \ + self.config.get_data_path() else: self.db_url = u'%s://%s:%...@%s/%s' % \ (db_type, self.config.get_config(u'db username'), @@ -60,23 +60,19 @@ self.config.get_config(u'db hostname'), self.config.get_config(u'db database')) self.session = init_models(self.db_url) - if not custom_slide_table.exists(): - metadata.create_all() + metadata.create_all(checkfirst=True) log.debug(u'Custom Initialised') -# -# def process_dialog(self, dialogobject): -# self.dialogobject = dialogobject -# + def get_all_slides(self): """ - Returns the details of a song + Returns the details of a Custom Slide Show """ return self.session.query(CustomSlide).order_by(CustomSlide.title).all() def save_slide(self, customslide): """ - Saves a song to the database + Saves a Custom slide show to the database """ log.debug(u'Custom Slide added') try: @@ -85,7 +81,8 @@ log.debug(u'Custom Slide saved') return True except: - log.debug(u'Custom Slide failed') + self.session.rollback() + log.excertion(u'Custom Slide save failed') return False def get_custom(self, id=None): @@ -98,6 +95,9 @@ return self.session.query(CustomSlide).get(id) def delete_custom(self, id): + """ + Delete a Custom slide show + """ if id !=0: customslide = self.get_custom(id) try: @@ -105,6 +105,8 @@ self.session.commit() return True except: + self.session.rollback() + log.excertion(u'Custom Slide deleton failed') return False else: return True === modified file 'openlp/plugins/images/imageplugin.py' --- openlp/plugins/images/imageplugin.py 2009-09-21 17:56:36 +0000 +++ openlp/plugins/images/imageplugin.py 2009-09-22 19:23:12 +0000 @@ -51,6 +51,3 @@ # Create the MediaManagerItem object self.media_item = ImageMediaItem(self, self.icon, u'Images') return self.media_item - - def initialise(self): - log.info(u'Plugin Initialising') === modified file 'openlp/plugins/images/lib/imagetab.py' --- openlp/plugins/images/lib/imagetab.py 2009-09-21 17:56:36 +0000 +++ openlp/plugins/images/lib/imagetab.py 2009-09-22 19:36:25 +0000 @@ -37,16 +37,16 @@ self.setObjectName(u'ImageTab') self.ImageLayout = QtGui.QFormLayout(self) self.ImageLayout.setObjectName(u'ImageLayout') - self.ImageModeGroupBox = QtGui.QGroupBox(self) - self.ImageModeGroupBox.setObjectName(u'ImageModeGroupBox') - self.TimeoutLayout = QtGui.QHBoxLayout(self.ImageModeGroupBox) + self.ImageSettingsGroupBox = QtGui.QGroupBox(self) + self.ImageSettingsGroupBox.setObjectName(u'ImageSettingsGroupBox') + self.TimeoutLayout = QtGui.QHBoxLayout(self.ImageSettingsGroupBox) self.TimeoutLayout.setSpacing(8) self.TimeoutLayout.setMargin(0) self.TimeoutLayout.setObjectName(u'TimeoutLayout') - self.TimeoutLabel = QtGui.QLabel(self.ImageModeGroupBox) + self.TimeoutLabel = QtGui.QLabel(self.ImageSettingsGroupBox) self.TimeoutLabel.setObjectName(u'TimeoutLabel') self.TimeoutLayout.addWidget(self.TimeoutLabel) - self.TimeoutSpinBox = QtGui.QSpinBox(self.ImageModeGroupBox) + self.TimeoutSpinBox = QtGui.QSpinBox(self.ImageSettingsGroupBox) self.TimeoutSpinBox.setMaximum(180) self.TimeoutSpinBox.setObjectName(u'TimeoutSpinBox') self.TimeoutLayout.addWidget(self.TimeoutSpinBox) @@ -54,12 +54,13 @@ QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.TimeoutLayout.addItem(self.TimeoutSpacer) self.ImageLayout.setWidget( - 0, QtGui.QFormLayout.LabelRole, self.ImageModeGroupBox) + 0, QtGui.QFormLayout.LabelRole, self.ImageSettingsGroupBox) # Signals and slots QtCore.QObject.connect(self.TimeoutSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.onTimeoutSpinBoxChanged) def retranslateUi(self): + self.ImageSettingsGroupBox.setTitle(translate(u'ImageTab', u'Image Settings')) self.TimeoutLabel.setText(translate(u'ImageTab', u'Slide Loop Delay:')) self.TimeoutSpinBox.setSuffix(translate(u'ImageTab', u's')) === modified file 'openlp/plugins/media/lib/mediaitem.py' --- openlp/plugins/media/lib/mediaitem.py 2009-09-21 17:56:36 +0000 +++ openlp/plugins/media/lib/mediaitem.py 2009-09-22 19:23:12 +0000 @@ -118,7 +118,3 @@ item_name.setIcon(buildIcon(img)) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) self.ListView.addItem(item_name) - -# def onMediaAddClick(self): -# log.debug(u'Media Add Button pressed') -# pass === modified file 'openlp/plugins/media/mediaplugin.py' --- openlp/plugins/media/mediaplugin.py 2009-09-08 19:58:05 +0000 +++ openlp/plugins/media/mediaplugin.py 2009-09-21 19:23:51 +0000 @@ -27,6 +27,7 @@ from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab from openlp.plugins.media.lib import MediaTab,MediaMediaItem + class MediaPlugin(Plugin): def __init__(self, plugin_helpers):
_______________________________________________ Mailing list: https://launchpad.net/~openlp-core Post to : openlp-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~openlp-core More help : https://help.launchpad.net/ListHelp