Exemple #1
0
def showForm():

    print '<center><h2>Add new link:</h2>'
    print '<form method=post action=/%s-cgi-bin/addlink.pyc>' % db_name
    print '<input type=hidden name=dest value=%s>' % form['dest'].value
    print '<TABLE BORDER=0>'

    # display the name of the data item
    print "<TR><TD><B>Data Item Name</B>:</TD><TD>"
    pmt_utils.textbox(None, 'name', '', '30', '40', None, None)
    print "</TD></TR>"

    # display date entered and href of target
    print "<TR><TD><B>Target</B>:</TD><TD>"
    pmt_utils.textbox(None, 'target', '', '30', '256', None, None)
    print "</TD></TR>"

    # display the description field
    print "<TR><TD><B>Description:</B></TD><TD>"
    pmt_utils.textarea(None, 'description', '', '5', '25', None, None)
    print '</TABLE>'
    print '<input name="submit" type="submit" value="Add Link">'
    print '<input name="Close Window" type="button" ' + \
          'value="Close Window" onClick=self.close()'
    print '</form>'
Exemple #2
0
def editDetails(filepath, filename):

    # get the current data if it exists
    html_filename = form['filename'].value

    # if the filename has more than 1 period in it replace them with _
    if string.count(html_filename, ".") > 1:
        html_filename = string.replace(html_filename, ".", "_")
    if os.path.exists(filepath + '/' + html_filename + '.html'):
        details = getDetailsFromFile(filepath + '/' + html_filename + '.html',
                                     form['filename'].value)
    else:
        details = getDetailsFromFile()
        theTime = time.localtime(os.stat(filename)[stat.ST_MTIME])
        details['date'] = time.strftime('%m/%d/%y', theTime)

    print '<center><h2>Edit details of file %s</h2>' % form['filename'].value

    print '<P><form action="/%s-cgi-bin/edit.pyc" method="POST" ' % (db_name)
    print 'enctype="multipart/form-data">'
    print '<TABLE BORDER=0>'

    # display the name of the data item
    print "<TR><TD><B>Data Item Name</B>:</TD><TD>"
    pmt_utils.textbox(None, 'name', details['name'], '30', '40', None, None)
    print "</TD></TR>"

    # display date entered and filename
    print "<TR><TD><B>Date Entered</B>:</TD><TD>%s" % details['date']
    print '<input name=date type=hidden value="%s">' % (details['date'])
    print "</TD></TR>"
    print "<TR><TD><B>Filename</B>:</TD><TD>%s" % form['filename'].value
    print '<input name=filename type=hidden value="%s">' % (
        form['filename'].value)
    print "</TD></TR>"

    # display the version field
    print "<TR><TD><B>Version:</B></TD><TD>"
    pmt_utils.textbox(None, 'version', details['version'], '30', '40', None,
                      None)
    print "</TD></TR>"

    # display the description field
    print "<TR><TD><B>Description:</B></TD><TD>"
    pmt_utils.textarea(None, 'description', details['description'], '5', '25',
                       None, None)
    print '</TABLE>'

    print '<input name=filepath type=hidden value=%s>' % (filepath)

    print '<input name="submit" type="submit" value="Save">'
    print '<input name="Close Window" type="button" value="Close Window"'
    print 'onClick=self.close()'
    print '</form>'
Exemple #3
0
def linkDetails():
    name = href = date = description = None

    if os.path.exists(form['file'].value):
        bookmarks = open(form['file'].value, 'r')
    else:
        sys.exit()

    lines = bookmarks.readlines()
    for line in lines:
        words = string.split(line)
        if words[0] == form['link'].value:
            name = words[2]
            i = 3
            while words[i] != '|':
                name = name + ' ' + words[i]
                i = i + 1
            href = words[i + 1]
            date = words[i + 3]
            description = string.join(words[i + 5:], ' ')

    bookmarks.close()

    print '<center><h2>Edit details of link %s</h2>' % name

    print '<P><form action="/%s-cgi-bin/edit.pyc" method="POST" ' % (db_name)
    print 'enctype="multipart/form-data">'
    print '<TABLE BORDER=0>'

    # display the name of the data item
    print "<TR><TD><B>Link Name</B>:</TD><TD>"
    pmt_utils.textbox(None, 'name', name, '30', '40', None, None)
    print "</TD></TR>"

    # display date entered and href of target
    print "<TR><TD><B>Date Entered</B>:</TD><TD>%s" % date
    print '<input name=date type=hidden value="%s">' % date
    print "</TD></TR>"
    print "<TR><TD><B>Target</B>:</TD><TD>"
    pmt_utils.textbox(None, 'target', href, '30', '256', None, None)
    print "</TD></TR>"

    # display the description field
    print "<TR><TD><B>Description:</B></TD><TD>"
    pmt_utils.textarea(None, 'description', description, '5', '25', None, None)
    print '</TABLE>'

    print '<input name="file" type="hidden" value="%s">' % form['file'].value
    print '<input name="link" type="hidden" value="%s">' % form['link'].value
    print '<input name="submit" type="submit" value="Save">'
    print '<input name="Close Window" type="button" value="Close Window"'
    print ' onClick=self.close()>'
    print '</form>'
Exemple #4
0
def doCreate():
    status, table_data, db = pageInit('Create', formJS=1)
    if status != 'success':
        message = "Could not connect to db,\n" + dbResult['message']
        exit(message)
    status, details = db_authentication.password_valid(db,
                                                       crypt_salt=db_name,
                                                       username=username,
                                                       password=password)

    if status != 'success':
        exit(details)

    display_questionnaire(db, table_data, 'edit')
    message = "Enter information on form and depress Create button"
    pmt_utils.alertsArea(form, message)

    listing_url = '/%s-cgi-bin/inv_admin.pyc?performDbQuery=1' % (db_name)
    help_url = '/%s/html/sprsum.html' % db_name
    pmt_utils.createFunctionButtons('create', listing_url, help_url)

    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')

    po_id = table_data['inventory']['po_id']['value']
    print '<input type=hidden name=po_id value="%s">' % po_id
    val = table_data['inventory']['prop_id_assigned_by_signature']['value']
    pmt_utils.textbox(None, 'prop_id_assigned_by_signature', val, '40', '40',
                      None, None, 'hidden')
    pageEnd(table_data, db)
