def create_db(): response.subtitle = T("Database Creation") response.view = 'nas/index.html' alias = db( (db.databases.deleted == False)).select(db.databases.id, db.databases.alias, orderby=db.databases.alias) cmb_alias = SELECT( *[OPTION(field["alias"], _value=field["alias"]) for field in alias], _id="cmb_alias", _style="margin-top: 0px;") if len(cmb_alias) == 0: cmb_alias.insert(0, OPTION("", _value="")) gform = DIV( HR(), P(SPAN(T('1. Create a new database alias. See ')), A("Customer Databases", _href=URL("databases"), _style="color:#0069D6;font-style: italic;"), BR(), SPAN( T('2. The sqlite and Google SQL databases are created automatically.' )), BR(), SPAN( T('3. Other types of databases must be created manually before.') ), BR(), SPAN(T('4. Please select an alias, and start the creation:')), _style="font-style: italic;"), DIV( SPAN(T('Database alias:'), _style="padding-right: 15px;padding-left: 15px;"), cmb_alias, P(SPAN(T('Starting the process?'), _id="msg_result", _style="font-style: italic;"), ui.control.get_mobil_button(label=T("Start"), href="#", onclick="createDatabase();", cformat=None, icon="check", theme="b", style="width: 100px;"), _style="padding-top: 0px;")), HR(), _style="font-weight: bold;", _align="left") return dict(form=gform)
def test_HR(self): self.assertEqual(HR(_a='1', _b='2').xml(), b'<hr a="1" b="2" />')
def restore_backup(): response.subtitle = T("Restore the Customer Data") response.view = 'nas/index.html' msg_result = T('Starting the process?') if request.post_vars: if request.post_vars.alias == None or request.post_vars.alias == "": msg_result = T("Error: Missing alias parameter!") if request.post_vars.has_key("frm_file"): if request.post_vars.bfile == "": msg_result = T("Error: Missing upload file!") else: msg_result = dbtool.loadBackupData( alias=request.vars.alias, bfile=request.post_vars.bfile) else: if request.post_vars.filename == "": msg_result = T("Error: Missing upload filename!") else: msg_result = dbtool.loadBackupData( alias=request.vars.alias, filename=request.post_vars.filename) request.post_vars = None alias = db( (db.databases.deleted == False)).select(db.databases.id, db.databases.alias, orderby=db.databases.alias) cmb_alias = SELECT( *[OPTION(field["alias"], _value=field["alias"]) for field in alias], _name="alias", _id="cmb_alias") if len(cmb_alias) == 0: cmb_alias.insert(0, OPTION("", _value="")) dfiles = os.listdir(os.path.join(ns.request.folder, 'static/backup')) files = [] for dfile in dfiles: if str(dfile).endswith(".backup") or str(dfile).endswith(".xml"): files.append(dfile) files.sort() cmb_files = SELECT(*files, _id="cmb_files", _name="filename") if len(cmb_files) == 0: cmb_files.insert(0, OPTION("", _value="")) cmd_filename = INPUT( _type="submit", _name="frm_filename", _title=ns.T('Start restore from local backup file'), _value=T("Start restore"), _onclick="msg_result.innerHTML='" + T("Process started. Waiting for the server to respond ...") + "';") cmd_filename["_data-theme"] = "b" cmd_filename["_data-icon"] = "check" cmd_file = INPUT( _type="submit", _name="frm_file", _title=ns.T('Upload file and Start restore'), _value=T("Upload and Start restore"), _onclick="msg_result.innerHTML='" + T("Process started. Waiting for the server to respond ...") + "';") cmd_file["_data-theme"] = "b" cmd_file["_data-icon"] = "check" cmd_file["_data-ajax"] = "false" if request.env.web2py_runtime_gae: gform = DIV( HR(), P( SPAN( T('The sqlite and Google SQL databases are created automatically. Other types of databases must be created manually before.' ))), FORM(DIV( SPAN(T('Database alias:'), _style="padding-right: 15px;padding-left: 15px;"), cmb_alias), DIV(SPAN(T('File:'), _style="padding-right: 15px;padding-left: 15px;"), INPUT(_type='file', _name='bfile', _id='bfile', _requires=IS_NOT_EMPTY()), SPAN("", _style="padding-left: 15px;"), cmd_file, _style="padding-top: 8px;"), _id="frm_upload_files", _name="frm_upload", **{"_data-ajax": "false"}), P( SPAN(msg_result, _id="msg_result", _style= "padding-left: 15px;font-style: italic;padding-top: 5px;") ), HR(), _style="font-weight: bold;", _align="left") else: gform = DIV( HR(), P( SPAN( T('The sqlite and Google SQL databases are created automatically. Other types of databases must be created manually before.' ))), FORM(DIV( SPAN(T('Database alias:'), _style="padding-right: 15px;padding-left: 15px;"), cmb_alias), DIV(SPAN(T('Filename:'), _style="padding-right: 15px;padding-left: 15px;"), cmb_files, SPAN("", _style="padding-left: 15px;"), cmd_filename, _style="padding-top: 8px;"), DIV(SPAN(T('File:'), _style="padding-right: 15px;padding-left: 15px;"), INPUT(_type='file', _name='bfile', _id='bfile', _requires=IS_NOT_EMPTY()), SPAN("", _style="padding-left: 15px;"), cmd_file, _style="padding-top: 8px;"), _id="frm_upload_files", _name="frm_upload", **{"_data-ajax": "false"}), P( SPAN(msg_result, _id="msg_result", _style= "padding-left: 15px;font-style: italic;padding-top: 5px;") ), HR(), _style="font-weight: bold;", _align="left") return dict(form=gform)
def create_backup(): response.subtitle = T("Create a Backup") response.view = 'nas/index.html' alias = db( (db.databases.deleted == False)).select(db.databases.id, db.databases.alias, orderby=db.databases.alias) cmb_alias = SELECT( *[OPTION(field["alias"], _value=field["alias"]) for field in alias], _id="cmb_alias") if len(cmb_alias) == 0: cmb_alias.insert(0, OPTION("", _value="")) cmb_format = SELECT( [OPTION(T("backup"), _value="backup"), OPTION(T("XML"), _value="xml")], _id="cmb_format") if len(cmb_format) == 0: cmb_format.insert(0, OPTION("", _value="")) cmb_filename = SELECT([ OPTION(T("Alias"), _value=""), OPTION(T("Download"), _value="download"), OPTION(T("Custom"), _value="custom") ], _id="cmb_filename") if request.env.web2py_runtime_gae: cmb_filename = SELECT([OPTION(T("Download"), _value="download")], _id="cmb_filename") cust_filename = "" else: cust_filename = INPUT(_type="text", _value="", _id="cust_filename") gform = DIV( HR(), P( SPAN(T('Nervatura backup: '), _style="color:brown;"), BR(), SPAN(T('NOM objects: '), _style="color:green;"), SPAN( "address, barcode, contact, currency, customer, deffield, employee, event, fieldvalue, groups, item, link, \ log, movement, numberdef, pattern, payment, place, price, product, project, rate, tax, tool, trans" ), BR(), SPAN(T('Settings objects: '), _style="color:green;"), SPAN("ui_audit, ui_language, \ ui_menu, ui_menufields, ui_message, ui_report, ui_reportfields, \ ui_reportsources, ui_userconfig"), BR(), SPAN(T('Not included: '), _style="color:red;"), SPAN("ui_printqueue"), BR(), BR(), SPAN(T( "Independent from the database type and version of the NAS server." ), _style="font-style: italic;")), DIV( DIV( SPAN(T('Database alias:'), _style="padding-right: 15px;padding-left: 15px;"), cmb_alias), DIV(SPAN(T('Filename:'), _style="padding-right: 15px;padding-left: 15px;"), cmb_filename, SPAN(" "), cust_filename, _style="padding-top: 10px;"), DIV(SPAN(T('Backup format:'), _style="padding-right: 15px;padding-left: 15px;"), cmb_format, _style="padding-top: 10px;"), P(SPAN(T('Starting the process?'), _id="msg_result", _style="font-style: italic;"), ui.control.get_mobil_button( label=T("Start"), href="#", onclick="createDataBackup();", cformat=None, icon="check", theme="b", style="width: 100px;", title=ns.T('Start customer backup creation')), _style="padding-top: 5px;")), HR(), _style="font-weight: bold;", _align="left") return dict(form=gform)