def pageInit(subHeading=None, formJS=0): table_data = declarations.define_tables() print "<HTML>" print "<HEAD>" if formJS: pmt_utils.generate_form_javascript(table_data, 'inventory', 'inv_admin', 0) else: pmt_utils.javaScript("inv_admin") pmt_utils.title("Inventory") print "</HEAD>" pmt_utils.bodySetup() pmt_utils.mainHeading('Inventory') if subHeading != None: pmt_utils.subHeading(subHeading) pmt_utils.formSetup("inv_admin", declarations.pmt_info['db_name'], "inv_admin", "return submitForm(document.inv_admin)") dbResult = pmt_utils.connectDB(declarations.pmt_info['browser_username'], declarations.pmt_info['browser_password'], declarations.pmt_info['db_name']) if dbResult['status'] != 'success': db = None status = dbResult['message'] else: db = dbResult['result'] status = 'success' return status, table_data, db
def displayLogin(form,alert=None): print "<HTML>" print "<HEAD>" pmt_utils.javaScript("cvsweb") pmt_utils.title("Development Library") print "</HEAD>" pmt_utils.bodySetup() pmt_utils.mainHeading('Development Library') pmt_utils.subHeading('Login') pmt_utils.formSetup("cvsweb", db_name, "cvsweb", "return submitForm(document.cvsweb)") pmt_utils.usernamePasswordDisplay() if alert!=None: pmt_utils.alertsArea(form, alert) print "<hr><INPUT TYPE='submit' NAME='submit' value='Submit' >"
def displayLogin(alert=None): print "<HTML>" print "<HEAD>" pmt_utils.javaScript("upload") pmt_utils.title("Upload") print "</HEAD>" pmt_utils.bodySetup() pmt_utils.mainHeading('Upload') pmt_utils.subHeading('Login') pmt_utils.formSetup("upload",declarations.pmt_info['db_name'], "upload","return submitForm(document.upload)") pmt_utils.usernamePasswordDisplay() if alert!=None: pmt_utils.alertsArea(form,alert) print "<hr><INPUT TYPE='submit' NAME='submit' value='Submit' >" if form.has_key('dest'): print '<INPUT TYPE=hidden NAME=dest value="%s">' % form['dest'].value
def displayLogin(form, alert=None): print "<HTML>" print "<HEAD>" pmt_utils.javaScript("list_docs") pmt_utils.title("Data Item Listing") print "</HEAD>" pmt_utils.bodySetup() pmt_utils.mainHeading('Data Item Listing') pmt_utils.subHeading('Login') java = "return submitForm(document.list_docs)" pmt_utils.formSetup("list_docs", db_name, "list_docs", java) pmt_utils.usernamePasswordDisplay() if alert != None: pmt_utils.alertsArea(form, alert) print "<hr><INPUT TYPE='submit' NAME='submit' value='Submit' >" if form.has_key('directory'): if string.find(form['directory'].value, '..') >= 0: sys.exit() print "<INPUT TYPE='hidden' NAME='directory' " print "value='%s'>" % form['directory'].value
def display_form(display_files=0,alerts=None): print "<HTML>" print "<HEAD>" pmt_utils.javaScript("doc_maintenance") pmt_utils.title("Documentation Maintenance") print "</HEAD>" pmt_utils.bodySetup() pmt_utils.mainHeading('Documentation Maintenance') pmt_utils.subHeading('Create and Delete Folders/Files') pmt_utils.formSetup("doc_maintenance",db_name,"doc_maintenance",None) dbResult=pmt_utils.connectDB(declarations.pmt_info['browser_username'], declarations.pmt_info['browser_password'], declarations.pmt_info['db_name']) if dbResult['status']!='success': exit(dbResult['message']) db=dbResult['result'] status,details = db_authentication.password_valid(db, crypt_salt=db_name, username=username, password=password) if status!='success': exit(details) if not pmt_utils.hasPriv(db,username,'folder_admin'): msg="User %s does not have folder maintenance priviledges" % username exit(msg) print '<hr><br><CENTER><B>Delete Folders/Files</B></CENTER>' stripped_db=string.lower(string.strip(db_name)) os.chdir(os.path.join('/home',stripped_db,'documents')) file_list = os_utils.walk_list_files( directory_name='.', list_only_files=0, exclude_list = [], include_file_type=1) if len(file_list) > 25: list_size = 25 else: list_size = len(file_list) print '<BLINK><B>WARNING:</B></BLINK><br>' print 'Any folders or files that you select for deletion are ' print 'permanently deleted. You should have a local backup of ' print 'any folders/files you delete in case you really did not mean ' print 'to delete. Backups are crucial. You have been warned.' print '<p>Selecting a folder will delete the folder and all files ' print 'under it including sub folders. ' print 'Select folder names with caution.' print '<p>Your deletes will not be confirmed. ' print 'When you press [Delete Folders/Files] your files are deleted.' print '<BR><CENTER><B>Select folders/files to delete</B>:<BR>' print '<SELECT NAME="files_to_remove" SIZE="8" MULTIPLE>' for curfile in file_list: print '<OPTION>%s' % (curfile) print "</SELECT><br>" java_call="return execute('delete_folder','1')" print '<input name="delete_folder" type="button" ' print 'value=" Delete Folders/Files " onClick="%s">' % java_call print '<input name ="website_name_hidden" ' print 'type="hidden" value="%s">' % (db_name) print "<hr><BR><BR>" print '<CENTER><B>Create Folder</B></CENTER><BR>' print '<B>Folder Name</B>: ' print '<input name="folder" type="text" size="50" maxlength="100"><BR>' java_call="return execute('create','1')" print '<input name="create" type="button" ' print 'value=" Create Folder " onClick="%s">' % java_call print '<input name ="website_name_hidden" ' print 'type="hidden" value="%s"><hr>' % (db_name) if alerts != None: pmt_utils.alertsArea(form,alerts) print '</CENTER>' pmt_utils.textbox(None, 'action', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'key_id', '1', '10', '10', None, None,'hidden') print '</form>' print '<p align="right">' print '<A HREF="mailto:[email protected]">Contact Support Team</a>' print "</body></html>"
def edit_project_info(performDbQuery=0, onLoad=None, queryFields=None): table_data = declarations.define_tables() print "<HTML>" print "<HEAD>" pmt_utils.javaScript("project_admin") pmt_utils.title("Project Administration") print "</HEAD>" pmt_utils.bodySetup(onLoad) pmt_utils.mainHeading('Project Administration') pmt_utils.subHeading('Project Info') pmt_utils.formSetup("project_admin", db_name, "project_admin", "return submitForm(document.project_admin)") if username == None: pmt_utils.usernamePasswordDisplay() project_adminButtons(button_name='edit') pmt_utils.textbox(None, 'key_id', '1', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'action', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'item_no', '', '8', '8', None, None, 'hidden') print "</FORM>" try: pmt_utils.trailer(table_data, db) db.close() except NameError: pass print "</BODY>" print "</HTML>" return dbResult = pmt_utils.connectDB(declarations.pmt_info['browser_username'], declarations.pmt_info['browser_password'], declarations.pmt_info['db_name']) # could not connect to db if dbResult['status'] != 'success': pmt_utils.alertsArea( form, "Can not connect to database,\n" + dbResult['message']) project_adminButtons() print "</FORM>" try: pmt_utils.trailer(table_data, db) db.close() except NameError: pass print "</BODY>" print "</HTML>" return db = dbResult['result'] status, details = db_authentication.password_valid(db, crypt_salt=db_name, username=username, password=password) if status != 'success': print '<form method=post action=/%s-cgi-bin/project_admin.pyc>' % db_name pmt_utils.usernamePasswordDisplay(username) pmt_utils.alertsArea(form, 'Can not verify you as a valid user') print '<hr><input name=reload type=submit value="Query">' print '<input name=action value=edit type=hidden>' print '</form>' sys.exit() if pmt_utils.hasPriv(db, username, 'project_data') != 1: print '<form method=post action=/%s-cgi-bin/project_admin.pyc>' % db_name pmt_utils.usernamePasswordDisplay(username) msg = 'User %s does not have project admin privileges>' % username pmt_utils.alertsArea(form, msg) print '<hr><input name=reload type=submit value="Query">' print '<input name=action value=edit type=hidden>' print '</form>' sys.exit() if form.has_key('key_id'): key_id = form['key_id'].value else: key_id = '1' sqlStatement = pmt_utils.selectAllColumnsSqlStatement( table_data, 'project_info', key_id) dbResult = pmt_utils.executeSQL(db, sqlStatement) if dbResult['status'] != 'success': msg = "Could not retrieve project information\n" + dbResult['message'] pmt_utils.alertsArea(form, msg) else: result = dbResult['result'] table_data = pmt_utils.dbToTableData(table_data, 'project_info', result[0]) table_data['project_info']['id']['value'] = '1' pmt_utils.display_form(table_data, 'project_info', 1, 'useValues', 1, db) pmt_utils.alertsArea(form, "Project Information retrieved successfully") project_adminButtons(button_name='save') pmt_utils.textbox(None, 'key_id', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'action', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'item_no', '', '8', '8', None, None, 'hidden') print "</FORM>" try: pmt_utils.trailer(table_data, db) db.close() except NameError: pass print "</BODY>" print "</HTML>"