Ejemplo n.º 1
0
    def viewLab(self, form):

        #print "Content-type:text/html"		# TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!!
        #print					# DITTO
        #print `form`

        db = self.__db
        cursor = self.__cursor
        hostname = self.__hostname

        userOutput = UserOutputClass()
        lHandler = LabHandler(db, cursor)

        # request may come from different views, so field names may vary
        if form.has_key("labs"):
            # request received through 'View Labs' menu item
            labID = int(form.getvalue("labs"))

        elif form.has_key("labID"):
            # request came from User Detailed View to navigate back to the Lab Detailed View
            labID = int(form.getvalue("labID"))

        else:
            labID = int(form.getvalue("view_lab"))

        newLab = lHandler.findLabByID(labID)

        self.printLabInfo('view', newLab)
Ejemplo n.º 2
0
    def cancelLabModification(self, form):

        db = self.__db
        cursor = self.__cursor
        hostname = self.__hostname

        lHandler = LabHandler(db, cursor)

        labID = int(form.getvalue("labID"))
        lab = lHandler.findLabByID(labID)  # fetch old lab attribute values

        self.printLabInfo('view', lab)
Ejemplo n.º 3
0
    def deleteLab(self, form):
        db = self.__db
        cursor = self.__cursor
        hostname = self.__hostname

        lHandler = LabHandler(db, cursor)

        #print "Content-type:text/html"		# TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!!
        #print					# DITTO
        #print `form`

        labID = form.getvalue("labID")

        lHandler.deleteLab(labID)

        utils.redirect(hostname + "User.php?View=5")
Ejemplo n.º 4
0
    def modifyLab(self, form):

        db = self.__db
        cursor = self.__cursor
        hostname = self.__hostname

        lHandler = LabHandler(db, cursor)

        #print "Content-type:text/html"		# TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!!
        #print					# DITTO
        #print `form`

        labID = int(form.getvalue("labID"))
        newLab = lHandler.findLabByID(labID)

        self.printLabInfo('edit', newLab)
Ejemplo n.º 5
0
    def addLab(self, form):

        db = self.__db
        cursor = self.__cursor
        hostname = self.__hostname

        lHandler = LabHandler(db, cursor)
        ucMapper = UserCategoryMapper(db, cursor)
        category_Name_ID_Map = ucMapper.mapCategoryNameToID()

        #print "Content-type:text/html"		# TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!!
        #print					# DITTO
        #print `form`

        # Get form values
        labName = form.getvalue("labName")
        labHeadTitle = form.getvalue("titles")
        labHeadName = form.getvalue("labHead")
        labHead = labHeadTitle + " " + labHeadName
        labCode = form.getvalue("labCode").upper()
        labDescr = form.getvalue("labDescription")
        labAddress = form.getvalue("labAddress")
        labAccess = form.getvalue("system_access_level")
        defaultLabAccessLevel = category_Name_ID_Map[
            labAccess]  # map to database ID

        try:
            newLabID = lHandler.insertLab(labName, labDescr, labAddress,
                                          defaultLabAccessLevel, labHead,
                                          labCode)
            #print `newLabID`
            newLab = Laboratory(newLabID, labName, labDescr, labAccess,
                                labAddress, labHead, labCode)
            self.printLabInfo('view', newLab)

        except DuplicateLabCodeException:

            d = DuplicateLabCodeException()
            utils.redirect(hostname + "User.php?View=3&labName=" + labName +
                           "&title=" + labHeadTitle + "&labHead=" +
                           labHeadName + "&labCode=" + labCode + "&labDescr=" +
                           labDescr + "&locn=" + labAddress + "&access=" +
                           labAccess + "&ErrCode=" + ` d.err_code() `)
Ejemplo n.º 6
0
	def generateBarcode(self, cTypeID, cSizeID, contNum, cLab):
		
		db = self.db
		cursor = self.cursor	# for easy access
		
		# Get the lab code that corresponds to lab ID
		lHandler = LabHandler(db, cursor)
		labCode = lHandler.findLabCode(cLab)
		
		ltHandler = LocationTypeHandler(db, cursor)
		
		# Find the container size
		contSize = ltHandler.findNumContainerSamples(cSizeID)
		
		# Find the container group code
		contTypeCode = ltHandler.findContainerTypeCode(cTypeID)

		# Produce a string barcode
		barcode = labCode + `contSize` + contTypeCode + `contNum`
		
		return barcode
Ejemplo n.º 7
0
    def modifyUser(self, form):

        db = self.__db
        cursor = self.__cursor
        hostname = self.__hostname

        uHandler = UserHandler(db, cursor)
        lHandler = LabHandler(db, cursor)
        pHandler = ProjectDatabaseHandler(db, cursor)

        ucMapper = UserCategoryMapper(db, cursor)
        category_Name_ID_Map = ucMapper.mapCategoryNameToID()

        #print "Content-type:text/html"		# TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!!
        #print					# DITTO
        #print `form`

        # Get form values
        userID = int(form.getvalue("userID"))
        newUser = uHandler.getUserByID(userID)
        '''
		labID = int(form.getvalue("labID"))
		username = form.getvalue("username")
		
		firstName = form.getvalue("firstName")
		lastName = form.getvalue("lastName")
		description = firstName + " " + lastName
		
		email = form.getvalue("email")
		passwd = form.getvalue("password")
		'''

        readProjects = pHandler.findMemberProjects(userID, 'Reader')
        newUser.setReadProjects(readProjects)

        writeProjects = pHandler.findMemberProjects(userID, 'Writer')
        newUser.setWriteProjects(writeProjects)

        self.printUserInfo('edit', newUser)