Exemple #5
0
def doEdit():

    status, table_data, db = pageInit("Edit", formJS=1)

    if status != 'success':
        message = "Could not connect to the database.\n" + status
        exit(message)

    status, details = db_authentication.password_valid(db,
                                                       crypt_salt=db_name,
                                                       username=username,
                                                       password=password)

    if status != 'success':
        exit(details)

    sqlStatement = pmt_utils.selectAllColumnsSqlStatement(
        table_data, 'inventory', form["key_id"].value)
    dbResult = pmt_utils.executeSQL(db, sqlStatement)

    if dbResult['status'] != 'success':
        message = "Could not retrieve item to edit.\n" + dbResult['message']
        exit(message)

    result = dbResult['result']
    table_data = pmt_utils.dbToTableData(table_data, 'inventory', result[0])
    display_questionnaire(db, table_data, 'edit')
    pmt_utils.alertsArea(form, "Item data retrieved successfully")

    pmt_utils.textbox(
        None, 'prop_id_assigned_by_signature',
        table_data['inventory']['prop_id_assigned_by_signature']['value'],
        '40', '40', None, None, 'hidden')

    listing_url = '/%s-cgi-bin/inv_admin.pyc?performDbQuery=1' % (db_name)
    help_url = '/%s/html/sprsum.html' % (db_name)
    po_id = table_data['inventory']['po_id']['value']
    print '<input type=hidden name=po_id value="%s">' % po_id

    if form.has_key("return_to_po"):
        print '<input type=hidden name=return_to_po value=1>'
        java = "return goto_url('/%s-cgi-bin/po_admin.pyc?action=edit&key_id=%s')" % (
            db_name, table_data['inventory']['po_id']['value'])
        html = '<INPUT NAME="edit" type="button" value=" Return to PO " onClick="%s">' % java
        print '<BR><BR>'
        print html

    editFunctionButtons(form["key_id"].value, listing_url, help_url)
    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')

    pageEnd(table_data, db)
Exemple #6
0
def exit(message,table_data=None,db=None,display_login=1):

    if display_login:
        pmt_utils.usernamePasswordDisplay(username)
    pmt_utils.alertsArea(form, message);

    create_priv=0

    #url='/%s/html/sprsum.html' % db_name
    #pmt_utils.queryFunctionButtons(create_priv, url)
    print '<HR>'
    print '<TABLE><TR>'
    java="return goto_url ('doc_maintenance.pyc')"
    html='<INPUT TYPE="button" NAME="return_to_menu" VALUE=" Listing " '
    html=html+'onClick="%s">' % java
    pmt_utils.tableColumn(html)
    print '</TR></TABLE>'

    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')
    
    if table_data!=None and db!=None:
        pageEnd(table_data,db)
    sys.exit()
Exemple #7
0
def exit(message):
    pmt_utils.usernamePasswordDisplay()
    pmt_utils.alertsArea(form, message)
    queryFunctionButtons(0, '/%s/html/contactsum.html' % (db_name))
    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')
    sys.exit()
Exemple #8
0
def query_project_members(performDbQuery=0,onLoad=None,queryFields=None):

    status,table_data,db=pageInit('Members',formJS=0)
    if status != 'success':
        message='Could not connect to database.\n%s' % status
        exit(message)

    status, details = db_authentication.password_valid(db,
                                                       crypt_salt=db_name,
                                                       username=username,
                                                       password=password)
    if status != 'success':
        exit(details)

    # Check for user admin privileges
    if pmt_utils.hasPriv(db, username,'user_admin')!=1:
        message='User %s does not have user admin privileges.' % username
        exit(message)

    queryFields,whereFields=pmt_utils.getQueryWhereFields(form,
                                                          table_data,
                                                          'project_members')

    if queryFields == None or queryFields == []:
        queryFields = []
        whereFields = None
        queryFields.append('first_name')
        queryFields.append('last_name')
        queryFields.append('phone_number_voice')

    dbResult,queryStatement=pmt_utils.executeQuery(db,
                                                   table_data,
                                                   'project_members',
                                                   queryFields,
                                                   whereFields,
                                                   'query',
                                                   queryItemFunctionsHtml,
                                                   'ORDER by last_name',
                                                   ['id'],
                                                   None,None,
                                                   "return execute('query')",
                                                   ["",""])
    if dbResult['status'] != 'success':
        message="Could not get member data from db.\n%s" % dbResult['message']
        exit(message)
    msg="Last Query Statement: %s\n" % queryStatement
    msg=msg+"%s project members retrieved from db" % `len(dbResult['result'])`
    pmt_utils.alertsArea(form,msg)

    # Add buttons and hidden fields
    help_url='/%s/html/contactsum.html' % db_name
    pmt_utils.queryFunctionButtons(1,help_url)

    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')
    
    pageEnd(table_data,db)
Exemple #9
0
def doSave():
    saveDueToCreate = 0
    status, table_data, db = pageInit('Save', formJS=1)

    if status != 'success':
        message = "Could not connect to db.\n" + status
        exit(message)

    status, details = db_authentication.password_valid(db,
                                                       crypt_salt=db_name,
                                                       username=username,
                                                       password=password)

    if status != 'success':
        exit(details)

    if form["key_id"].value == 'create':
        saveDueToCreate = 1
        queryResult = pmt_utils.executeSQL(db, "SELECT NEXTVAL('pai_id_seq')")

        form["key_id"].value = ` queryResult['result'][0]['nextval'] `

    dbResult = pmt_utils.saveForm(table_data, db, form['key_id'].value, "pai",
                                  " WHERE id = '%s'" % form["key_id"].value,
                                  form)

    if dbResult['status'] != 'success':
        message = "Action item could not be saved.\n" + dbResult['message']
        exit(message)

    if saveDueToCreate:
        subject = 'New PAI #%s has been generated' % (form['key_id'].value)
        msg = "PAI #%s has been generated.\n\n" % form["key_id"].value
        msg = msg + "Assigned to: %s\n" % form['assigned_to'].value
        msg = msg + "Problem Description:\n%s" % form['action_required'].value
        msg = msg + "\n\nLog into the Project Action Item tracking tool at "
        msg = msg + "http://www.isrparc.org for further info.\n\n"
        msg = msg + "If you do not wish to be on this mailing list please "
        msg = msg + "send an email requesting removal to [email protected].\n"
        pmt_utils.emailList(db, 'localhost', 'pai_list', subject, msg)

    table_data = pmt_utils.formToTableData(table_data, 'pai', form,
                                           form['key_id'].value)

    pmt_utils.display_form(table_data, 'pai', 1, 'useValues', 1, db)
    pmt_utils.alertsArea(form, "Action item successfully saved")

    # generate function button row
    listing_url = '/%s-cgi-bin/pai_admin.pyc?performDbQuery=1' % (db_name)
    help_url = '/%s/html/paisum.html' % (db_name)
    editFunctionButtons(form["key_id"].value, listing_url, help_url)

    # generate hidden fields for form
    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')

    pageEnd(table_data, db)
Exemple #10
0
def query_project_members(performDbQuery=0, onLoad=None, queryFields=None):

    status, table_data, db = pageInit('Members', formJS=0)

    if username == None:
        message = "Unable to identify user."
        exit(message)

    if status != 'success':
        message = "Can not connect to database.\n" + dbResult['message']
        exit(message)

    status, details = db_authentication.password_valid(db,
                                                       crypt_salt=db_name,
                                                       username=username,
                                                       password=password)

    if status != 'success':
        exit(details)

    queryFields, whereFields = pmt_utils.getQueryWhereFields(
        form, table_data, 'project_members')

    if queryFields == None or queryFields == []:
        queryFields = []
        whereFields = None
        queryFields.append('first_name')
        queryFields.append('last_name')
        queryFields.append('email')
        queryFields.append('phone_number_voice')
        queryFields.append('phone_extension')

    dbResult, queryStatement = pmt_utils.executeQuery(
        db, table_data, 'project_members', queryFields, whereFields, 'query',
        queryItemFunctionsHtml, 'ORDER by last_name',
        ['id', 'member_username'], None, ['member_password'],
        "return execute('query')", [username])

    if dbResult['status'] != 'success':
        message = "Couldn't get user data from db.\n" + dbResult['message']
        exit(message)

    pmt_utils.alertsArea(form,
                         "Last Query Statement: "+queryStatement+\
                         "\n" + `len(dbResult['result'])` +\
                         " project members retrieved from db")

    queryFunctionButtons(1, '/%s/html/contactsum.html' % (db_name))

    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')

    pageEnd(table_data, db)
