コード例 #1
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() `)
コード例 #2
0
ファイル: container.py プロジェクト: mbikyaw/OpenFreezer
 def setContainerLab(self, cLab):
     newLab = Laboratory(cLab)
     self.__cont_lab = newLab
コード例 #3
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())
コード例 #4
0
import dash
from laboratory import Laboratory
import dash_bootstrap_components as dbc
from flask_caching import Cache
from laboratory.processing import Sample

lab = Laboratory()

stylesheets = [
    {
        'href': 'https://use.fontawesome.com/releases/v5.15.1/css/all.css',
        'rel': 'stylesheet',
        'integrity':
        'sha384-vp86vTRFVJgpjF9jiIGPEEqYqlDwgyBgEF109VFjmqGmIY/Y4HV4d3Gp2irVfcrp',
        'crossorigin': 'anonymous'
    },
    "assets\css\sb-admin-2.css",
    dbc.themes.DARKLY,
]

external_scripts = [
    "assets\js\jquery.min.js",
    "assets\js\\bootstrap.bundle.min.js",
    "assets\js\jquery.easing.min.js",
    "assets\js\sb-admin-2.js",
]

app = dash.Dash(
    __name__,
    external_stylesheets=stylesheets,
    external_scripts=external_scripts,