Ejemplo n.º 8
0
    def printProjectInfo(self, cmd, project):

        dbConn = DatabaseConn()
        hostname = dbConn.getHostname()  # to define form action URL

        db = dbConn.databaseConnect()
        cursor = db.cursor()

        uHandler = UserHandler(db, cursor)
        lHandler = LabHandler(db, cursor)

        gOut = GeneralOutputClass()

        currUser = Session.getUser()

        if cmd == 'view':

            projectID = project.getNumber()
            projectOwner = project.getOwner()
            ownerName = projectOwner.getFullName()
            ownerID = projectOwner.getUserID()
            projectName = project.getName()
            projectDescr = project.getDescription()

            # private or public
            isPrivate = project.isPrivate()

            if isPrivate:
                accessType = 'Private'
            else:
                accessType = 'Public'

            # Only allow modification by owner or admin AND disallow project deletion if there are reagents in it!!!
            modify_disabled = True
            delete_disabled = True

            if (currUser.getUserID() == ownerID) or (currUser.getCategory()
                                                     == 'Admin'):
                modify_disabled = False

            if project.isEmpty():
                delete_disabled = False

            # Aug. 18/08: Changed b/c of new format
            #content = gOut.printHeader() + gOut.printMainMenu()
            content = gOut.printHeader()

            content += '''
				<FORM name="project_form" method="POST" action="%s">
			
					<!-- pass current user as hidden form field -->
					<INPUT type="hidden" ID="username_hidden" NAME="username"'''

            content += "value=\"" + currUser.getFullName() + "\">"

            content += '''
					<TABLE height="100%%">
						<TABLE width="770px" cellpadding="5px" cellspacing="5px" class="detailedView_tbl">
							<TR>
								<TD class="detailedView_heading" style="white-space:nowrap;">
									PROJECT DETAILS PAGE
								</TD>
								
								<TD class="detailedView_heading" style="text-align:right">
									'''
            content += "<INPUT TYPE=\"submit\" name=\"modify_project\" value=\"Modify Project\""

            if modify_disabled:
                content += " disabled>"
            else:
                content += ">"

            content += "<INPUT TYPE=\"submit\" style=\"margin-left:2px;\" name=\"delete_project\" value=\"Delete Project\" onClick=\"return confirmDeleteProject();\""

            if modify_disabled or delete_disabled:
                content += " disabled>"
            else:
                content += ">"

            content += '''
								</TD>
	
							</TR>
	
							<TR>
								<TD class="projectDetailedViewName">
									Project #
								</TD>
	
								<TD class="detailedView_value" width="87%%">
									%d
									<INPUT TYPE="hidden" name="packetID" value="%d">
								</TD>
	
							</TR>
	
							<TR>
								<TD class="projectDetailedViewName">
									Project Owner:
								</TD>
	
								<TD class="detailedView_value">
									%s
									<INPUT TYPE="hidden" name="packetOwner" value="%d">
								</TD>
							</TR>
	
							<TR>
								<TD class="projectDetailedViewName">
									Project Name:
								</TD>
	
								<TD class="detailedView_value">
									%s
									<INPUT TYPE="hidden" name="packetName" value="%s">
								</TD>
							</TR>
	
							<TR>
								<TD class="projectDetailedViewName">
									Project Description:
								</TD>
	
								<TD class="detailedView_value">
									%s
									<INPUT TYPE="hidden" name="packetDescription" value="%s">
								</TD>
							</TR>
							
							<TR>
								<TD class="projectDetailedViewName">
									Access type:
								</TD>
	
								<TD class="detailedView_value">
									%s
									<INPUT TYPE="hidden" name="private_or_public" value="%s">
								</TD>
							</TR>
							
							<TR>
								<TD colspan="2">
									<HR/>
								</TD>
							</TR>
							
							'''

            # Now here, show or hide members section depending on the user's access level
            # Condition is the same as for determining whether modification is allowed - so use 'modify_disabled' variable
            if not modify_disabled:
                content += '''
							<TR>
								<TD class="projectDetailedViewName">
									Project Members:
								</TD>
								
								<TD>&nbsp;</TD>
							</TR>
							
							<TR>
								<TD class="detailedView_value" colspan="2">
									<TABLE width="100%%">
										<TR>
											<TD style="font-weight:bold; padding-left:10px" width="30%%">
												Readers:
											</TD>
	
											<TD style="font-weight:bold; padding-left:10px">
												Writers:
											</TD>
										</TR>
	
										<TR>
											<TD class="detailedView_value" style="vertical-align:top">
												<UL>
												'''

                if not isPrivate:
                    content += "All OpenFreezer Users"
                else:
                    # maintain the indent
                    readers = project.getReaders()

                    # sort by labs
                    labs = []
                    rdrLabs = {}

                    # First, iterate over readers list to extract all the labs
                    for rdr in readers:
                        lab = rdr.getLab().getID()

                        if lab not in labs:
                            labs.append(lab)

                    # Now iterate over the list of labs and link its readers to it
                    for lab in labs:
                        tmpRdrs = []  # list of members in one lab

                        for rdr in readers:
                            tmpLab = rdr.getLab().getID()

                            if tmpLab == lab:
                                # append reader to list of members of this lab
                                if rdrLabs.has_key(lab):
                                    tmpRdrs = rdrLabs[lab]

                                tmpRdrs.append(rdr)
                                rdrLabs[lab] = tmpRdrs

                    #for rdr in readers:
                    for lab_id in rdrLabs.keys():
                        rdrs = rdrLabs[lab_id]  # list of objects!!
                        tmp_lab_name = lHandler.findLabName(lab_id)

                        # print out the lab name

                        if currUser.getCategory() == 'Admin':
                            content += "<span class=\"linkShow\" style=\"color:#2E8B57\" onClick=\"goToLabViewFromProject(" + ` lab_id ` + ");\">" + tmp_lab_name + "</span><BR/>"
                        else:
                            content += "<span style=\"color:#2E8B57\">" + tmp_lab_name + "</span><BR/>"

                        # print reader names
                        for rdr in rdrs:
                            content += "<INPUT TYPE=\"hidden\" name=\"projectReaders\" value=\"" + ` rdr.getUserID(
                            ) ` + "\"></INPUT>"

                            # Only show hyperlinks if the viewer is an Admin; otherwise just output plain names
                            if currUser.getCategory() == 'Admin':
                                content += "<LI style=\"list-style:none; padding-left:6px;\">&#45;&#45;&nbsp;&nbsp;<span class=\"linkShow\" onClick=\"redirectToUserFromProject(" + ` rdr.getUserID(
                                ) ` + ");\">" + rdr.getFullName(
                                ) + "</span></LI>"
                            else:
                                content += "<LI style=\"list-style:none; padding-left:6px;\">&#45;&#45;&nbsp;&nbsp;" + rdr.getFullName(
                                ) + "</LI>"

                content += '''			
											</UL>
										</TD>


										<TD class="detailedView_value" style="width:250px; vertical-align:top">
											<UL>
											'''
                writers = project.getWriters()

                # sort them by lab too, same as for readers
                labs = []
                wrtrLabs = {}

                # First, iterate over readers list to extract all the labs
                for wrtr in writers:
                    lab = wrtr.getLab().getID()

                    if lab not in labs:
                        labs.append(lab)

                # Now iterate over the list of labs and link its readers to it
                for lab in labs:
                    tmpWrtrs = []  # list of members in one lab

                    for wrtr in writers:
                        tmpLab = wrtr.getLab().getID()

                        if tmpLab == lab:
                            # append reader to list of members of this lab
                            if wrtrLabs.has_key(lab):
                                tmpWrtrs = wrtrLabs[lab]

                            tmpWrtrs.append(wrtr)
                            wrtrLabs[lab] = tmpWrtrs

                for lab_id in wrtrLabs.keys():
                    wrtrs = wrtrLabs[lab_id]  # list of objects!!
                    tmp_lab_name = lHandler.findLabName(lab_id)

                    # print out the lab name
                    if currUser.getCategory() == 'Admin':
                        content += "<span class=\"linkShow\" style=\"color:#2E8B57\" onClick=\"goToLabViewFromProject(" + ` lab_id ` + ");\">" + tmp_lab_name + "</span><BR/>"
                    else:
                        content += "<span style=\"color:#2E8B57\" " + ` lab_id ` + ");\">" + tmp_lab_name + "</span><BR/>"

                    for wrtr in wrtrs:

                        content += "<INPUT TYPE=\"hidden\" name=\"projectWriters\" value=\"" + ` wrtr.getUserID(
                        ) ` + "\">"

                        if currUser.getCategory() == 'Admin':
                            content += "<LI style=\"list-style:none; padding-left:6px;\">&#45;&#45;&nbsp;&nbsp;<span class=\"linkShow\" onClick=\"redirectToUserFromProject(" + ` wrtr.getUserID(
                            ) ` + ");\">" + wrtr.getFullName() + "</span></LI>"
                        else:
                            content += "<LI style=\"list-style:none; padding-left:6px;\">&#45;&#45;&nbsp;&nbsp;" + wrtr.getFullName(
                            ) + "</LI>"

                content += '''
											</UL>
										</TD>
									</TR>
								</TABLE>
							</TD>	
						</TR>
					</TABLE>
				</FORM>
				
				<FORM id="viewUserForm" method="POST" action="%s">
					<INPUT type="hidden" id="view_user_hidden" name="view_user">
					<INPUT type="hidden" ID="curr_userid_hidden" NAME="curr_user_id" value="%d">
				</FORM>
				
				<FORM id="viewLabForm" method="POST" action="%s">
					<INPUT type="hidden" ID="curr_userid_hidden" NAME="curr_user_id" value="%d">
					<INPUT type="hidden" id="view_lab_hidden" name="view_lab">
				</FORM>
				</TABLE>
				'''

                content += gOut.printFooter()

            else:
                content += '''
					</TABLE>
				</FORM>
				</TABLE>
				'''

                content += gOut.printFooter()

            # and here, depending on what sections of the project view were printed, the number of arguments would vary
            if not modify_disabled:
                page_content = content % (
                    hostname + "cgi/project_request_handler.py", projectID,
                    projectID, ownerName, ownerID, projectName, projectName,
                    projectDescr, projectDescr, accessType, accessType,
                    hostname + "cgi/user_request_handler.py",
                    currUser.getUserID(), hostname +
                    "cgi/user_request_handler.py", currUser.getUserID())
            else:
                page_content = content % (
                    hostname + "cgi/project_request_handler.py", projectID,
                    projectID, ownerName, ownerID, projectName, projectName,
                    projectDescr, projectDescr, accessType, accessType)

            print "Content-type:text/html"  # THIS IS PERMANENT; DO NOT REMOVE
            print  # DITTO
            print page_content

        elif cmd == 'edit':

            projectID = project.getNumber()
            projectOwner = project.getOwner()
            ownerName = projectOwner.getFullName()
            ownerID = projectOwner.getUserID()
            projectName = project.getName()
            projectDescr = project.getDescription()
            isPrivate = project.isPrivate()

            content = gOut.printHeader()
            #content += gOut.printMainMenu()

            content += '''
				<FORM name="project_form" method="POST" action="%s">

					<!-- pass current user as hidden form field -->
					<INPUT type="hidden" ID="username_hidden" NAME="username"'''
            content += "value=\"" + currUser.getFullName() + "\">"

            content += '''
					<TABLE width="770px" cellpadding="5px" cellspacing="5px" style="border:1px solid black" frame="box" rules="rows">
					<TR>
						<TD colspan="3" style="padding-left:200px; text-align:center">
							
							<span style="color:#0000FF; font-weight:bold">MODIFY PROJECT </span>
							<span style="color:#FF0000; font-weight:bold">%d</span>
							
							<INPUT TYPE="hidden" name="packetID" value="%d">
							
							<INPUT TYPE="submit" style="margin-left:200px;" name="save_project" value="Save" onClick=\"alert('Please note: If your project writers list contains names of users who have read-only access to OpenFreezer, their names will be removed from the list during saving.'); addProjectOwnerToWritersList(); selectAllElements('readers_target_list'); selectAllElements('writers_target_list'); return verifyProjectOwner('projectOwnersList') && verifyProjectName('packet_name') && verifyProjectDescr('packet_descr') && verifyMembers('readers_target_list') && verifyMembers('writers_target_list');\">
							
							<INPUT TYPE="submit" style="margin-left:20px;" name="cancel_project" value="Cancel">
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Project Owner:
						</TD>

						<TD class="detailedView_value" colspan="2">
							<SELECT ID="projectOwnersList" name="packetOwner">
							'''

            # Get list of all potential project owners - users with 'CREATOR' or higher privileges
            # Returns list of User **objects**
            creators = uHandler.findAllMembersInCategory(
                'Creator', False, '<=')
            creatorsDict = {}  # name, uid

            for creator in creators:
                uid = creator.getUserID()
                name = creator.getFullName()
                creatorsDict[name] = uid

            names = creatorsDict.keys()
            names.sort()

            #print "Content-type:text/html"
            #print

            for name in names:
                #print name
                uid = creatorsDict[name]
                #print uid
                #print ownerID

                if uid == ownerID:
                    content += "<OPTION SELECTED value=" + ` uid ` + ">" + name + "</OPTION>"
                else:
                    content += "<OPTION value=" + ` uid ` + ">" + name + "</OPTION>"

            content += '''
							</SELECT>
							
							<DIV ID="projectOwnerWarning" STYLE="display:none; color:#FF0000; font-weight:normal;">
								<BR>Please select a name from the list above.
							</DIV>
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Project Name:
						</TD>

						<TD class="detailedView_value" colspan="2">
							<INPUT TYPE="text" id="packet_name" name="packetName" value="%s">
							
							<DIV ID="projectNameWarning" STYLE="display:none; color:#FF0000; font-weight:normal;">
								<BR>Please provide a project name.
							</DIV>
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Project Description:
						</TD>

						<TD class="detailedView_value" colspan="2">
							<INPUT TYPE="text" id="packet_descr" name="packetDescription" value="%s">
							
							<DIV ID="projectDescrWarning" STYLE="display:none; color:#FF0000; font-weight:normal;">
								<BR>Please provide a project description.
							</DIV>
						</TD>
					</TR>
					
					
					<TR>
						<TD class="projectDetailedViewName">
							Access type:
						</TD>

						<TD class="detailedView_value" style="width:400px">
						'''
            if not isPrivate:
                content += "<INPUT TYPE=\"RADIO\" NAME=\"private_or_public\" VALUE=\"public\" checked>Public&nbsp;&nbsp;&nbsp;&nbsp;"
                content += "<INPUT TYPE=\"RADIO\" NAME=\"private_or_public\" VALUE=\"private\">Private"
            else:
                content += "<INPUT TYPE=\"RADIO\" NAME=\"private_or_public\" VALUE=\"public\">Public&nbsp;&nbsp;&nbsp;&nbsp;"
                content += "<INPUT TYPE=\"RADIO\" NAME=\"private_or_public\" VALUE=\"private\" checked>Private"

            content += '''
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Project Members:
						</TD>

						<TD class="detailedView_value" colspan="2">
							&nbsp;
						</TD>
					</TR>
					
					<TR>
						<TD class="detailedView_value" colspan="3">
							Edit existing project members lists:
						</TD>
					</TR>

					<TR>
						<TD style="width:100px">
							<SELECT multiple size="10" id="readers_target_list" name="readersList">
						'''
            # Readers and writers associated with this project
            currReaders = project.getReaders()
            currWriters = project.getWriters()

            # Since object comparison is done by reference, cannot check if a User object returned by findAllMembers is a member of this project by using 'in array'.  Need to compare user IDs explicitly
            currReaderIDs = []
            currWriterIDs = []

            currReaderNames = []
            currWriterNames = []

            currReadersDict = {}  # name, id
            currWritersDict = {}

            # need lab IDs too - to match members to their labs when moved between lists, but having a 'memberID, labID' dictionary is too clumsy.  Easiest approach: have 'memberID, Member Object' dictionary
            currReaderObjDict = {}  # id, User object
            currWriterObjDict = {}

            for r in currReaders:
                rID = r.getUserID()
                rName = r.getFullName()

                # associate rID with its containing object
                currReaderObjDict[rID] = r

                currReaderIDs.append(rID)
                currReaderNames.append(rName)
                currReadersDict[rName] = rID

            for w in currWriters:
                wID = w.getUserID()
                wName = w.getFullName()

                currWriterObjDict[wID] = w

                currWriterIDs.append(wID)
                currWriterNames.append(wName)
                currWritersDict[wName] = wID

            currReaderNames.sort()
            currWriterNames.sort()

            for rName in currReaderNames:
                rID = currReadersDict[rName]
                rdr = currReaderObjDict[rID]
                rdrLabID = rdr.getLab().getID()

                #content += "<OPTION id=" + `rID` + " value=" + `rID` + ">" + rName + "</OPTION>"

                # June 28/07: Include labID in the option id
                content += "<OPTION id=\"user_" + ` rID ` + "_lab_" + ` rdrLabID ` + "\" value=" + ` rID ` + ">" + rName + "</OPTION>"

            content += '''
							</SELECT>
							<BR/>
							<INPUT TYPE="checkbox" style="margin-top:10px" onClick="selectAll(this.id, 'readers_target_list')" id="select_all_reader_chkbx"> Select All</INPUT>
						</TD>

						<TD width="30px">
							<input onclick="addMembers('readers_target_list', 'write')" value="   Make Writer >>" type="button"></INPUT><BR/>
							<input style="margin-top:10px;" onclick="addMembers('writers_target_list', 'read')" value="<< Make Reader" type="button"></INPUT><BR/>
							<input style="margin-top:10px;" onclick="removeProjectMembers()" value="Remove Selected" type="button"></INPUT>
						</TD>

						<TD>
							<SELECT multiple size="10" id="writers_target_list" name="writersList">
						'''
            for wName in currWriterNames:
                wID = currWritersDict[wName]
                wrtr = currWriterObjDict[wID]
                wrtrLabID = wrtr.getLab().getID()

                #content += "<OPTION id=" + `wID` + " value=" + `wID` + ">" + wName + "</OPTION>"

                # June 28/07: Include labID in the option id
                content += "<OPTION id=\"user_" + ` wID ` + "_lab_" + ` wrtrLabID ` + "\" value=" + ` wID ` + ">" + wName + "</OPTION>"

            content += '''
							</SELECT>
							
							<BR/>
							<INPUT style="margin-top:10px;" TYPE="checkbox" onClick="selectAll(this.id, 'writers_target_list')" id="select_all_writer_chkbx"> Select All</INPUT>
						</TD>
					</TR>
					
					<TR>
						<TD class="detailedView_value" colspan="3">
							Add new members to this project:
						</TD>
					</TR>
					
					<TR>
						<TD class="detailedView_value" colspan="3">
							Laboratory:&nbsp;&nbsp;&nbsp;&nbsp;
			
							<SELECT id="labList" name="labs" onChange="showLabMembersList()">
							'''
            # fetch lab list - Updated August 90/7: Fetch ALL labs, with any access - then if a read-only lab has members with higher access, would show these members in list
            #labs = lHandler.findAllLabs('Writer', '<=')
            labs = lHandler.findAllLabs()

            # sort lab names alphabetically
            labNames = []
            labsDict = {}  # name, id

            for labID in labs.keys():
                labName = labs[labID]
                labNames.append(labName)
                labsDict[labName] = labID

            labNames.sort()

            currLab = projectOwner.getLab()
            currLabID = currLab.getID()

            #for labID in labs.keys():
            for labName in labNames:
                #labName = labs[labID]
                labID = labsDict[labName]

                if labID == currLabID:
                    content += "<OPTION SELECTED id='" + ` labID ` + "' NAME='lab_optn' value=" + ` labName ` + ">" + labName + "</OPTION>"
                else:
                    content += "<OPTION id='" + ` labID ` + "' NAME='lab_optn' value=" + ` labName ` + ">" + labName + "</OPTION>"

            content += '''
							</SELECT>
						</TD>
					</TR>
					
					<TR>
						<TD width="100px">
							'''

            # For each lab, print a list of its members
            for labID in labs.keys():

                # First, fetch a list of users
                # These are **User instances** - need to get their names and IDs for comparison

                # August 9/07: Don't fetch only writers, fetch readers too - it's up to the project owner to grant them access to the project
                #writers = uHandler.findAllMembersInCategory('Writer', True, '<=', labID)
                writers = uHandler.findAllMembersInCategory(
                    'Reader', True, '<=', labID)
                writersDict = {}  # name, uid
                writersObjDict = {}  # id, User object

                # Fetch user IDs and sort their names alphabetically
                for writer in writers:
                    name = writer.getFullName()
                    uid = writer.getUserID()
                    labID = (writer.getLab()).getID()
                    writersDict[name] = uid
                    writersObjDict[uid] = writer

                names = writersDict.keys()
                names.sort()

                # Show members for one lab at a time
                if labID == currLabID:
                    display = "inline"
                else:
                    display = "none"

                content += "<SELECT MULTIPLE id=\"lab_source_list_" + ` labID ` + "\" name=\"labSourceMembers_" + ` labID ` + "\" SIZE=\"10\" style=\"display:" + display + "\">"

                for name in names:
                    uid = writersDict[name]
                    labID = writersObjDict[uid].getLab().getID()

                    if uid not in currReaderIDs and uid not in currWriterIDs:
                        #content += "<OPTION value=" + `uid` + ">" + name + "</OPTION>"
                        content += "<OPTION id=\"user_" + ` uid ` + "_lab_" + ` labID ` + "\" value=" + ` uid ` + ">" + name + "</OPTION>"

                content += "</SELECT>"

            content += '''
							<BR/>
							<INPUT TYPE="checkbox" style="margin-top:8px" onClick="selectAll(this.id, 'lab_source_list_' + getSelectedLab())" id="add_all_chkbx"> Select All Members</INPUT>
						</TD>

						<TD colspan="2" style="vertical-align:top">
							Add selected members to:
							
							<P style="font-size:9pt; margin-top:5px;">
								<input type="radio" id="access_level_radio_read" name="access_levels" value="read" checked>Readers list</INPUT><BR/> 
								<input type="radio" id="access_level_radio_write" name="access_levels" value="write">Writers list</INPUT><BR/>
								<input style="margin-top:8px" onclick="addMembers('lab_source_list_' + getSelectedLab(), getSelectedRole('1'))" value="Go" type="button"></INPUT>
								<BR/>
							</P>

						</TD>
					</TR>
				</TABLE>
			</FORM>
			'''

            content += gOut.printFooter()

            page_content = content % (
                hostname + "cgi/project_request_handler.py",
                project.getNumber(), project.getNumber(), project.getName(),
                project.getDescription())

            print "Content-type:text/html"  # THIS IS PERMANENT; DO NOT REMOVE
            print  # DITTO
            print page_content