Exemple #11
0
def doEdit():

    status,table_data,db = pageInit('Edit',formJS=1)
    
    if status!='success':
        message="Could not connect to db.\n%s" % status
        exit(message)
        
    status, details = db_authentication.password_valid(db,
                                                       crypt_salt=db_name,
                                                       username=username,
                                                       password=password)

    if status != 'success':
        exit(details)

    sqlStatement = pmt_utils.selectAllColumnsSqlStatement(table_data,
							  'project_members',
							  form["key_id"].value)
    dbResult = pmt_utils.executeSQL(db, sqlStatement)

    if dbResult['status'] != 'success':
        message="Could not get project member data.\n%s" % dbResult['message']
        exit(message)

    result = dbResult['result']
    table_data=pmt_utils.dbToTableData(table_data,'project_members',result[0])
    pmt_utils.display_form(table_data,'project_members', 1,'useValues', 1, db)

    # get user privileges and display them
    sqlStatement = "select * from priviledges where " +\
                   "member_username='******'" % (result[0]['member_username'])
    dbResult = pmt_utils.executeSQL(db, sqlStatement)
    if dbResult['status'] != 'success':
        message="Could not get privileges from db.\n%s" % dbResult['message']
        exit(message,table_data,db)

    result = dbResult['result']
    table_data = pmt_utils.dbToTableData(table_data,'priviledges', result[0])
    displayPriviledges(result[0], table_data)
    pmt_utils.alertsArea(form,"Project member data retrieved successfully")

    listing_url= '/%s-cgi-bin/project_members_admin.pyc?performDbQuery=1' % (db_name)
    help_url='/%s/html/contactsum.html' % db_name
    pmt_utils.editFunctionButtons(form["key_id"].value,listing_url,help_url)
    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')
    
    pageEnd(table_data,db)
Exemple #12
0
def doSave():

    status, table_data, db = pageInit('Save', formJS=0)

    if status != 'success':
        message = "Could not connect to db.\n" + status
        exit(message)

    status, details = db_authentication.password_valid(db,
                                                       crypt_salt=db_name,
                                                       username=username,
                                                       password=password)

    if status != 'success':
        exit(details)

    # save the Form
    dbResult = pmt_utils.saveForm(table_data, db, form['key_id'].value,
                                  "project_members",
                                  " WHERE id = '%s'" % form["key_id"].value,
                                  form)

    if dbResult['status'] != 'success':
        message = "Save error.\n" + dbResult['message']
        exit(message)

    table_data = pmt_utils.formToTableData(table_data, 'project_members', form,
                                           form['key_id'].value)

    table_data['project_members']['member_username']['display'] = 'read-only'
    table_data['project_members']['member_role']['display'] = 'read-only'
    table_data['project_members']['member_password']['display'] = 'Hidden'

    pmt_utils.display_form(table_data, 'project_members', 1, 'useValues', 1,
                           db)

    pmt_utils.alertsArea(form, "Member data successfully saved")

    # generate function button row
    listing_url = '/%s-cgi-bin/contact_list.pyc?performDbQuery=1' % db_name
    help_url = '/%s/html/contactsum.html' % (db_name)
    editFunctionButtons(form["key_id"].value, listing_url, help_url)

    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')

    pageEnd(table_data, db)
Exemple #13
0
def doEdit():
    status, table_data, db = pageInit('Edit', formJS=0)

    if status != 'success':
        message = "Could not connect to db.\n%s" % status
        exit(message)

    status, details = db_authentication.password_valid(db,
                                                       crypt_salt=db_name,
                                                       username=username,
                                                       password=password)

    if status != 'success':
        exit(details)

    sqlStatement = pmt_utils.selectAllColumnsSqlStatement(
        table_data, 'project_members', form["key_id"].value)
    dbResult = pmt_utils.executeSQL(db, sqlStatement)

    if dbResult['status'] != 'success':
        message = "Unable to get member data from db.\n" + dbResult['message']
        exit(message)

    result = dbResult['result']

    table_data = pmt_utils.dbToTableData(table_data, 'project_members',
                                         result[0])

    table_data['project_members']['member_username']['display'] = 'read-only'
    table_data['project_members']['member_password']['display'] = 'Hidden'
    table_data['project_members']['member_role']['display'] = 'read-only'

    pmt_utils.display_form(table_data, 'project_members', 1, 'useValues', 1,
                           db)
    pmt_utils.alertsArea(form, "Member data retrieved successfully")

    listing_url = '/%s-cgi-bin/contact_list.pyc?performDbQuery=1' % db_name
    help_url = '/%s/html/contactsum.html' % (db_name)
    editFunctionButtons(form['key_id'].value, listing_url, help_url)

    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')

    pageEnd(table_data, db)
Exemple #14
0
def exit(message,table_data=None,db=None):
    pmt_utils.usernamePasswordDisplay(username)
    pmt_utils.alertsArea(form, message);

    if username!=None and db!=None:
        create_priv=pmt_utils.hasPriv(db,username,'user_admin')
    else:
        create_priv=0

    url='/%s/html/contactsum.html' % db_name
    pmt_utils.queryFunctionButtons(create_priv, url)

    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')
    
    if table_data!=None and db!=None:
        pageEnd(table_data,db)
    sys.exit()
Exemple #15
0
def exit(message, table_data=None, db=None, login_display=1):
    if login_display:
        pmt_utils.usernamePasswordDisplay()
    pmt_utils.alertsArea(form, message)

    if username != None and db != None:
        create_priv = pmt_utils.hasPriv(db, username, 'create_ecp')
    else:
        create_priv = 0

    queryFunctionButtons(create_priv, 0, '/%s/html/ecpsum.html' % db_name)

    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')

    if table_data != None and db != None:
        pageEnd(table_data, db)
    sys.exit()
Exemple #16
0
def doCreate():
    status,table_data,db=pageInit('Create',formJS=1)
    if status != 'success':
        message="Could not connect to db.\n%s" % status
        exit(message)
 
    pmt_utils.display_form(table_data, 'project_members', 1,'useValues',1,db)
    displayPriviledges({}, table_data)

    message="Enter information on form and depress Create button"
    pmt_utils.alertsArea(form,message)

    # Add buttons and hidden fields
    listing_url='/%s-cgi-bin/project_members_admin.pyc?performDbQuery=1' % (db_name) 
    help_url='/%s/html/contactsum.html' % db_name
    pmt_utils.createFunctionButtons('create',listing_url, help_url)
    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')
    
    pageEnd(table_data,db)
