From 51fb1533bda69de9c3ef1e99b12ace6b4779d884 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 23 Sep 2009 17:33:30 +0100 Subject: [PATCH] Audit database addition insert 1 --- openlp/plugins/audit/auditplugin.py | 17 ++++++++++++----- openlp/plugins/audit/lib/__init__.py | 9 +++------ openlp/plugins/audit/lib/tables.py | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/openlp/plugins/audit/auditplugin.py b/openlp/plugins/audit/auditplugin.py index e5e60e95e..10cc701f8 100644 --- a/openlp/plugins/audit/auditplugin.py +++ b/openlp/plugins/audit/auditplugin.py @@ -22,13 +22,15 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +from datetime import date +from time import time 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, AuditManager +from openlp.plugins.audit.lib.models import AuditItem class AuditPlugin(Plugin): global log @@ -111,17 +113,22 @@ class AuditPlugin(Plugin): Audit a live song from SlideController """ if self.auditActive: + audititem = AuditItem() + audititem.auditdate = date.today() + a = time.time() + audititem.audittime = time.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'': diff --git a/openlp/plugins/audit/lib/__init__.py b/openlp/plugins/audit/lib/__init__.py index 784a92abb..b7501b377 100644 --- a/openlp/plugins/audit/lib/__init__.py +++ b/openlp/plugins/audit/lib/__init__.py @@ -21,9 +21,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -import sys -try: - from audittab import AuditTab - from manager import AuditManager -except: - print sys.exc_info() + +from audittab import AuditTab +from manager import AuditManager diff --git a/openlp/plugins/audit/lib/tables.py b/openlp/plugins/audit/lib/tables.py index b3898d5e8..9d7eb1551 100644 --- a/openlp/plugins/audit/lib/tables.py +++ b/openlp/plugins/audit/lib/tables.py @@ -32,6 +32,6 @@ audit_table = Table(u'audit_data', metadata, 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.UnicodeText, nullable=False), + Column(u'authors', types.Unicode(255), nullable=False), Column(u'ccl_id', types.Unicode(65), nullable=False) )