Ejemplo n.º 9
0
    def saveLab(self, form):

        db = self.__db
        cursor = self.__cursor
        hostname = self.__hostname

        #print "Content-type:text/html"		# TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!!
        #print					# DITTO
        #print `form`

        # Handlers and mappers
        lHandler = LabHandler(db, cursor)
        ucMapper = UserCategoryMapper(db, cursor)
        category_Name_ID_Map = ucMapper.mapCategoryNameToID()

        # Get form values
        labID = int(form.getvalue("labID"))
        lab = Laboratory(
            labID
        )  # here need to use the default constructor and not findLabByID, because lab is being updated and need a fresh instance and set its attributes to new values

        newName = form.getvalue("labName")
        newLabHead = form.getvalue("labHead")
        newLabCode = form.getvalue("labCode").upper()
        newDescr = form.getvalue("description")
        newAddr = form.getvalue("address")
        newAccess = form.getvalue("system_access_level")
        newAccLev = category_Name_ID_Map[newAccess]

        # change database values
        try:
            lHandler.setLabName(labID, newName)
            lHandler.setLabHead(labID, newLabHead)
            lHandler.setLabCode(labID, newLabCode)
            lHandler.setLabDescription(labID, newDescr)
            lHandler.setLabAccessLevel(labID, newAccLev)
            lHandler.setLocation(labID, newAddr)

            #######################
            # update members!
            #######################

            newMembers = form.getlist("labMembers")
            lHandler.updateLabMembers(labID, newMembers)

            # change object values
            lab.setName(newName)
            lab.setLabHead(newLabHead)
            lab.setLabCode(newLabCode)
            lab.setDescription(newDescr)
            lab.setAddress(newAddr)
            lab.setDefaultAccessLevel(newAccess)

            # return to detailed view
            self.printLabInfo('view', lab)
            #utils.redirect(hostname + "User.php?View=5&Lab=" + `labID` + "&fd=" + filename)

        except DuplicateLabCodeException:

            newLab = Laboratory(labID, newName, newDescr, newAccess, newAddr,
                                newLabHead, newLabCode)

            d = DuplicateLabCodeException()
            self.printLabInfo('edit', newLab, d.err_code())