Exemple #17
0
def doEdit():

    status, table_data, db = pageInit('Edit', formJS=1)

    if status != 'success':
        message = "Could not connect to the database.\n" + status
        exit(message)

    status, details = db_authentication.password_valid(db,
                                                       crypt_salt=db_name,
                                                       username=username,
                                                       password=password)
    if status != 'success':
        exit(details)

    sqlStatement = pmt_utils.selectAllColumnsSqlStatement(
        table_data, 'pai', form["key_id"].value)
    dbResult = pmt_utils.executeSQL(db, sqlStatement)

    if dbResult['status'] != 'success':
        message = "Could not retrieve action item to edit.\n" + dbResult[
            'message']
        exit(message)

    result = dbResult['result']
    table_data = pmt_utils.dbToTableData(table_data, 'pai', result[0])
    pmt_utils.display_form(table_data, 'pai', 1, 'useValues', 1, db)

    pmt_utils.alertsArea(form, "Action item data retrieved successfully")

    listing_url = '/%s-cgi-bin/pai_admin.pyc?performDbQuery=1' % (db_name)
    help_url = '/%s/html/pai_intro.html' % (db_name)
    del_priv = pmt_utils.hasPriv(db, username, 'del_pai')
    editFunctionButtons(form["key_id"].value, listing_url, help_url, del_priv)

    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')

    pageEnd(table_data, db)
Exemple #18
0
def doCreate():

    status, table_data, db = pageInit('Create', formJS=1)

    if status != 'success':
        message = "Could not connect to db.\n%s" % status
        exit(message)

    # initialize form data values to zero or blank
    table_data = pmt_utils.init_table_data(table_data, 'pai')
    now = time_pkg.current_time_MM_DD_YYYY()
    table_data['pai']['date_created']['value'] = now

    status, details = db_authentication.password_valid(db,
                                                       crypt_salt=db_name,
                                                       username=username,
                                                       password=password)
    if status != 'success':
        exit(details)

    table_data['pai']['id']['display'] = 'hidden'

    pmt_utils.display_form(table_data, 'pai', 1, 'useValues', 1, db)

    message = "Enter information on form and depress Create button"
    pmt_utils.alertsArea(form, message)

    # create functions button row
    listing_url = '/%s-cgi-bin/pai_admin.pyc?performDbQuery=1' % (db_name)
    help_url = '/%s/html/pai_intro.html' % (db_name)
    pmt_utils.createFunctionButtons('create', listing_url, help_url)
    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')

    pageEnd(table_data, db)
Exemple #19
0
def doCsv():

    status, table_data, db = pageInit("Export", formJS=0)

    if status != 'success':
        message = "Can not connect to database.\n" + status

    sql = "SELECT id, inv_prefix, outside_id, gist, source, inv_status, "
    sql = sql + "problem_description, problem_duplication, system_status, "
    sql = sql + "priority, category, originator, origination_date, assigned_to, "
    sql = sql + "analysis, analyst_signature, swm_analysis_signature, "
    sql = sql + "corrective_action, config_items_impacted, test_plan, "
    sql = sql + "test_results, swm_completion_signature, "
    sql = sql + "test_completion_signature, cm_completion_signature, "
    sql = sql + "qa_completion_signature from inventory ORDER by inv_prefix, int4(id)"
    queryResult = pmt_utils.executeSQL(db, sql)

    if queryResult["status"] != 'success':
        message = "Query failed.\n" + dbResult['message']

    result = queryResult['result']

    print '<a href="/%s/html/%s">' % (db_name, 'inventory.csv')
    print 'Inventory File '
    print '(Right Click and select &quot;Save Link As&quot; to download)</a>'
    print '<BR><BR><B>The Comma Separated Values file contains the following'
    print 'fields for each record:</B>'
    print '<TABLE BORDER>'
    print '<TR><TD>Inventory Id</TD><TD>Prefix</TD><TD>Outside Id</TD>'
    print '<TD>Gist</TD><TD>Source</TD><TD>Status</TD>'
    print '<TD>Problem Description</TD><TD>Problem Duplication</TD>'
    print '<TD>System Status</TD><TD>Priority</TD><TD>Category</TD>'
    print '<TD>Originator</TD><TD>Origination Date</TD><TD>Assigned To</TD>'
    print '<TD>Analysis</TD><TD>Corrective Action</TD>'
    print '<TD>Configuration Items Impacted</TD><TD>Test Plan</TD>'
    print '<TD>Test Results</TD><TD>Completion Status</TD></TR></TABLE>'
    print 'NOTE: Commas in fields have been changed to whitespace'
    output_lines = []
    for i in xrange(0, len(result)):
        inv_completed = 'Open'
        if string.strip(result[i]['inv_status']) == 'Fixed (complete)':
            if string.strip(result[i]['analyst_signature']) != ''         and \
                 string.strip(result[i]['swm_analysis_signature'])!=''    and \
                 string.strip(result[i]['swm_completion_signature'])!=''  and \
                 string.strip(result[i]['test_completion_signature'])!='' and \
                 string.strip(result[i]['cm_completion_signature'])!=''   and \
                 string.strip(result[i]['qa_completion_signature'])!='':
                inv_completed = 'Closed'

        txt = string.replace(result[i]['inv_prefix'], ',', '') + ','
        txt = txt + string.replace(result[i]['id'], ',', '') + ','
        txt = txt + string.replace(result[i]['outside_id'], ',', '') + ','
        txt = txt + string.replace(result[i]['gist'], ',', '') + ','
        txt = txt + string.replace(result[i]['source'], ',', '') + ','
        txt = txt + string.replace(result[i]['inv_status'], ',', '') + ','
        txt = txt + string.replace(result[i]['problem_description'], ',',
                                   '') + ','
        txt = txt + string.replace(result[i]['problem_duplication'], ',',
                                   '') + ','
        txt = txt + string.replace(result[i]['system_status'], ',', '') + ','
        txt = txt + string.replace(result[i]['priority'], ',', '') + ','
        txt = txt + string.replace(result[i]['category'], ',', '') + ','
        txt = txt + string.replace(result[i]['originator'], ',', '') + ','
        txt = txt + string.replace(result[i]['origination_date'], ',',
                                   '') + ','
        txt = txt + string.replace(result[i]['assigned_to'], ',', '') + ','
        txt = txt + string.replace(result[i]['analysis'], ',', '') + ','
        txt = txt + string.replace(result[i]['corrective_action'], ',',
                                   '') + ','
        txt = txt + string.replace(result[i]['config_items_impacted'], ',',
                                   '') + ','
        txt = txt + string.replace(result[i]['test_plan'], ',', '') + ','
        txt = txt + string.replace(result[i]['test_results'], ',', '') + ','
        txt = txt + inv_completed
        txt = string.replace(txt, '\r\n', ' ')
        txt = string.replace(txt, '\n', ' ')
        output_lines.append(txt)

    filename = '/home/%s/html/inventory.csv' % db_name
    file_io.writeToFile(filename, output_lines)

    queryFunctionButtons(0, 1, '/%s/html/sprsum.html' % (db_name))
    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')

    pageEnd(table_data, db)
