# Main Window class
import PyQt4
+import sys
+
import ui_main_window
import site_configuration_dialog as scd
import category_dialog as catd
import article_dialog as artd
+import templates_dialog as tpld
import biaweb_db
-import sys
class MainWindow (PyQt4.QtGui.QMainWindow, ui_main_window.Ui_MainWindow):
def __init__ (self):
# refresh the category list
def repopulate_categories (self):
recs = biaweb_db.get_categories (self.current_db)
- if not recs:
+
+ # check with False because None is returned when no records exist
+ if recs == False:
PyQt4.QtGui.QMessageBox.critical (self, "Error", "SQLite 3 error in getting the categories")
return
# refresh the articles list
def repopulate_articles (self, catid=None):
recs = biaweb_db.get_articles (self.current_db, catid)
- if not recs:
+
+ # check with False because None is returned when no records exist
+ if recs == False:
PyQt4.QtGui.QMessageBox.critical (self, "Error", "SQLite 3 error in getting the articles")
return
catid = self.get_selected_item_id (self.categories)
self.repopulate_articles (catid)
- # when configuration menu is activated
+ # when configuration menu is triggered
def onConfiguration (self):
if self.current_db is None:
PyQt4.QtGui.QMessageBox.critical (self, "Error",
PyQt4.QtGui.QMessageBox.critical (self, "Error",
"SQLite 3 error in updating configuration")
+ # when templates menu is triggered
+ def onTemplates (self):
+ if self.current_db is None:
+ PyQt4.QtGui.QMessageBox.critical (self, "Error",
+ "Cannot edit templates. You need to create or open a website first")
+ else:
+ tdlg = tpld.TemplatesDialog (self, self.current_db)
+ tdlg.exec_ ()
+
# function to get the category or article ID from current selected item in a tree widget
def get_selected_item_id (self, twidget):
selitems = twidget.selectedItems ()