Ejemplo n.º 10
0
    def saveUser(self, form):

        db = self.__db
        cursor = self.__cursor
        hostname = self.__hostname

        #print "Content-type:text/html"		# TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!!
        #print					# DITTO
        #print `form`

        uHandler = UserHandler(db, cursor)
        lHandler = LabHandler(db, cursor)
        pHandler = ProjectDatabaseHandler(db, cursor)

        ucMapper = UserCategoryMapper(db, cursor)
        category_ID_Name_Map = ucMapper.mapCategoryIDToName()

        newProps = {}

        # Get form values
        userID = int(form.getvalue("userID"))
        newUser = uHandler.getUserByID(userID)

        labID = int(form.getvalue("labs"))
        tmpLab = lHandler.findLabByID(labID)

        # rest of user properties
        username = form.getvalue("username")
        firstName = form.getvalue("firstName")
        lastName = form.getvalue("lastName")
        description = firstName + " " + lastName
        email = form.getvalue("email")
        category = category_ID_Name_Map[int(
            form.getvalue("system_access_level"))]

        newProps["labID"] = labID
        newProps["username"] = username
        newProps["firstname"] = firstName
        newProps["lastname"] = lastName
        newProps["description"] = description
        newProps["email"] = email
        newProps["category"] = category

        try:
            # Now do an update on database level AND on class level:
            uHandler.updateUserProperties(userID, newProps)  # database update

            # Interface level
            newUser.setUsername(username)
            newUser.setFirstName(firstName)
            newUser.setLastName(lastName)
            newUser.setDescription(description)
            newUser.setEmail(email)
            newUser.setLab(tmpLab)
            newUser.setCategory(category)

            # update list of user's projects
            if form.has_key("userProjectsReadonly"):
                # list of IDs
                readonlyProjects = utils.unique(
                    form.getlist("userProjectsReadonly"))
                pHandler.updateUserProjects(userID, readonlyProjects, 'Reader')
            else:
                # safe to assume should delete projects?
                pHandler.deleteMemberProjects(userID, 'Reader')

            if form.has_key("userProjectsWrite"):
                writeProjects = utils.unique(form.getlist("userProjectsWrite"))
                pHandler.updateUserProjects(userID, writeProjects, 'Writer')
            else:
                # safe to assume should delete projects?
                pHandler.deleteMemberProjects(userID, 'Writer')

            # think about this
            #newUser.setReadProjects(readProjects)
            #newUser.setWriteProjects(writeProjects)

            # return to detailed view
            self.printUserInfo('view', newUser)
            #utils.redirect(hostname + "User.php?View=3&fd=" + filename)

        except DuplicateUsernameException:

            # return to the view with input values and error message
            # Need to construct a dummy User instance to save form values for error output on the next page (otherwise they're lost as soon as Submit is pressed and creation view is exited)
            newLab = lHandler.findLabByID(labID)
            newUser = User(userID, username, firstName, lastName, description,
                           newLab, category, email, "")

            self.printUserInfo('edit', newUser, "Dup_un")
Ejemplo n.º 11
0
    def addUser(self, form):

        db = self.__db
        cursor = self.__cursor
        hostname = self.__hostname
        mail_server = self.__mail_server  # August 19, 2011

        mail_programmer = self.__mail_programmer  # July 30, 2010
        mail_biologist = self.__mail_biologist
        mail_admin = self.__mail_admin

        #print "Content-type:text/html"		# TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!!
        #print					# DITTO
        #print `form`

        uHandler = UserHandler(db, cursor)
        lHandler = LabHandler(db, cursor)
        pHandler = ProjectDatabaseHandler(db, cursor)

        ucMapper = UserCategoryMapper(db, cursor)
        category_Name_ID_Map = ucMapper.mapCategoryNameToID()

        # Get form values
        labID = int(form.getvalue("labs"))
        username = form.getvalue("username")

        firstName = form.getvalue("firstName")
        lastName = form.getvalue("lastName")
        description = firstName + " " + lastName

        to_email = form.getvalue("email")

        from_email = mail_admin

        # Change July 30, 2010 - random password generator
        #passwd = form.getvalue("password")

        chars = string.letters + string.digits
        passwd = ""

        for i in range(10):
            passwd += choice(chars)

        # System access level: Lab default or override?
        #if form.getvalue("privChoiceRadio") == 'override':
        accessLevel = category_Name_ID_Map[form.getvalue(
            "system_access_level")]
        #else:
        #accessLevel = lHandler.findDefaultAccessLevel(labID)

        newProps = {}

        try:
            # Insert User information
            userID = uHandler.insertUser(username, firstName, lastName,
                                         description, accessLevel, to_email,
                                         passwd, labID)
            #newUser = uHandler.getUserByID(userID)
            tmpLab = lHandler.findLabByID(labID)
            #print tmpLab.getName()

            # Insert Project info
            # Sept. 11/07: Differentiate between user categories Reader and Writer - different field names
            if form.has_key("userProjectsReadonly"):
                # list of IDs
                readonlyProjects = utils.unique(
                    form.getlist("userProjectsReadonly"))
                #print `readonlyProjects`
                pHandler.insertMemberProjects(userID, readonlyProjects,
                                              'Reader')

            elif form.has_key("userProjectsReadonlyWrite"):
                # list of IDs
                readonlyProjects = utils.unique(
                    form.getlist("userProjectsReadonlyWrite"))
                #print `readonlyProjects`
                pHandler.insertMemberProjects(userID, readonlyProjects,
                                              'Reader')

            # Write projects exist only for Writers
            if form.has_key("userProjectsWrite"):
                writeProjects = utils.unique(form.getlist("userProjectsWrite"))
                pHandler.insertMemberProjects(userID, writeProjects, 'Writer')

            # don't assign projects to a User instance - will retrieve them from db in output function
            newUser = User(userID, username, firstName, lastName,
                           description, tmpLab,
                           form.getvalue("system_access_level"), to_email,
                           passwd, [], [])

            email_subject = "OpenFreezer User Account"

            msg = email.MIMEMultipart.MIMEMultipart('alternative')

            msg['Subject'] = email_subject
            msg['To'] = to_email

            msgText = "Hi " + firstName + ",<BR><BR>An OpenFreezer account has been created for you.&nbsp;&nbsp;Your access level is " + form.getvalue(
                "system_access_level") + ", so you can "

            if form.getvalue("system_access_level") == 'Reader':
                msgText += "search for clones.&nbsp;&nbsp;If you wish to add/modify reagents or create projects, please contact the administrator to upgrade your access level.<BR>"

            elif form.getvalue("system_access_level") == 'Writer':
                msgText += "search, add, and modify reagents.&nbsp;&nbsp;If you wish to create projects, please contact the administrator to upgrade your access level.<BR>"

            elif form.getvalue("system_access_level") == 'Creator':
                msgText += "search for clones, add and modify reagents, as well as create your own projects.<BR>"

            #####################################################
            # CHANGE TEXT AS NEEDED
            #####################################################

            msgText += "<BR>The URL to access the system is <a href='" + hostname + "'>" + hostname + "</a>.&nbsp;&nbsp;Your username is <b>" + username + "</b>, and your temporary password is <b>" + passwd + "</b>.&nbsp;&nbsp;Please <u>change the temporary password as soon as you log into the website</u> - you can do it through the 'Change your password' link under the 'User Management' menu section.<BR><BR>Please refer to http://openfreezer.org for additional support.<BR><BR>Sincerely,<BR>OpenFreezer  support team.<BR><BR><span style='font-family:Courier; font-size:10pt;'><HR>This is an automatically generated e-mail message.&nbsp;&nbsp;Please do not reply to this e-mail.&nbsp;&nbsp;All questions should be directed to your local administrator.</span>"

            msgText = email.MIMEText.MIMEText(msgText, 'html')
            msg.attach(msgText)

            server = smtplib.SMTP(mail_server)
            server.set_debuglevel(1)

            server.sendmail(from_email, [to_email], msg.as_string())
            server.quit()

            self.printUserInfo('view', newUser)

        except DeletedUserException:

            # Without asking too many questions, reactivate the deleted user and overwrite his/her attributes with the form input values
            userID = uHandler.findUserIDByUsername(username)

            newProps["firstname"] = firstName
            newProps["lastname"] = lastName
            newProps["description"] = description
            newProps["email"] = email
            newProps["status"] = "ACTIVE"
            newProps["password"] = passwd

            # Insert new database values and create new object
            uHandler.updateUserProperties(userID, newProps)  # database update
            newUser = uHandler.getUserByID(userID)

            # Insert Project info
            readProjects = []
            writeProjects = []

            if form.has_key("userProjectsReadonly"):
                # list of IDs
                readonlyProjects = form.getlist("userProjectsReadonly")

                for r in readonlyProjects:
                    pHandler.addProjectMember(r, userID, 'Reader')

                    #tmpReadProject = pHandler.findPacket(r)
                    #readProjects.append(tmpReadProject)
                    #newUser.addProject(tmpReadProject, 'read')

            if form.has_key("userProjectsWrite"):
                writeProjects = form.getlist("userProjectsWrite")

                for w in writeProjects:
                    pHandler.addProjectMember(w, userID, 'Writer')

                    #tmpWriteProject = pHandler.findPacket(w)
                    #writeProjects.append(tmpWriteProject)
                    #newUser.addProject(tmpWriteProject, 'write')

            #newUser.setReadProjects(readProjects)
            #newUser.setWriteProjects(writeProjects)

            self.printUserInfo('view', newUser)
            #utils.redirect(hostname + "User.php?View=3&fd=" + filename)

        except DuplicateUsernameException:

            # return to the view with input values and error message
            # Need to construct a dummy User instance to save form values for error output on the next page (otherwise they're lost as soon as Submit is pressed and creation view is exited)
            newLab = lHandler.findLabByID(labID)
            newUser = User(0, username, firstName, lastName, description,
                           newLab, "", email, passwd)

            self.printUserInfo('create', newUser)