Exemple #20
0
def doCsv():

    # Setup the javascript and html, connect to the db
    subHeading = 'Address Book (Palm Desktop Import File)'
    status, table_data, db = pageInit(subHeading, formJS=0)

    if status != 'success':
        message = "Couldn't connect to db.\n%s" % (status)
        exit(message)

    # Get project member contact info
    sql = "SELECT first_name, last_name, email, company_name, "
    sql = sql + "address_line_1, address_line_2, city, state, zip, "
    sql = sql + "phone_number_voice, phone_extension, "
    sql = sql + "cell_phone_number, phone_number_fax "
    sql = sql + "from project_members ORDER by last_name, first_name"
    queryResult = pmt_utils.executeSQL(db, sql)

    if queryResult["status"] != 'success':
        message = "Query failed.\n" + dbResult['message']
        exit(message)

    result = queryResult['result']

    # Display a link to the file and a listing of the data itself
    url = '/%s/html/%s' % (urllib.quote(db_name), 'address_book.dat')
    print '<BR><BR><a href="%s">' % url
    print 'Palm Desktop Address Book Import File '
    print '(Right Click Here and select '
    print '&quot;Save Link As&quot; to download)</a>'

    print '<BR><BR><B>You should configure Palm Desktop Tools '
    print 'to import the Address Book with a comma used as the '
    print 'field deliminter and with the following order of the '
    print 'fields for each address entry:</B>'

    print '<TABLE BORDER>'
    print '<TR><TD>First Name</TD><TD>Last Name</TD>'
    print '<TD>Company Name</TD><TD>Address</TD><TD>City</TD>'
    print '<TD>State</TD><TD>Zip Code</TD><TD>Work</TD>'
    print '<TD>Fax</TD><TD>Mobile</TD><TD>E-Mail</TD></TR></TABLE>'
    print '<BR><B>The contents of this Address Book '
    print 'Import file follows:</B>'
    print '<PRE>'

    output_lines = []
    for i in xrange(0, len(result)):
        if string.strip(result[i]['phone_extension']) != '':
            ext = ' x' + result[i]['phone_extension']
        else:
            ext = ''
        if string.strip(result[i]['address_line_1']) != '':
            address = result[i]['address_line_1']
            if string.strip(result[i]['address_line_2']) != '':
                address = address + ' ' + result[i]['address_line_2']
        else:
            address = ''

        outline = result[i]['first_name'] + ','
        outline = outline + result[i]['last_name'] + ','
        outline = outline + result[i]['company_name'] + ','
        outline = outline + address + ','
        outline = outline + result[i]['city'] + ','
        outline = outline + result[i]['state'] + ','
        outline = outline + result[i]['zip'] + ','
        outline = outline + result[i]['phone_number_voice'] + ext + ','
        outline = outline + result[i]['phone_number_fax'] + ','
        outline = outline + result[i]['cell_phone_number'] + ','
        outline = outline + result[i]['email']
        print outline
        output_lines.append(outline)

    # Write the contact data to a file
    output_filename = '/home/%s/html/address_book.dat' % db_name
    file_io.writeToFile(output_filename, output_lines)
    print '</PRE>'

    # Add buttons, hidden html form data, and company info
    queryFunctionButtons(0, '/%s/html/contactsum.html' % (db_name))
    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')

    pageEnd(table_data, db)
