efd5bd72e0688b1b989542f8e287b1b0063ee590
1 # BiaWeb Website content manager (c) 2010 V.Harishankar
2 # Templates dialog class
5 import ui_templates_dialog
9 class TemplatesDialog (PyQt4
.QtGui
.QDialog
, ui_templates_dialog
.Ui_TemplatesDialog
):
10 def __init__ (self
, master
, currentdb
):
11 PyQt4
.QtGui
.QDialog
.__init
__ (self
, master
)
14 # set the current database
15 self
.current_db
= currentdb
17 # populate the templates
18 tpls
= biaweb_db
.get_templates (self
.current_db
)
19 for tpl_name
, tpl_content
in tpls
:
20 self
.templates
.addItem (str (tpl_name
))
23 # get the currently selected list item
24 tpl_name
= self
.templates
.currentItem ().data (0).toString ()
26 # get the template content from the database
27 tpl_str
= biaweb_db
.get_template_text (self
.current_db
, str (tpl_name
))
29 # if template string cannot be obtained for some reason
31 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Error", "SQLite 3 error in retrieving template")
33 # open edit dialog with title "template name" and text as the template string
34 edlg
= editor_dialog
.EditorDialog (self
, tpl_name
, tpl_str
)