Ejemplo n.º 12
0
	def printLabInfo(self, cmd, newLab, errCode=""):
		dbConn = DatabaseConn()
		hostname = dbConn.getHostname()		# to define form action URL
		
		db = dbConn.databaseConnect()
		cursor = db.cursor()
		
		uHandler = UserHandler(db, cursor)
		lHandler = LabHandler(db, cursor)
		
		currUser = Session.getUser()
		
		gOut = GeneralOutputClass()

		if cmd == 'view':

			labID = newLab.getID()
			labHead = newLab.getLabHead()
			labName = newLab.getName()
			labCode = newLab.getLabCode()
			labDescr = newLab.getDescription()
			address = newLab.getAddress()
			accessLevel = newLab.getDefaultAccessLevel()
			
			# Determine if 'Delete' button should be disabled - if there are members in the lab, disallow deletion
			labMembers = lHandler.findMembers(labID)

			delete_disabled = True

			if len(labMembers) == 0:
				delete_disabled = False
			
			# Only allow modification by admin
			modify_disabled = True
			
			# July 3/07: Can further disallow modification of labs other than the one currUser belongs to; however, this might be too restrictive.  Keep it in the back of our minds but out of the website for now.
			#if (currUser.getCategory() == 'Admin') and (currUser.getLab().getID() == labID):
			if (currUser.getCategory() == 'Admin'):
				modify_disabled = False
			
			#content = gOut.printHeader() + gOut.printMainMenu()
			content = gOut.printHeader()
			
			content += '''
				<FORM name="lab_form" method="POST" action="%s">
			
					<!-- pass current user as hidden form field -->
					<INPUT type="hidden" ID="curr_username_hidden" NAME="curr_username"'''
					
			content += "value=\"" + currUser.getFullName() + "\">"
			
			content += '''
					<TABLE width="775px" cellpadding="5px" cellspacing="5px" class="detailedView_tbl">
						<TR>
							<TD colspan="6" class="detailedView_heading" style="padding-left:250px">
								LABORATORY DETAILS PAGE
								'''
			content += "<INPUT TYPE=\"submit\" style=\"margin-left:50px;\" name=\"modify_lab\" value=\"Change Lab Info\""
			
			if modify_disabled:
				content += " disabled>"
			else:
				content += ">"
							
			content += "<INPUT TYPE=\"submit\" style=\"margin-left:2px;\" name=\"delete_lab\" value=\"Delete Lab\" onClick=\"return verifyDeleteLab()\""
			
			if modify_disabled or delete_disabled:
				content += " disabled>"
			else:
				content += ">"
				
			content += '''
							</TD>

						</TR>
					
						<TR>
							<TD class="projectDetailedViewName">
								Name:
							</TD>

							<TD class="detailedView_value" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="labName" value="%s">

								<!-- lab ID a hidden value -->
								<INPUT TYPE="hidden" name="labID" value="%d">
							</TD>
						</TR>

						<TR>
							<TD class="projectDetailedViewName">
								Lab head:
							</TD>

							<TD class="detailedView_value" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="labHead" value="%s">
							</TD>
						</TR>

						<TR>
							<TD class="projectDetailedViewName">
								Lab ID:
							</TD>

							<TD class="detailedView_value" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="labCode" value="%s">
							</TD>
						</TR>
						
						<TR>
							<TD class="projectDetailedViewName">
								Description:
							</TD>

							<TD class="detailedView_value" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="labDescription" value="%s">
							</TD>
						</TR>

						<TR>
							<TD class="projectDetailedViewName">
								Location:
							</TD>

							<TD class="detailedView_value" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="address" value="%s">
							</TD>
						</TR>
						
						<TR>
							<TD class="projectDetailedViewName" style="white-space:nowrap">
								Default access level:
							</TD>

							<TD class="detailedView_value" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="access" value="%s">
							</TD>
						</TR>
						
						<!-- Members -->
						<TR>
							<TD class="projectDetailedViewName">
								Members:
							</TD>
							
							<TD class="detailedView_value" style="width:400px">
								<UL>
							'''
			
			content += "<INPUT type=\"hidden\" id=\"view_user_hidden\" name=\"view_user\">"
				
			for member in labMembers:
				mName = member.getFullName()
				memberID = member.getUserID()
				#content += "<LI>" + mName
				content += "<LI>"
				content += "<span class=\"linkShow\" onClick=\"redirectToUserDetailedView(" + `memberID` + ");\">" + mName + "</span>"
				content += "</LI>"

			content += '''
								</UL>
							</TD>
						</TR>
					</TABLE>
				</FORM>
				
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
			</div>
			'''
				
			content += gOut.printFooter()
			
			page_content = content % (hostname + "cgi/user_request_handler.py", labName, labName, labID,  labHead, labHead, labCode, labCode, labDescr, labDescr, address, address, accessLevel, accessLevel)

			print "Content-type:text/html"		# THIS IS PERMANENT; DO NOT REMOVE
			print					# DITTO
			print page_content

		elif cmd == 'edit':
			
			labID = newLab.getID()
			labName = newLab.getName()
			labHead = newLab.getLabHead()
			labCode = newLab.getLabCode()
			labDescr = newLab.getDescription()
			address = newLab.getAddress()
			accLev = newLab.getDefaultAccessLevel()
			
			# Disable name modification if there are members in lab
			labMembers = lHandler.findMembers(labID)

			name_readonly = True

			if len(labMembers) == 0:
				name_readonly = False

			# hide/show duplicate lab code warning
			if errCode == 14:
				dup_lab_code_warn_display = "inline"
			else:
				dup_lab_code_warn_display = "none"
			
			#content = gOut.printHeader() + gOut.printMainMenu()
			content = gOut.printHeader()
			
			content += '''
				<FORM name="user_form" method="POST" action="%s">

					<!-- pass current user as hidden form field -->
					<INPUT type="hidden" ID="curr_username_hidden" NAME="curr_username"'''
			content += "value=\"" + currUser.getFullName() + "\">"

			content += '''
					<TABLE width="760px" cellpadding="5px" cellspacing="5px" style="border:1px solid black" frame="box" rules="rows">
					<TR>
						<TD colspan="3" style="padding-left:100px; text-align:center">
							<span style="color:#0000FF; font-weight:bold">CHANGE LABORATORY INFORMATION</span>
							<INPUT TYPE="submit" style="margin-left:180px;" name="save_lab" value="Save" onClick="selectAllElements('labMembersList'); return checkLab();">
							<INPUT TYPE="submit" style="margin-left:20px;" name="cancel_lab" value="Cancel">
						</TD>
					</TR>
					
					<TR>
						<TD class="projectDetailedViewName">
							Name:
						</TD>

						<TD class="detailedView_value" style="width:400px" colspan="2">
							'''
							
			if name_readonly:
				content += "<INPUT TYPE=\"text\" size=\"50px\" id=\"lab_name\" name=\"labName\" value=\"%s\" readonly>"
			else:
				content += "<INPUT TYPE=\"text\" size=\"50px\" id=\"lab_name\" name=\"labName\" value=\"%s\">"
				
			content += '''
							<!-- lab ID hidden value -->
							<INPUT TYPE="hidden" name="labID" value="%d">
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Lab head:
						</TD>

						<TD class="detailedView_value" style="width:400px" colspan="2">
							<INPUT TYPE="text" size="50px" id="lab_head" name="labHead" value="%s">
						</TD>
					</TR>
					
					<TR>
						<TD class="projectDetailedViewName">
							Lab ID:
						</TD>

						<TD class="detailedView_value" style="width:400px" colspan="2">
							<INPUT TYPE="text" size="50px" id="lab_id" name="labCode" value="%s">
							<BR>
							<SPAN id="dup_labcode_warning" style="vertical-align:bottom; color:#FF0000; display:%s">This identifier already exists.  Please specify a different lab ID.</SPAN>
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Description:
						</TD>

						<TD class="detailedView_value" colspan="2">
							<INPUT TYPE="text" size="50px" id="lab_descr" name="description" value="%s">
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Location:
						</TD>

						<TD class="detailedView_value" colspan="2">
							<INPUT TYPE="text" size="50px" id="lab_location" name="address" value="%s">
						</TD>
					</TR>
										
					<TR>
						<TD style="width:50px; vertical-align:top; padding-top:10px; white-space:nowrap; font-size:8pt">
							Default access level:
						</TD>

						<TD style="font-size:8pt; vertical-align:top; width:50px;">
						'''
			# Determine which category radio button should be checked
			ucHandler = UserCategoryHandler(db, cursor)
			categories = ucHandler.findAllCategories()
			
			for cID in categories.keys():
				cat = categories[cID]
				content += "<INPUT TYPE=\"RADIO\" name=\"system_access_level\" value=\"" + cat + "\" style=\"margin-top:8px; font-size:8pt\" onClick=\"showHideProjectAccess()\""
				
				if cat == accLev:
					content += " checked"
				
				content += ">" + cat + "<BR/>"
				
			content += '''
						</TD>
					</TR>
					
					<!-- Members - allow deletion -->
					<TR>
						<TD style="width:50px; vertical-align:top; padding-top:10px; font-size:8pt">
							<b>Members:</b>
							<BR/><BR/>
							Select one or more members to remove them from the system.<BR/><BR/>
							
							(hold down CTRL key to select multiple names)
						</TD>

						<TD style="font-size:8pt; vertical-align:top; width:50px;">
							<SELECT MULTIPLE SIZE="10" ID="labMembersList" NAME="labMembers">
						'''
			members = lHandler.findMembers(labID)
			
			for  member in members:
				mName = member.getFullName()
				memberID = member.getUserID()
				
				content += "<OPTION value=\"" + `memberID` + "\">" + mName + "</OPTION>"
			
			content += '''
							</SELECT>
						</TD>
						
						<TD>
							<INPUT TYPE=\"button\" onClick=\"removeLabMembers('labMembersList')\" value=\"Remove Selected Members\">
						</TD>
					</TR>
				</TABLE>
			</FORM>
			
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
		
			</div>
			'''
			
			content += gOut.printFooter()
			
			page_content = content % (hostname + "cgi/user_request_handler.py", labName, labID, labHead, labCode, dup_lab_code_warn_display, labDescr, address)

			print "Content-type:text/html"		# THIS IS PERMANENT; DO NOT REMOVE
			print					# DITTO
			print page_content