Exemple #21
0
def doSave():
    saveDueToCreate = 0    

    status,table_data,db=pageInit('Edit',formJS=1)

    if status != 'success':
        message="Could not connect to db.\n%" % status
        exit(message)

    status, details = db_authentication.password_valid(db,
                                                       crypt_salt=db_name,
                                                       username=username,
                                                       password=password)

    if status != 'success':
        exit(details)

    if form["key_id"].value == 'create':
        saveDueToCreate = 1
        queryResult = pmt_utils.executeSQL(db, "SELECT NEXTVAL('spr_id_seq')")

        form["key_id"].value = `queryResult['result'][0]['nextval']`

    table_data = pmt_utils.formToTableData(table_data,
                                           'spr',
                                           form,
                                           form['key_id'].value)
    alerts = ''

    data=pmt_utils.process_signature(db,
                                     form['analyst_username'].value,
                                     form['analyst_password'].value,
                                     'Analyst',
                                     form['analyst_signature'].value,
                                     form['analyst_signature_function'].value)
    (status, details,
     table_data['spr']['analyst_username']['value'],
     table_data['spr']['analyst_password']['value'],
     table_data['spr']['analyst_signature']['value'],
     table_data['spr']['analyst_signature_function']['value']) = data

    alerts = alerts + details

    data=pmt_utils.process_signature(db,
                       form['swm_analysis_username'].value,
                       form['swm_analysis_password'].value, 'Software Manager',
                       form['swm_analysis_signature'].value,
                       form['swm_analysis_signature_function'].value)
    (status, details,
     table_data['spr']['swm_analysis_username']['value'],
     table_data['spr']['swm_analysis_password']['value'],
     table_data['spr']['swm_analysis_signature']['value'],
     table_data['spr']['swm_analysis_signature_function']['value']) = data

    alerts = alerts + details

    data=pmt_utils.process_signature(db,
                     form['swm_completion_username'].value,
                     form['swm_completion_password'].value, 'Software Manager',
                     form['swm_completion_signature'].value,
                     form['swm_completion_signature_function'].value)
    (status, details,
     table_data['spr']['swm_completion_username']['value'],
     table_data['spr']['swm_completion_password']['value'],
     table_data['spr']['swm_completion_signature']['value'],
     table_data['spr']['swm_completion_signature_function']['value']) = data

    alerts = alerts + details

    data=pmt_utils.process_signature(db,
                        form['test_completion_username'].value,
                        form['test_completion_password'].value, 'Test Manager',
                        form['test_completion_signature'].value,
                        form['test_completion_signature_function'].value)
    (status, details,
     table_data['spr']['test_completion_username']['value'],
     table_data['spr']['test_completion_password']['value'],
     table_data['spr']['test_completion_signature']['value'],
     table_data['spr']['test_completion_signature_function']['value']) = data

    alerts = alerts + details

    data=pmt_utils.process_signature(db,
                            form['cm_completion_username'].value,
                            form['cm_completion_password'].value, 'CM Manager',
                            form['cm_completion_signature'].value,
                            form['cm_completion_signature_function'].value)
    (status, details,
     table_data['spr']['cm_completion_username']['value'],
     table_data['spr']['cm_completion_password']['value'],
     table_data['spr']['cm_completion_signature']['value'],
     table_data['spr']['cm_completion_signature_function']['value']) = data

    alerts = alerts + details

    data=pmt_utils.process_signature(db,
                            form['qa_completion_username'].value,
                            form['qa_completion_password'].value, 'QA Manager',
                            form['qa_completion_signature'].value,
                            form['qa_completion_signature_function'].value)
    (status, details,
     table_data['spr']['qa_completion_username']['value'],
     table_data['spr']['qa_completion_password']['value'],
     table_data['spr']['qa_completion_signature']['value'],
     table_data['spr']['qa_completion_signature_function']['value']) = data

    alerts = alerts + details

    dbResult = pmt_utils.saveForm(table_data, db,
                                  form['key_id'].value, "spr",
                                  " WHERE id = '%s'" % form["key_id"].value,
                                  form, 0, 0)

    if dbResult['status'] != 'success':
        message="Item could not be saved.\n" + dbResult['message']
        exit(message)

    if saveDueToCreate:
        subject='New SPR #%s has been generated' % form['key_id'].value
        message='SPR #%s has been generated.\n\n' % form["key_id"].value
        message=message+'Assigned to: %s\n\n' % form['assigned_to'].value
        message=message+'Problem Description is as follows:\n'
        message=message+form['problem_description'].value+'\n\n'
        message=message+'Log into the System Problem Report tracking tool at '
        message=message+'http://www.isrparc.org for further info.'
        message=message+'If you do not wish to be on this mailing list please '
        message=message+'send an email requesting removal to [email protected].\n'
        pmt_utils.emailList(db,'localhost', 'spr_list', subject, message)

    display_questionnaire(db,table_data, 'edit')

    alerts = alerts + '\nItem saved successfully'
    pmt_utils.alertsArea(form,alerts)

    listing_url='/%s-cgi-bin/spr_admin.pyc?performDbQuery=1' % (db_name)
    help_url='/%s/html/sprsum.html' % db_name
    editFunctionButtons(form["key_id"].value, listing_url, help_url)
        
    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')
    
    pmt_utils.textbox(None, 'analyst_signature',
                      table_data['spr']['analyst_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pmt_utils.textbox(None, 'swm_analysis_signature',
                      table_data['spr']['swm_analysis_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pmt_utils.textbox(None, 'swm_completion_signature',
                      table_data['spr']['swm_completion_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pmt_utils.textbox(None, 'test_completion_signature',
                      table_data['spr']['test_completion_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pmt_utils.textbox(None, 'cm_completion_signature',
                      table_data['spr']['cm_completion_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pmt_utils.textbox(None, 'qa_completion_signature',
                      table_data['spr']['qa_completion_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pageEnd(table_data,db)
Exemple #22
0
def doEdit():
    table_data = declarations.define_tables()
    print "<HTML>"
    print "<HEAD>"
    pmt_utils.generate_form_javascript(table_data, 'project_info',
                                       'project_admin', 0)
    pmt_utils.title("Project Info Administration")
    print "</HEAD>"

    pmt_utils.bodySetup()
    pmt_utils.mainHeading('Project Info Administration')
    pmt_utils.subHeading('Edit Project Info')
    pmt_utils.formSetup("project_admin", db_name, "project_admin",
                        "return submitForm(document.project_admin)")

    dbResult = pmt_utils.connectDB(declarations.pmt_info['browser_username'],
                                   declarations.pmt_info['browser_password'],
                                   declarations.pmt_info['db_name'])

    if dbResult['status'] != 'success':
        msg = "Could not connect to the database\n"
        pmt_utils.alertsArea(form, msg + dbResult['message'])
        sys.exit()

    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()

    sqlStatement = pmt_utils.selectAllColumnsSqlStatement(
        table_data, 'project_info', '1')
    dbResult = pmt_utils.executeSQL(db, sqlStatement)

    if dbResult['status'] != 'success':
        msg = "Could not retrieve project info to edit\n"
        pmt_utils.alertsArea(form, msg + dbResult['message'])
    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 Info retrieved successfully")

    project_adminButtons('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>"
    pmt_utils.trailer(table_data, db)
    db.close()
    print "</BODY>"
    print "</HTML>"
Exemple #23
0
def doSave():
    
    status,table_data,db=pageInit('Save',formJS=1)

    if status != 'success':
        message="Could not connect to db.\n%s" % status
        exit(message)

    create='false'
    if form["key_id"].value == 'create':
        create='true'

        # check for duplicate username
        sql="select id from project_members "
        sql=sql+"where member_username='******'" % form['member_username'].value
        dupResult=pmt_utils.executeSQL(db,sql)
        if len(dupResult['result'])!=0:
            msg="The specified username '%s' "% form['member_username'].value
            msg=msg+'is already in use.' 
            exit(msg)

        # update the member id
        sql="SELECT NEXTVAL('project_members_id_seq')"
        queryResult = pmt_utils.executeSQL(db, sql)
        if queryResult['status']!='success':
            message="Unable to retrieve project member id"
            exit(message,table_data,db)
            
        form["key_id"].value = `queryResult['result'][0]['nextval']`
        form['id'].value=form['key_id'].value

    # save member data to project_members table in db
    dbResult = pmt_utils.saveForm(table_data, db,
                                  form['key_id'].value,
                                  "project_members",
                                  " WHERE id = '%s'" % form["key_id"].value,
                                  form)
    if dbResult['status'] != 'success':
        message="Project member could not be saved.\n" + dbResult['message']
        exit(message,table_data,db)

    # save privileges to privileges table in db
    whereStr=" WHERE member_username='******'" % form["member_username"].value
    dbResult = pmt_utils.saveForm(table_data, db,
                                  form['member_username'].value,
                                  "priviledges",
                                  whereStr,
                                  form)
    if dbResult['status'] != 'success':
        message="Unable to save member privileges.\n%s" % dbResult['message']
        exit(message,table_data,db)

    # Display the user information
    table_data = pmt_utils.formToTableData(table_data,
                                           'project_members',
                                           form, form['key_id'].value)  
    pmt_utils.display_form(table_data,'project_members',1,'useValues',1,db)

    # Display the user's privileges
    sql = "select * from priviledges "
    sql=sql+"where member_username='******'" % (form['member_username'].value)
    dbResult = pmt_utils.executeSQL(db, sql)
    if dbResult['status'] != 'success':
        message="Could not get member privileges.\n%s" % dbResult['message']
        exit(message)
    result = dbResult['result']
    table_data = pmt_utils.dbToTableData(table_data, 'priviledges', result[0])
    displayPriviledges(result[0], table_data)
    pmt_utils.alertsArea(form,"Project member successfully saved")
    
#    if create=='true':
    # Add the username and password to the .passwd file or htaccess
    command='/usr/bin/htpasswd -b '
    command=command+'/var/www/admin/%s.passwd ' % db_name
    #NOTE : Use the form data here since an admin's cookie is logged in
    command=command+'%s ' % form['member_username'].value
    command=command+'%s' % form['member_password'].value
    status, output = commands.getstatusoutput(command)

    if create=='true':
        # Send an email to the new user
        db_label=string.upper(db_name)
        if db_label=='SAVE':
            db_label="IFCS"
        if db_label=="BUAV":
            db_label="FCST"
        if db_label=="CUAV":
            db_label="PADV"
        msg="A new user account has been created for you "
        msg=msg+"on the %s site at www.isrparc.org.\n\n"%string.upper(db_label)
        #NOTE : Use the form data here since an admin's cookie is logged in
        msg=msg+"Username: %s\n" % form['member_username'].value
        msg=msg+"Password: %s" % form['member_password'].value
        pmt_utils.send_email('localhost',
                             '*****@*****.**',
                             [form['email'].value],
                             "New User Account",
                             msg)

    # Add buttons and hidden fields
    listing_url='/%s-cgi-bin/project_members_admin.pyc?performDbQuery=1' % (db_name)
    help_url='/%s/html/contactsum.html' % db_name
    pmt_utils.editFunctionButtons(form["key_id"].value,listing_url, help_url)
    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')
    
    pageEnd(table_data,db)	
Exemple #24
0
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>"
Exemple #25
0
def doCreate():
    status,table_data,db=pageInit('Create',formJS=1)
    if status != 'success':
        message="Could not connect to db,\n" + dbResult['message']
        exit(message)
    status, details = db_authentication.password_valid(db,
                                                       crypt_salt=db_name,
                                                       username=username,
                                                       password=password)

    if status != 'success':
        exit(details)

    display_questionnaire(db,table_data, 'edit')
    message="Enter information on form and depress Create button"
    pmt_utils.alertsArea(form,message)

    listing_url='/%s-cgi-bin/spr_admin.pyc?performDbQuery=1' % (db_name)
    help_url='/%s/html/spr_intro.html' % db_name
    pmt_utils.createFunctionButtons('create',listing_url,help_url)

    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')
    
    pmt_utils.textbox(None, 'analyst_signature',
                      table_data['spr']['analyst_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pmt_utils.textbox(None, 'swm_analysis_signature',
                      table_data['spr']['swm_analysis_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pmt_utils.textbox(None, 'swm_completion_signature',
                      table_data['spr']['swm_completion_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pmt_utils.textbox(None, 'test_completion_signature',
                      table_data['spr']['test_completion_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pmt_utils.textbox(None, 'cm_completion_signature',
                      table_data['spr']['cm_completion_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pmt_utils.textbox(None, 'qa_completion_signature',
                      table_data['spr']['qa_completion_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pageEnd(table_data,db)
Exemple #26
0
def doSave():
    saveDueToCreate = 0

    status, table_data, db = pageInit('Edit', formJS=1)

    if status != 'success':
        message = "Could not connect to db.\n%" % status
        exit(message)

    status, details = db_authentication.password_valid(db,
                                                       crypt_salt=db_name,
                                                       username=username,
                                                       password=password)

    if status != 'success':
        exit(details)

    if form["key_id"].value == 'create':
        saveDueToCreate = 1
        queryResult = pmt_utils.executeSQL(
            db, "SELECT NEXTVAL('inventory_id_seq')")

        form["key_id"].value = ` queryResult['result'][0]['nextval'] `

    table_data = pmt_utils.formToTableData(table_data, 'inventory', form,
                                           form['key_id'].value)
    alerts = ''

    data = pmt_utils.process_signature(
        db, form['prop_id_assigned_by_username'].value,
        form['prop_id_assigned_by_password'].value, 'Property ID Authority',
        form['prop_id_assigned_by_signature'].value,
        form['prop_id_assigned_by_sig_func'].value)
    (status, details,
     table_data['inventory']['prop_id_assigned_by_username']['value'],
     table_data['inventory']['prop_id_assigned_by_password']['value'],
     table_data['inventory']['prop_id_assigned_by_signature']['value'],
     table_data['inventory']['prop_id_assigned_by_sig_func']['value']) = data

    dbResult = pmt_utils.saveForm(table_data, db, form['key_id'].value,
                                  "inventory",
                                  " WHERE id = '%s'" % form["key_id"].value,
                                  form, 0, 0)

    if dbResult['status'] != 'success':
        message = "Item could not be saved.\n" + dbResult['message']
        exit(message)

    if saveDueToCreate:
        subject = 'New INV #%s has been generated' % form['key_id'].value
    # message='INV #%s has been generated.\n\n' % form["key_id"].value
    # message=message+'Assigned to: %s\n\n' % form['assigned_to'].value
    # message=message+'Problem Description is as follows:\n'
    # message=message+form['problem_description'].value+'\n\n'
    # message=message+'Log into the Inventory tracking tool at '
    # message=message+'http://www.isrparc.org for further info.'
    # message=message+'If you do not wish to be on this mailing list '
    # message=message+'please send an email requesting removal to '
    # message=message+'[email protected].\n'
    # pmt_utils.emailList(db,'localhost', 'inv_list', subject, message)

    display_questionnaire(db, table_data, 'edit')

    alerts = alerts + '\nItem saved successfully'
    pmt_utils.alertsArea(form, alerts)

    listing_url = '/%s-cgi-bin/inv_admin.pyc?performDbQuery=1' % (db_name)
    help_url = '/%s/html/sprsum.html' % db_name

    # This will return to po_admin.py or inv_admin.py in Edit mode.
    if form.has_key("return_to_po"):
        data = '?action=edit&key_id=%s' % table_data['inventory']['po_id'][
            'value']
        java = "return goto_url('/%s-cgi-bin/po_admin.pyc%s')" % (db_name,
                                                                  data)
        html = '<INPUT NAME="edit" type="button" value=" Return to PO '
        html = html + '" onClick="%s">' % java
        print '<BR><BR>'
        print html

    editFunctionButtons(form["key_id"].value, listing_url, help_url)

    po_id = table_data['inventory']['po_id']['value']
    print '<input type=hidden name=po_id value="%s">' % po_id

    val = table_data['inventory']['prop_id_assigned_by_signature']['value']
    pmt_utils.textbox(None, 'prop_id_assigned_by_signature', val, '40', '40',
                      None, None, 'hidden')
    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')

    pageEnd(table_data, db)
Exemple #27
0
def display_form():
    print "<html>"
    print "<head>"
    print "<title>Documentation Maintenance</title></head>"
    print '<body background="/%s/icons/circ_bg.jpg">' % (db_name)

    pmt_utils.mainHeading("Upload")
    pmt_utils.subHeading("Single File, Zip, or Tarfile upload:")

    print '<P><form action="/%s-cgi-bin/upload.pyc" method="POST" enctype="multipart/form-data">' % db_name
    print '<TABLE BORDER=0>'

    # display the name of the data item
    print "<TR><TD><B>Data Item Name</B>:</TD><TD>"
    pmt_utils.textbox(None, 'name',  "", '40', '80',  None,  None)
    print "</TD></TR>"

    # display the version field
    print "<TR><TD><B>Version:</B></TD><TD>"
    pmt_utils.textbox(None,  'version',  "",  '40',  '80',  None,  None)
    print "</TD></TR>"

    # display the description field
    print "<TR><TD><B>Description:</B></TD><TD>"
    pmt_utils.textarea(None,   'description',   "",   '5',   '40',   None,   None)
    print "</TD></TR>"

    print '<TR><TD><B>Filename</B>:</TD>'
    print '<TD><input name="archive" type="file" size="40" maxlength="100"></TD></TR>'
    if form.has_key('dest'):
        dest=form['dest'].value
    else: dest=''
    print '<TR><TD><B>Destination Folder</B>:</TD><TD>'
    print '<input name="folder" type="text" size="40" maxlength="100" value="%s">' % dest
    print '</TD></TR></TABLE>'
    
    print '<input name="permissions" type="checkbox" value="permissions">'
    print 'Set file permissions after upload<BR>'

    print '<input name="extract" type="checkbox" value="extract">'
    print 'Extract archive on server<BR>'
    print '<input name="submit" type="submit" value="Upload File">'
    print '</form>'

    print '<HR>'

    print '<H3>Introduction</H3>'
    print '<P>This maintenance function will allow authorized users to upload a single file or file archive to their website.  The tar file may be compressed with gzip.  The archive file size when extracted should not'
    print 'exceed your maximum allowable disk space allotment for your site which is %d MB (%d bytes).  If this happens all files that exceed the allotment will not be stored in your website.  It is therefore suggested that you maintain a complete copy of your site locally and change your local copy to how you would like it on www.isrparc.org, create the archive of your local copy and upload the archive to www.isrparc.org.  The archive filename should end with .zip, .tar.gz, or .tgz</P>' % (upload_ceiling/(1024*1024),upload_ceiling)

    print '<P>You may upgrade your disk space allotment via an e-mail request to the www.isrparc.org <A HREF="mailto:[email protected]">support team</A>.</P>'
    print '<H3>Directions for Uploading Archives</H3>'
    print '<P>You may upload a winzip, gzip, or tar file to your website.'
#    print 'The contents of the archive should match the following directory tree structure, in other words the directories listed below should be the top level directories when the archive is created.</P>'
    print '<P>All files including files in zip and tar archive should not have spaces in their name.</P>'
    print '<P>Filenames can have mixed case and are not governed by an 8.3 filename name specification.'
#    print '<P>If the file you are uploading is not a zip or tar archive, the file will be placed in the documents directory for the website you specify.'
#    print '<P>Allowable subdirectories in your archive file</P>'
#    print '<UL>'
#    print '<LI>documents'
#    print '</UL>'
#    print '<P>NOTE: Do <b>NOT</B> put a subdirectory called cgi-bin in your archive file. This can damage the Documentation Management engine at your website, if installed.</P>'
#    print '<P>Example (Windows 9x Systems at MS-DOS prompt):</p>'
#    print 'cd C:\<BR>'
#    print 'mkdir website<BR>'
#    print 'cd C:\website<BR>'
#    print 'mkdir documents<BR>'
#    print '<P>Put all of your document files: MS Word, Excel, Power Point, Adobe Acrobat, ASCII text under the documents directory'
#    print '<p>zip all files under c:\website directory but do not zip the directory c:\website</p>'
#    print '<P>If your archive has other directories in it besides the above mentioned names, these directories will not be accessed by the www.isrparc.org server and will be merely wasting your websites disk space allotment.  This Site Maintenance Upload program does not check the integrity of your archive file so it is imperative that you specify your archive as mentioned above.  Future updates will verify the contents of the archive file you are uploading.</P>'
    print '<p align="right"><A HREF="mailto:[email protected]">Contact Support Team</a>'


    print '</body>'
    print '</html>'
Exemple #28
0
def doSave():
    table_data = declarations.define_tables()

    print "<HTML>"
    print "<HEAD>"

    pmt_utils.generate_form_javascript(table_data, 'project_info',
                                       'project_admin', 0)
    pmt_utils.title("Project Info Administration")

    print "</HEAD>"

    pmt_utils.bodySetup()
    pmt_utils.mainHeading('Project Info Administration')
    pmt_utils.subHeading('Edit Project Info')
    pmt_utils.formSetup("project_admin", db_name, "project_admin",
                        "return submitForm(document.project_admin)")

    dbResult = pmt_utils.connectDB(declarations.pmt_info['browser_username'],
                                   declarations.pmt_info['browser_password'],
                                   declarations.pmt_info['db_name'])

    if dbResult['status'] != 'success':
        msg = "Project Info could not be saved, could not connect to db\n"
        pmt_utils.alertsArea(form, msg + dbResult['message'])
        # generate function button row
        project_adminButtons('save')

        # generate hidden fields for form
        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>"
        pmt_utils.trailer(table_data, db)
        db.close()
        print "</BODY>"
        print "</HTML>"
        return

    db = dbResult['result']

    # save the Form
    dbResult = pmt_utils.saveForm(table_data, db, None, "project_info",
                                  " WHERE id = '1'", form)

    # if the form was not successfully saved
    if dbResult['status'] != 'success':
        msg = "Project Info could not be saved due to an error during save,\n"
        pmt_utils.alertsArea(form, msg + dbResult['message'])
    else:
        table_data = declarations.define_tables()
        table_data = pmt_utils.formToTableData(table_data, 'project_info',
                                               form)
        table_data['project_info']['id']['value'] = '1'
        pmt_utils.display_form(table_data, 'project_info', 1, 'useValues', 1,
                               db)
        pmt_utils.alertsArea(form, "Project Info successfully saved")

    # generate function button row
    project_adminButtons('save')

    # generate hidden fields for form
    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>"
    pmt_utils.trailer(table_data, db)
    db.close()
    print "</BODY>"
    print "</HTML>"
Exemple #29
0
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>:&nbsp;'
    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>"
Exemple #30
0
def doEdit():

    status,table_data,db=pageInit("Edit",formJS=1)

    if status != 'success':
        message="Could not connect to the database.\n" + status
        exit(message)

    status, details = db_authentication.password_valid(db,
                                                       crypt_salt=db_name,
                                                       username=username,
                                                       password=password)
        
    if status != 'success':
        exit(details)

    sqlStatement = pmt_utils.selectAllColumnsSqlStatement(table_data,
                                                          'spr',
                                                          form["key_id"].value)
    dbResult = pmt_utils.executeSQL(db, sqlStatement)
           
    if dbResult['status'] != 'success':
        message="Could not retrieve item to edit.\n" + dbResult['message']
        exit(message)

    result = dbResult['result']
    table_data = pmt_utils.dbToTableData(table_data, 'spr', result[0])
    display_questionnaire(db,table_data, 'edit')
    pmt_utils.alertsArea(form, "Item data retrieved successfully");

    pmt_utils.textbox(None, 'analyst_signature',
                      table_data['spr']['analyst_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pmt_utils.textbox(None, 'swm_analysis_signature',
                      table_data['spr']['swm_analysis_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pmt_utils.textbox(None, 'swm_completion_signature',
                      table_data['spr']['swm_completion_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pmt_utils.textbox(None, 'test_completion_signature',
                      table_data['spr']['test_completion_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pmt_utils.textbox(None, 'cm_completion_signature',
                      table_data['spr']['cm_completion_signature']['value'],
                      '40', '40', None, None, 'hidden')
    pmt_utils.textbox(None, 'qa_completion_signature',
                      table_data['spr']['qa_completion_signature']['value'],
                      '40', '40', None, None, 'hidden')

    listing_url='/%s-cgi-bin/spr_admin.pyc?performDbQuery=1' % (db_name)
    help_url='/%s/html/spr_intro.html' % (db_name)
    editFunctionButtons(form["key_id"].value, listing_url,help_url)

    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')
    
    pageEnd(table_data,db)