Ejemplo n.º 13
0
	def printUserInfo(self, cmd, user, errCode=""):
		
		dbConn = DatabaseConn()
		hostname = dbConn.getHostname()		# to define form action URL
		
		db = dbConn.databaseConnect()
		cursor = db.cursor()
		
		uHandler = UserHandler(db, cursor)
		lHandler = LabHandler(db, cursor)
		pHandler = ProjectDatabaseHandler(db, cursor)
		
		ucMapper = UserCategoryMapper(db, cursor)
		category_ID_Name_Map = ucMapper.mapCategoryIDToName()
		category_Name_ID_Map = ucMapper.mapCategoryNameToID()

		currUser = Session.getUser()
		
		gOut = GeneralOutputClass()
					
		if cmd =='create':
			
			username = user.getUsername()
			firstname = user.getFirstName()
			lastname = user.getLastName()
			email = user.getEmail()
			passwd = user.getPassword()
			
			lab = user.getLab()
			uLabID = lab.getID()
			uLabName = lab.getName()
			
			labs = lHandler.findAllLabs()

			# changed Aug. 18/08 - new format
			#content = gOut.printHeader() + gOut.printMainMenu()
			content = gOut.printHeader()
			
			content += '''
				<FORM NAME="create_user_form" METHOD="POST" ACTION="%s" onSubmit="return verifyAddUser();">

					<!-- pass current user as hidden form field -->
					<INPUT type="hidden" ID="curr_username_hidden" NAME="curr_username"'''
					
			content += "value=\"" + currUser.getFullName() + "\">"
			
			content += '''
					<TABLE width="760px" cellpadding="5" cellspacing="5">

						<TH colspan="4" style="color:#0000FF; border-top:1px groove black; border-bottom: 1px groove black; padding-top: 10px; padding-top:5px;">
							ADD NEW USER
							<P style="color:#FF0000; font-weight:normal; font-size:8pt; margin-top:5px;">Fields in red marked with an asterisk (<span style="font-size:9pt; color:#FF0000;">*</span>) are mandatory</P>
						</TH>

						<TR>
							<TD style="width:150px; vertical-align:top; padding-top:10px; color:#FF0000;">
								Laboratory:&nbsp;<sup style="font-size:10pt; color:#FF0000;">*</sup>
							</TD>

							<TD style="vertical-align:top; padding-top:10px">
								<SELECT id="labList" name="labs">
									<OPTION>Select Lab</OPTION>
								'''
			# sort labs by name
			labSortedDict = {}		# will store (labName, labID) tuples 
			labNames = []			# just hold lab names
			
			for labID in labs.keys():
				labName = labs[labID]
				labNames.append(labName)
				labSortedDict[labName] = labID
				
			labNames.sort()

			#for labID in labs.keys():
			for labName in labNames:
				labID = labSortedDict[labName]
				labName = labs[labID]
				content += "<OPTION ID=\"" + `labID` + "\" NAME=\"lab_optn\" VALUE=\"" + `labID` + "\""
				
				if labID == uLabID:
					content += " SELECTED>" + labName
				else:
					content += ">" + labName
					
				content += "</OPTION>"
					
			content += '''
								</SELECT>
								<BR/>
								<P id="lab_warning" style="color:#FF0000; display:none">Please select a laboratory name from the dropdown list above.</P>
							</TD>
						</TR>

						<TR>
							<TD class="createViewColName" style="color:#FF0000;">
								Username:&nbsp;<sup style="font-size:10pt; color:#FF0000;">*</sup>
							</TD>

							<TD class="createViewColValue">
								<INPUT TYPE="TEXT" SIZE="35px" id="user_name" NAME="username" VALUE="%s"/>
								<BR/>
								<!-- Warning anchor -->
								<a name="w1" style="text-decoration:none; font-weight:normal; font-size:8pt">
								
								<P id="dup_uname_warning" style="color:#FF0000; display:inline">This username already exists.  Please specify a different username.</P>
								</a>
							</TD>

							<TD style="font-size:8pt">
								Alphanumeric string up to 10 characters used to log into the system.
							</TD>
						</TR>

						<TR>
							<TD class="createViewColName" style="color:#FF0000;">
								Password:&nbsp;<sup style="font-size:10pt; color:#FF0000;">*</sup>
							</TD>

							<TD class="createViewColValue">
								<INPUT TYPE="PASSWORD" SIZE="35px" id="passwd" NAME="password" VALUE="%s"/>
							</TD>
						</TR>

						<TR>
							<TD class="createViewColName" style="color:#FF0000;">
								First name:&nbsp;<sup style="font-size:10pt; color:#FF0000;">*</sup>
							</TD>

							<TD class="createViewColValue">
								<INPUT TYPE="TEXT" SIZE="35px" id="first_name" NAME="firstName" VALUE="%s"/>
							</TD>
						</TR>

						<TR>
							<TD class="createViewColName" style="color:#FF0000;">
								Last name:&nbsp;<sup style="font-size:10pt; color:#FF0000;">*</sup>
							</TD>

							<TD class="createViewColName">
								<INPUT TYPE="TEXT" SIZE="35px" id="last_name" NAME="lastName" VALUE="%s"/>
							</TD>
						</TR>

						<TR>
							<TD class="createViewColName">
								Email:
							</TD>

							<TD class="createViewColValue">
								<INPUT TYPE="TEXT" SIZE="35px" id="e_mail" NAME="email" VALUE="%s"/>
							</TD>
						</TR>

						<TR>
							<TD>
								Access Level:
							</TD>

							<TD class="createViewColName"  colspan="3">
								<INPUT TYPE="RADIO" name="system_access_level" value="Reader" style="margin-top:8px; font-size:9pt" checked>Reader<BR/>
								<INPUT TYPE="RADIO" name="system_access_level" value="Writer" style="margin-top:8px; font-size:9pt">Writer<BR/>
								<INPUT TYPE="RADIO" name="system_access_level" value="Creator" style="margin-top:8px; font-size:9pt">Creator<BR/>
								<INPUT TYPE="RADIO" name="system_access_level" value="Admin" style="margin-top:8px; font-size:9pt">Admin<BR/>
							</TD>
						</TR>				

						<TR id="project_access">
							<TD colspan="4">
								<TABLE width="100%%">
									<TR>
										<TD colspan="4" style="border-top:1px groove black; border-bottom:1px groove black; padding-top:8px; font-size:8pt; font-weight:bold">
											Grant project access permissions to this user:
										</TD>
									</TR>

									<TR>
										<TD style="width:210px">
											<SELECT id="packetList" name="packets" multiple size="15">
											'''
			# PRINT PROJECT LIST
			projects = pHandler.findAllProjects()
			
			for project in projects:
				projectNumber = project.getNumber()	
				projectName = project.getName()
				
				tmpProject = `projectNumber` + ": " + projectName
				
				content += "<OPTION value=\"" + `projectNumber` + "\">" + tmpProject + "</OPTION>"
				
			content += '''
											</SELECT>
											<BR/>
											<INPUT TYPE="checkbox" style="margin-top:10px; font-size:8pt;" onClick="selectAll(this.id, 'packetList')" id="add_all_chkbx"> Select All</INPUT>
										</TD>

										<TD style="vertical-align:top" colspan="3">
											<span style="font-size:8pt; font-weight:bold">User's access level to selected projects:<BR/></span>
											<input type="radio" id="access_level_radio_read" name="access_levels" value="read" style="margin-top:8px; font-size:9pt" checked>Read-Only &nbsp;&nbsp;&nbsp;<BR/>
											<input type="radio" id="access_level_radio_write" name="access_levels" value="write" style="margin-top:5px; font-size:9pt">Write &nbsp;&nbsp;&nbsp;<BR/>
											<input style="margin-top:8px" onclick="addProjects('packetList', getSelectedRole('1'))" value="Go" type="button"></INPUT>

											<P style="font-size:8pt; border-top:1px groove black; padding-top:10px; padding-bottom:5px; margin-top:10px">
											Access levels: <BR/>
											<span style="font-size: 8pt; margin-left: 9px; font-weight:bold; ">&#45; Read-Only:</span>  May view reagents in a project but may NOT modify them or add new reagents<BR/>

											<span style="font-size: 8pt; margin-left: 9px; font-weight:bold;">&#45; Write:</span>  May create and modify reagents in a project but may NOT change project details or add/remove members to/from the project<BR/>
											</P>
										</TD>
									</TR>

									<TR>
										<TD colspan="4" style="border-top:1px groove black; border-bottom:1px groove black; font-size:8pt; font-weight:bold">
											User's current project access privileges:
										</TD>
									</TR>

									<TR>
										<TD style="border-right:1px solid black; font-size:8pt">
											<B>Read-Only</B><BR/>
											<SELECT id="user_projects_readonly" name="userProjectsReadonly" style="margin-top:5px" multiple size="12">
											'''
			# August 10/07: Default reader access to all on public projects
			publicProjects = pHandler.findAllProjects('FALSE')

			for proj in publicProjects: 
				pID = proj.getNumber()
				pName = proj.getName();
				
				# concatenate project ID and name in the form '1:parent'
				tmpDescr = `pID` + ": " + pName
				
				content += "<OPTION VALUE=\"" + `pID` + "\">" + tmpDescr + "</OPTION>"

			content += '''
											</SELECT><BR/>
											<INPUT style="margin-top:10px;" TYPE="checkbox" onClick="selectAll(this.id, 'user_projects_readonly')" id="select_all_reader_chkbx"> Select All</INPUT>
										</TD>

										<TD style="text-align:center; width:100px; border-right: 1px solid black; padding-left:20px; padding-right:20px;">
											<input onclick="addProjects('user_projects_readonly', 'write')" value="   Make Writeable >>" type="button"></INPUT><BR/>
											<input style="margin-top:30px;" onclick="addProjects('user_projects_write', 'read')" value="<< Make Read-Only" type="button"></INPUT><BR/>
											<input style="margin-top:30px;" onclick="addProjects('user_projects_write'); addProjects('user_projects_readonly')" value="Remove Selected" type="button"></INPUT>
										</TD>

										<TD style="padding-left:50px; font-size:8pt">
											<B>Write</B><BR/>
											<SELECT id="user_projects_write" name="userProjectsWrite" style="margin-top:5px" multiple size="12"></SELECT><BR/>
											<INPUT style="margin-top:10px;" TYPE="checkbox" onClick="selectAll(this.id, 'user_projects_write')" id="select_all_writer_chkbx"> Select All</INPUT>
										</TD>
									</TR>
								</TABLE>
							</TD>
						</TR>

						<TR>
							<TD colspan="4" style="border-top:1px groove black; border-bottom:1px groove black">
								<INPUT TYPE="SUBMIT" id="addUser" NAME="add_user" VALUE="Add User" onClick="selectAllElements('user_projects_readonly'); selectAllElements('user_projects_write');">
							</TD>
						</TR>
					</TABLE>
				</FORM>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				
				</div>
				'''
				
			content += gOut.printFooter()
			
			page_content = content % (hostname + "cgi/user_request_handler.py", username, passwd, firstname, lastname, email)
			
			print "Content-type:text/html"		# THIS IS PERMANENT; DO NOT REMOVE
			print					# DITTO
			print page_content

		elif cmd == 'view':

			userID = user.getUserID()
			username = user.getUsername()
			firstname = user.getFirstName()
			lastname = user.getLastName()
			email = user.getEmail()
			userCat = user.getCategory()
			lab = user.getLab()
			labID = lab.getID()
			labName = lab.getName()
			
			# Only allow modification by admin
			modify_disabled = True
			
			if (currUser.getCategory() == 'Admin'):
				modify_disabled = False
			
			content = gOut.printHeader()
			#content += gOut.printMainMenu()
			
			content += '''
				<FORM name="user_form" method="POST" action="%s">
							
					<!-- pass current user as hidden form field -->
					<INPUT type="hidden" ID="curr_username_hidden" NAME="curr_username"'''
					
			content += "value=\"" + currUser.getFullName() + "\">"
			
			content += '''
					<TABLE width="767px" style="margin-left:2px" cellpadding="5px" cellspacing="5px" class="detailedView_tbl" border="1" frame="box" rules="none">
						<TR>
							<TD colspan="6" class="detailedView_heading" style="padding-left:265px">
								USER DETAILS PAGE
								'''
			content += "<INPUT TYPE=\"submit\" style=\"margin-left:50px;\" name=\"modify_user\" value=\"Change User Details\""
			
			if modify_disabled:
				content += " disabled>"
			else:
				content += ">"
						
			content += "<INPUT TYPE=\"submit\" style=\"margin-left:2px;\" name=\"delete_user\" value=\"Delete User\" onClick=\"return verifyDeleteUser();\""
			
			if modify_disabled:
				content += " disabled>"
			else:
				content += ">"

				
			content += '''
							</TD>

						</TR>

						<TR>
							<TD class="projectDetailedViewName" width="50px">
								Username:
							</TD>

							<TD class="detailedView_value" colspan="2" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="username" value="%s">

								<!-- user ID a hidden value -->
								<INPUT TYPE="hidden" name="userID" value="%d">
							</TD>
						</TR>

						<TR>
							<TD class="projectDetailedViewName" width="50px">
								First Name:
							</TD>

							<TD class="detailedView_value" colspan="2" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="firstName" value="%s">
							</TD>
						</TR>

						<TR>
							<TD class="projectDetailedViewName" width="50px">
								Last Name:
							</TD>

							<TD class="detailedView_value" colspan="2" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="lastName" value="%s">
							</TD>
						</TR>
						
						<TR>
							<TD class="projectDetailedViewName" width="50px">
								Laboratory:
							</TD>

							<TD class="detailedView_value" colspan="2" style="width:400px">
							'''
			if modify_disabled:
				content += labName
			else:
				content += "<span class=\"linkShow\" onClick=\"redirectToLabView(" + `labID` + ");\">" + labName + "</span>"
			
			content += '''
								<INPUT TYPE="hidden" name="labID" value="%d">
								<INPUT type="hidden" id="view_lab_hidden" name="view_lab">
							</TD>
						</TR>
						
						<TR>
							<TD class="projectDetailedViewName" width="50px">
								Email:
							</TD>

							<TD class="detailedView_value" colspan="2" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="email" value="%s">
							</TD>
						</TR>
						
						<TR>
							<TD class="projectDetailedViewName" width="50px">
								Access Level:
							</TD>

							<TD class="detailedView_value" colspan="2" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="system_access_level" value="%d">
							</TD>
						</TR>
						
						
						<TR>
							<TD class="projectDetailedViewName" width="50px">
								Projects:
							</TD>
							
						</TR>
						
						<TR>
							<TD style="font-weight:bold; font-size:8pt; width:250px" colspan="2">
								Read-Only:
							</TD>
							
							<TD style="font-weight:bold; font-size:8pt">
								Write:
							</TD>
						</TR>

						<TR>
							<TD style="vertical-align:top;" colspan="2">
								<UL>
								'''
			# show projects for the user
			publicProj = pHandler.findAllProjects("FALSE")
			readOnlyProj = pHandler.findMemberProjects(userID, 'Reader')
			readProj = utils.merge(publicProj, readOnlyProj)
			writeProj = pHandler.findMemberProjects(userID, 'Writer')
			
			# sort read projects
			readKeys = []
			readSorted = {}
			
			for r in readProj:
				rProjectID = r.getNumber()
				readKeys.append(rProjectID)
				readSorted[rProjectID] = r
			
			readKeys = utils.unique(readKeys)
			readKeys.sort()
			
			#for r in readProj:
			for rProjectID in readKeys:
				#rProjectID = r.getNumber()
				r = readSorted[rProjectID]
				rProjectName = r.getName()
				rProjectOwner = r.getOwner()

				try:
					rOwnerName = rProjectOwner.getLastName()
				except AttributeError:
					rOwnerName = ""

				#content += "<LI>" + `rProjectID` + ": " + rOwnerName + ": " + rProjectName
				
				content += "<LI>"
				content += "<span class=\"linkShow\" onClick=\"redirectToProjectDetailedView(" + `rProjectID` + ");\">" + `rProjectID` + ": " + rOwnerName + ": " + rProjectName + "</span>"
				content += "</LI>"

					
			content += '''
								</UL>
							</TD>
							
							<TD style="vertical-align:top;">
								<UL>
								'''
			# sort write projects
			writeKeys = []
			writeSorted = {}
			
			for w in writeProj:
				wProjectID = w.getNumber()
				writeKeys.append(wProjectID)
				writeSorted[wProjectID] = w
				
			writeKeys = utils.unique(writeKeys)
			writeKeys.sort()
			
			#for w in writeProj:
			for wProjectID in writeKeys:
				#wProjectID = w.getNumber()
				w = writeSorted[wProjectID]
				wProjectName = w.getName()
				wProjectOwner = w.getOwner()
				wOwnerName = wProjectOwner.getLastName()
										
				#content += "<LI>" + `wProjectID` + ": " + wProjectName
			
				content += "<LI>"
				content += "<span class=\"linkShow\" onClick=\"redirectToProjectDetailedView(" + `wProjectID` + ");\">" + `wProjectID` + ": " + wOwnerName + ": " + wProjectName + "</span>"
				content += "</LI>"

			content += '''
								</UL>
							</TD>
						</TR>
					</TABLE>
				</FORM>
				
				<FORM id="viewProjectForm" method="POST" action="%s">
					<INPUT type="hidden" id="view_packet_hidden" name="view_packet">
					<INPUT type="hidden" ID="curr_userid_hidden" NAME="curr_user_id" value="%d">
				</FORM>
				
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				
			</div>
			'''

			content += gOut.printFooter()
		
			page_content = content % (hostname + "cgi/user_request_handler.py", username, username, userID, firstname, firstname, lastname, lastname, labID, email, email, userCat, category_Name_ID_Map[userCat], hostname + "cgi/project_request_handler.py", currUser.getUserID())

			print "Content-type:text/html"		# 
			print					# DITTO
			print page_content

		elif cmd == 'edit':
					
			userID = user.getUserID()
			username = user.getUsername()
			firstname = user.getFirstName()
			lastname = user.getLastName()
			email = user.getEmail()
			passwd = user.getPassword()
			userCat = user.getCategory()
			
			lab = user.getLab()
			uLabID = lab.getID()
			labName = lab.getName()
			
			labs = lHandler.findAllLabs()
		
			if errCode == "Dup_un":
				un_warn_display = "inline"
			else:
				un_warn_display = "none"
			
			
			content = gOut.printHeader()
			#content += gOut.printMainMenu()
			
			content += '''
				<FORM name="user_form" method="POST" action="%s" onSubmit="return verifyWriteProjects();">
					
					<!-- pass current user as hidden form field -->
					<INPUT type="hidden" ID="curr_username_hidden" NAME="curr_username"'''
					
			content += "value=\"" + currUser.getFullName() + "\">"

			content += '''
					<TABLE width="760px" cellpadding="5px" cellspacing="5px" style="border:1px solid black" frame="box" rules="rows">
					<TR>
						<TD colspan="3" style="padding-left:200px; text-align:center">
							<span style="color:#0000FF; font-weight:bold">CHANGE USER INFORMATION</span>
							<INPUT TYPE="submit" style="margin-left:50px;" name="save_user" value="Save" onClick="selectAllElements('user_projects_readonly'); selectAllElements('user_projects_write');">
							<INPUT TYPE="submit" style="margin-left:20px;" name="cancel_user" value="Cancel">
						</TD>
					</TR>
					
					<TR>
						<TD class="projectDetailedViewName">
							Username:
						</TD>

						<TD class="detailedView_value" style="width:400px">
							<INPUT TYPE="text" size="50px" name="username" value="%s">
							<BR/>
							
							<!-- Warning anchor -->
							<a name="w1" style="text-decoration:none; font-weight:normal; font-size:8pt">
							<P id="dup_uname_warning" style="color:#FF0000; display:%s">This username already exists.  Please specify a different username.</P>
							</a>
							
							<!-- user ID hidden value -->
							<INPUT TYPE="hidden" name="userID" value="%d">
						</TD>
					</TR>


					<TR>
						<TD class="projectDetailedViewName">
							Laboratory:
						</TD>

						<TD style="vertical-align:top; padding-top:10px">
							<SELECT id="labList" name="labs">
							'''
			# sort labs by name
			labSortedDict = {}		# will store (labName, labID) tuples 
			labNames = []			# just hold lab names
			
			for labID in labs.keys():
				labName = labs[labID]
				labNames.append(labName)
				labSortedDict[labName] = labID
				
			labNames.sort()
			
			#for labID in labs.keys():
			for labName in labNames:
				labID = labSortedDict[labName]
				labName = labs[labID]
				content += "<OPTION ID=\"" + `labID` + "\" NAME=\"lab_optn\" VALUE=\"" + `labID` + "\""
				
				if labID == uLabID:
					content += " SELECTED>" + labName
				else:
					content += ">" + labName
					
				content += "</OPTION>"
					
			content += '''
							</SELECT>
						</TD>
					</TR>
					
					<TR>
						<TD class="projectDetailedViewName">
							First Name:
						</TD>

						<TD class="detailedView_value" colspan="2">
							<INPUT TYPE="text" size="50px" name="firstName" value="%s">
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Last Name:
						</TD>

						<TD class="detailedView_value" colspan="2">
							<INPUT TYPE="text" size="50px" name="lastName" value="%s">
						</TD>
					</TR>
										
					<TR>
						<TD class="projectDetailedViewName">
							Email:
						</TD>

						<TD class="detailedView_value" colspan="2">
							<INPUT TYPE="text" size="50px" name="email" value="%s">
						</TD>
					</TR>
					
					<TR>
						<TD class="projectDetailedViewName">
							Access Level:
						</TD>
						
						<TD class="detailedView_value" colspan="2">
							<SELECT ID="user_category" NAME="system_access_level">
						'''
			ucHandler = UserCategoryHandler(db, cursor)
			categories = ucHandler.findAllCategories()
			
			for cID in categories.keys():
				
				if categories[cID] == userCat:
					content += "<OPTION VALUE=\"" + `cID` + "\" SELECTED>" + categories[cID] + "</OPTION>"
				else:
					content += "<OPTION VALUE=\"" + `cID` + "\">" + categories[cID] + "</OPTION>"

			# Don't allow addition of Writeable projects to Readers thru Modify view
			if userCat == 'Reader':
				write_disabled = True
			else:
				write_disabled = False
				
			content += '''
							</SELECT>
						</TD>
					</TR>
					
					<TR>
						<TD class="detailedView_value" colspan="3">
							Projects user has access to:
						</TD>
					</TR>

					<TR>
						<td colspan="3">
							<table width="700px">
								<tr>
									<TD colspan="2" style="font-size:8pt; vertical-align:top"">
										Read-Only
									</TD>
									
									<TD style="font-size:8pt; vertical-align:top">
									'''
			if not write_disabled:
				content += "Write"
			else:
				content += "&nbsp;"
			
			content += '''
									</TD>
								</TR>
								
								<TR>
									<TD style="">
										<SELECT id="user_projects_readonly" name="userProjectsReadonly" style="margin-top:5px" multiple size="12">
										'''
										
			# show projects for the user
			readProj = pHandler.findMemberProjects(userID, 'Reader')
			writeProj = pHandler.findMemberProjects(userID, 'Writer')
		
			for r in readProj:
				rProjectID = r.getNumber()
				rProjectName = r.getName()
				
				content += "<OPTION name=\"project_read\" value=\"" + `rProjectID` + "\">" + `rProjectID` + ": " + rProjectName + "</OPTION>"
					
			content += '''
										</SELECT>
										<BR/>
										
										<INPUT TYPE="checkbox" style="margin-top:10px;" onClick="selectAll(this.id, 'user_projects_readonly')" id="select_all_reader_chkbx"> Select All</INPUT>
						'''
			if not write_disabled:
				content += '''
									</TD>
			
									<TD style="text-align:center; padding-right:15px;">
			
										<input onclick="addProjects('user_projects_readonly', 'write')" value="   Make Writeable >>" type="button"></INPUT><BR/>
								
										<input style="margin-top:30px;" onclick="addProjects('user_projects_write', 'read')" value="<< Make Read-Only" type="button"></INPUT><BR/>
			
										&nbsp;<input type="button" style="margin-top:30px;" value="Remove" onclick="removeUserProjects();"></INPUT>
									</TD>
									'''
			
			else:
				content += '''
						&nbsp;<input type="button" value="Remove Selected" onclick="removeUserProjects();"></INPUT>
						'''
			if not write_disabled:
				content += '''	
									<TD style="font-size:8pt">
								
										<SELECT id="user_projects_write" name="userProjectsWrite" style="margin-top:5px" multiple size="12">
										'''
				for w in writeProj:
					wProjectID = w.getNumber()
					wProjectName = w.getName()
					
					content += "<OPTION name=\"project_write\" value=\"" + `wProjectID` + "\">" + `wProjectID` + ": " + wProjectName + "</OPTION>"
						
				content += '''
										</SELECT><BR/>
										
										<INPUT style="margin-top:10px;" TYPE="checkbox" onClick="selectAll(this.id, 'user_projects_write')" id="select_all_writer_chkbx"> Select All</INPUT>
									</TD>
									'''
				
			content += '''
								</TR>
							</table>
						</td>
					</tr>
						
					<TR>
						<TD class="detailedView_value" colspan="3">
							Add new projects:
						</TD>
					</TR>
					
					<TR>
						<TD colspan="3">
							<TABLE>
								<TR>
									<TD>
										<SELECT multiple ID="packetList">
							'''
			# Fetch the list of read and write projects for this user and extract their IDs
			readProjID = []	# list of numerical IDs of read projects
			
			for r in readProj:
				rNum = r.getNumber()
				readProjID.append(rNum)
							
			writeProjID = []
			
			for w in writeProjID:
				wNum = w.getNumber()
				writeProjID.append(wNum)
			
			allPackets = pHandler.findAllProjects()
			
			for p in allPackets:
				pID = p.getNumber()
				pName = p.getName()
				pOwner = p.getOwner()
			
				#print "Content-type:text/html"		# TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!!
				#print					# DITTO
				#print `pOwner`

				# update March 11, 2011
				try:
					lastName = pOwner.getLastName()
				except AttributeError:
					lastName = ""

				#pDesc = `pID` + " : " + pOwner + " : " + pName
				pDesc = `pID` + " : " + lastName + " : " + pName
				
				if not pID in readProjID and not pID in writeProjID:
					content += "<OPTION VALUE=\"" + `pID` + "\">" + pDesc

			content += '''
										</SELECT>
										<BR>
										<INPUT TYPE="checkbox" style="margin-top:10px; font-size:8pt;" onClick="selectAll(this.id, 'packetList')" id="add_all_chkbx"> Select All</INPUT>
						'''

			if not write_disabled:
				content += '''	
									</TD>
								
									<TD style="vertical-align:top">
										<span style="font-size:8pt; font-weight:bold">User's access level to selected projects:<BR/></span>
										<input type="radio" id="access_level_radio_read" name="access_levels" value="read" style="margin-top:8px; font-size:9pt" checked>Read-Only &nbsp;&nbsp;&nbsp;<BR/>
										<input type="radio" id="access_level_radio_write" name="access_levels" value="write" style="margin-top:5px; font-size:9pt">Write &nbsp;&nbsp;&nbsp;<BR/>
										<input style="margin-top:8px" onclick="addProjects('packetList', getSelectedRole('1'))" value="Add project" type="button"></INPUT>
									</TD>
								</TABLE>
							</TD>
						</TR>
						'''
			else:
				content += '''
						<input style="margin-left:5px; margin-top:8px" onclick="addProjects('packetList', 'read')" value="Add project" type="button"></INPUT>
						'''

			content += '''
					</TR>
				</TABLE>
			</FORM>
			
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>	
			</div>
			'''
				
			content += gOut.printFooter()
		
			page_content = content % (hostname + "cgi/user_request_handler.py", username, un_warn_display, userID, firstname, lastname, email)
		
			print "Content-type:text/html"		# THIS IS PERMANENT; DO NOT REMOVE
			print					# DITTO
			print page_content