示例#1
0
文件: cal.py 项目: farooqseeru/Glams
    def index(self):
        username = checkPassword()
        if not username:
            return """<meta http-equiv="refresh" content="0;url=/home/login" />"""  #This takes the unknown user to login
        article = "<p id='notification'></p>"
        article += calTag
        rightbar = "<p style='position:absolute;padding:3px 5px;display: block;width: 120px;'><a  class='button-link' onclick='updatecal();'>Update</a></p>"
        style = """
#notification{
    display:none;
    padding:5px;
    margin:3px;
    background-color:#FFFF66;
    webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;}
    """
        javascript = """
var t;
function notify(data){
    $('#notification').html(data);
    $('#notification').show();
    var fadefunc="$('#notification').hide('fade', {}, 200);";
    t=setTimeout(fadefunc,15000);
}
function updatecal(){$.post('/calendar/ajax/updatecalendar/', function(data){ notify(data);});}
    """
        resources = "<style type='text/css'>" + style + '</style><script type="text/javascript">' + javascript + '</script>'
        return glamsTemplate(article,
                             username,
                             resources=resources,
                             rightbar=rightbar)
示例#2
0
文件: info.py 项目: farooqseeru/Glams
    def index(self):
        username=checkPassword()
        animalinfo=E.div(
                    E.h2('Breeding'),
                    E.ul(
                        E.li("To see if an animal is pregnant, weigh her every 7 days."),
                        E.li("To get an accurate estimate of the birth day, check every day."),
                        E.li("You can look at anatomical features before P5 to identify date of birth."),
                        E.li("The founder line is the first generation. You should mate descendants with the founder line often, to reduce genetic variability."),
                        E.li("Breed females between P56 (8 weeks) to P120 (4 months).  Younger females between P42 (6 weeks) to P56 can be breed but won't be good mothers.  Females older than 4 months can breed, but you must use the 'Whitten effect' by dropping male waste in the cage.  This should induce estrous cycle in female after 1 to 2 days."),
                        E.li("Breed males after they reach sexual maturity at P56 (8 weeks). ")
                    ),
                     E.h2('Weaning'),
                     E.ul(
                         E.li("Wean at P19 to P23.  They need to be able to reach the water at the top of the cage."),
                         E.li("The vet staff will wean at P23. This costs a lot of money, so wean before then."),
                         E.li("To wean, separate out genders in different cages, don't put more than 4 in a cage or they will fight."),
                         E.li("When weaning, look for teeth that curve upwards and sac them.  If you catch early enough, trim teeth with scissors.")
                     ),
                     E.h2('Genotyping'),
                     E.ul(
                         E.li("To genotype, clip P3-P7 toes, mail to ",E.a({'href':'http://www.transnetyx.com/'},'Transnetyx'),"."),
                         E.li("To determine if td-Tomato positive and PV-Cre positive, shine a green laser at the base of the tail and look for fluorescence.")
                     )
                )
        glamsQA=E.div(
                    E.h2('What do the colors over animal names mean?'),
                    E.div("Color indicates gender. Blue means male, red means female, and yellow indicates 'neither' or 'unknown'."),
                    E.h2('I just started GLAMS.  How do I log in?'),
                    E.div("The administrator user name is 'admin' and the default password is 'password'."),
                )
        article=E.div(
                E.div({'class':'tabs'},
                    E.ul(E.li(E.a({'href':'#tab1'},'GLAMS Q&A')), 
                         E.li(E.a({'href':'#tab2'},'Animal Information')),
                         E.li(E.a({'href':'#tab3'},'')),
                         E.li(E.a({'href':'#tab4'},''))),
                    E.div(            
                        E.div({'id':'tab1'},glamsQA),
                        E.div({'id':'tab2'},animalinfo),
                        E.div({'id':'tab3'}),
                        E.div({'id':'tab4'}),
                    )
                )
            )
        article=etree.tostring(article, pretty_print=True)
        style="""
        li{display:block;}
        """
        javascript=""" 
            $(document).ready(function(){
               $( ".tabs" ).tabs();
            });

        """
        resources="<style type='text/css'>"+style+'</style><script type="text/javascript">'+javascript+'</script>'
        return glamsTemplate(article,username, resources=resources)
示例#3
0
def getHome(username):
    table=E.table({'id':'create_view'},
              E.tr(E.th('Create'),E.th('View')),
              E.tr(
                  E.td({'id':'create'}),
                    E.p('Nothing to create yet!'),
                  E.td({'id':'view'}),
                      E.p(E.a({'href':'/database/'},'Database')),
                      #E.p(E.a({'href':'/calendar/'},'Calendar')) #KE leaving this commented until I can completely integrate the calendar
              )
          )

    article=E.div(E.h1(username,E.span('(',E.a({'href':'/home/logout/'},'log out'),')')),table)
    resources=   """<link rel="stylesheet" type="text/css" href="/support/css/home/home.css" />"""
    
    article=etree.tostring(article, pretty_print=True)
    return glamsTemplate(article, username, resources=resources)
示例#4
0
def getAdmin():
    username = checkPassword()
    if not username or username != 'admin':
        return """<meta http-equiv="refresh" content="0;url=/home/login" />"""


########################  CREATE ARTICLE ###############################################################################

###### ADMIN
    changepass = E.div(
        E.h2('Change admin password:'******'Current password:'******'name': 'oldpassword',
                      'type': 'password'
                  })),
            E.div(E.label('New password:'******'name': 'newpassword1',
                      'type': 'password'
                  })),
            E.div(E.label('Confirm new password:'******'name': 'newpassword2',
                      'type': 'password'
                  })),
            E.a(
                {
                    'class': 'button-link',
                    'onclick': "changepassword($(this).parent().serialize());"
                }, 'Change password')))

    changeemail = E.div(
        E.h2('Change admin email address:'),
        E.form(
            E.div(
                E.label('Password:'******'name': 'password',
                    'id': 'emailpassword',
                    'type': 'password'
                })),
            E.div(
                E.label('New email:'),
                E.input({
                    'name': 'newemail1',
                    'id': 'newemail1',
                    'type': 'text'
                })),
            E.div(
                E.label('Confirm new email:'),
                E.input({
                    'name': 'newemail2',
                    'id': 'newemail2',
                    'type': 'text'
                })),
            E.a(
                {
                    'class': 'button-link',
                    'onclick': "changeemail($(this).parent().serialize());"
                }, 'Change email')))

    ###### USERS
    adduser = E.div(
        E.h2('Add User:'******'id': 'adduserform'},
               E.div(E.label('User name:'),
                     E.input({
                         'name': 'newusername',
                         'type': 'text'
                     })),
               E.div(E.label('Email address:'),
                     E.input({
                         'name': 'email',
                         'type': 'text'
                     })),
               E.div(E.label('User password:'******'name': 'newpassword1',
                         'type': 'password'
                     })),
               E.div(E.label('Confirm user password:'******'name': 'newpassword2',
                         'type': 'password'
                     })),
               E.a(
                   {
                       'class': 'button-link',
                       'onclick': "adduser($(this).parent().serialize());"
                   }, 'Add user')))

    userlist = E.select({'name': 'user'})
    vals = db.execute("SELECT name FROM lab_members")
    if vals == []:
        userlist.append(E.option(''))
    else:
        for val in vals:
            userlist.append(E.option(val[0]))
    removeuser = E.div(
        E.h2('Remove User:'******'User name:'), userlist),
            E.a(
                {
                    'class': 'button-link',
                    'onclick': "removeuser($(this).parent().serialize());"
                }, 'Remove user')))

    ##### GENES
    addgene = E.div(
        E.h2('Add Gene:'),
        E.form(
            E.div(E.label('Gene Name:'),
                  E.input({
                      'name': 'genename',
                      'type': 'text'
                  })),
            E.div(
                E.label('Wild Type Presence:'),
                E.select({'name': 'genedefaultstatus'}, E.option('+'),
                         E.option('-'))),
            E.a(
                {
                    'class': 'button-link',
                    'onclick': "addgene($(this).parent().serialize());"
                }, 'Add gene')))
    genelist = E.select({'name': 'gene'})
    vals = db.execute("SELECT name FROM genes")
    if vals == []:
        genelist.append(E.option(''))
    else:
        for val in vals:
            genelist.append(E.option(val[0]))
    removegene = E.div(
        E.h2('Remove Gene:'),
        E.form(
            E.div(E.label('Gene Name:'), genelist),
            E.a(
                {
                    'class': 'button-link',
                    'onclick': "removegene($(this).parent().serialize());"
                }, 'Remove gene')))

    ##### STRAINS
    addstrain = E.div(
        E.h2('Add Strain:'),
        E.form(
            E.div(E.label('Strain Name:'),
                  E.input({
                      'name': 'strainname',
                      'type': 'text'
                  })),
            E.a(
                {
                    'class': 'button-link',
                    'onclick': "addstrain($(this).parent().serialize());"
                }, 'Add Strain')))
    strainlist = E.select({'name': 'strain'})
    vals = db.execute("SELECT name FROM strains")
    if vals == []:
        strainlist.append(E.option(''))
    else:
        for val in vals:
            strainlist.append(E.option(val[0]))
    removestrain = E.div(
        E.h2('Remove strain:'),
        E.form({'class': 'form'}, E.div(E.label('Strain Name:'), strainlist),
               E.a(
                   {
                       'class': 'button-link',
                       'onclick': "removestrain($(this).parent().serialize());"
                   }, 'Remove strain')))

    ### PUT ALL THE PIECES TOGETHER
    article = E.div(
        E.div({'id': 'notification'}, ''),
        E.div({'class': 'tabs'},
              E.ul(E.li(E.a({'href': '#tab1'}, 'Admin')),
                   E.li(E.a({'href': '#tab2'}, 'Users')),
                   E.li(E.a({'href': '#tab3'}, 'Genes')),
                   E.li(E.a({'href': '#tab4'}, 'Strains'))),
              E.div(
                  E.div({'id': 'tab1'}, changepass, changeemail),
                  E.div({'id': 'tab2'}, adduser, removeuser),
                  E.div({'id': 'tab3'}, addgene, removegene),
                  E.div({'id': 'tab4'}, addstrain, removestrain),
              )))

    article = etree.tostring(article, pretty_print=True)

    ####################### STYLE AND JAVASCRIPT #############################################################################
    style = """ 
h2    {
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #D8D8D8;
    }
input{
    webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;
    padding: 4px;
}

table{
    width:500px;
    margin:10px;
}
#notification{
    display:none;
    padding:5px;
    margin:3px;
    background-color:#FFFF66;
    webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;}
label{
    display: inline-block;
    float: left;
    clear: left;
    width: 200px;
    margin-right: 10px;
    white-space: nowrap;}
    
form .button-link{
    margin-left:0px;
}
form div{margin-bottom:10px;}
    """
    javascript = """ 
var t;
function notify(data){
    $('#notification').html(data);
    $('#notification').show();
    var fadefunc="$('#notification').hide('fade', {}, 200);";
    t=setTimeout(fadefunc,15000);
}


function changepassword(fields){
    $.post('/home/ajax/changepassword/',{fields:fields}, function(data){ notify(data);});}
function changeemail(fields){
    alert(fields);
    $.post('/home/ajax/changeemail/',{fields:fields}, function(data){ notify(data);});}
    
function adduser(fields){
    $.post('/admin/adduser/',{fields:fields}, function(data){ notify(data);});}
function removeuser(fields){
    $.post('/admin/removeuser/',{fields:fields}, function(data){ notify(data);});}
    

 

function addgene(fields){
    $.post('/admin/addgene/',{fields:fields}, function(data){ notify(data);refreshgenes();});}
function removegene(fields){
    $.post('/admin/removegene/',{fields:fields}, function(data){ notify(data);refreshgenes();});}
function refreshgenes(){
    $.post('/admin/refreshgenes/', function(data){ $("select[name='gene']").html(data);});}  
function addstrain(fields){
    $.post('/admin/addstrain/',{fields:fields}, function(data){ notify(data);refreshstrains();});}
function removestrain(fields){
    $.post('/admin/removestrain/',{fields:fields}, function(data){ notify(data);refreshstrains();});}
function refreshstrains(){
    $.post('/admin/refreshstrains/', function(data){ $("select[name='strain']").html(data);});}  


$(document).ready(function(){
   $( ".tabs" ).tabs();
});

    """
    resources = "<style type='text/css'>" + style + '</style><script type="text/javascript">' + javascript + '</script>'
    return glamsTemplate(article, username, resources=resources)
示例#5
0
    def index(self):
        username=checkPassword()
        if not username:
            return """<meta http-equiv="refresh" content="0;url=/home/login" />"""
            
        style=""" 
            #db {
                 border-collapse: collapse;
                 border: 0;
             }
             table{
                  width:100%;
                  text-align:center;
             }
            #db th{
                 white-space: nowrap;
                background: none repeat scroll 0 0 #B0C4DE;  
                font-weight: normal;
            }
            #db th:hover {background-color: #C0D0E5
            }
            
            #db td{ 
                    font-family: arial,sans-serif;
                    overflow: hidden; 
                    text-overflow: ellipsis;
                    /*word-wrap: break-word; */
                    white-space: nowrap; 
            }

            td{
                font-size: small; 
                padding:6px;
                line-height:120%;
            }
            td a{
                text-decoration: none;
            }
            h1{
                text-align:center;
            }


            """
        javascript="""
        $( document ).ready(function(){
            
        });
        """

        resources= "<style type='text/css'>"+style+"</style>"
        resources+="<script type='text/javascript'>"+javascript+"</script>"
        resources+="<link rel='stylesheet' href='/support/css/dragtable.css' type='text/css' />"
        resources+="<script type='text/javascript' src='/support/javascript/jquery.dragtable.js'></script>"
        resources+="<script type='text/javascript' src='/support/javascript/experimentlog.js'></script>" 
        resources+="<script type='text/javascript' src='/support/javascript/jquery.tablesorter.js'></script> "
        
        
        resources+="<link rel='stylesheet' type='text/css' href='/support/thirdparty/tooltipster/css/tooltipster.css' />"
        resources+="<script type='text/javascript' src='/support/thirdparty/tooltipster/js/jquery.tooltipster.js'></script>"
        
#        viewtype,cols=db.execute("SELECT viewtype, columns FROM lab_members WHERE name=%s",(username,))[0]
#        if viewtype is None:
#            cols=['mousename','']
#        else:
#            cols=cols.split(',')
#        if viewtype=='mouse':
#            c=['checked','']
#        else:
#            c=['','checked']
        article= """<h1 style='margin-bottom: 20px;'>Experiment log</h1>
                    <table id='db' class="tablesorter"></table>"""
        
        
        rightbar= ''
        return glamsTemplate(article, username, resources=resources, rightbar=rightbar)
示例#6
0
def getsettings():
    username=checkPassword()
    if not username:
        return """<meta http-equiv="refresh" content="0;url=/home/login" />"""
########################  CREATE ARTICLE ###############################################################################
    changepass=E.div(E.h2('Change password:'******'Current password:'******'name':'oldpassword', 'type':'password'})),
                             E.div(E.label('New password:'******'name':'newpassword1', 'type':'password'})),
                             E.div(E.label('Confirm new password:'******'name':'newpassword2', 'type':'password'})),
                             E.a({'class':'button-link','onclick':"changepassword($(this).parent().serialize());"},'Change password')))
                             
    changeemail=E.div(E.h2('Change email address:'),
                      E.form(
                                 E.div(E.label('Password:'******'name':'password','id':'emailpassword', 'type':'password'})),
                                 E.div(E.label('New email:'),  E.input({'name':'newemail1', 'id':'newemail1','type':'text'})),
                                 E.div(E.label('Confirm new email:'),  E.input({'name':'newemail2', 'id':'newemail2','type':'text'})),
                                 E.a({'class':'button-link','onclick':"changeemail($(this).parent().serialize());"},'Change email')))
    article=E.div(
                E.div({'id':'notification'},''),
                    E.div(changepass, changeemail))
    article=etree.tostring(article, pretty_print=True)
                                
                            
####################### STYLE AND JAVASCRIPT #############################################################################            
    style=""" 
h2    {
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #D8D8D8;}
input{
    webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;
    padding: 4px;}

table{
    width:500px;
    margin:10px;}
    
#notification{
    display:none;
    padding:5px;
    margin:3px;
    background-color:#FFFF66;
    webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;}
    
label{
    display: inline-block;
    float: left;
    clear: left;
    width: 200px;
    margin-right: 10px;
    white-space: nowrap;}
    
form .button-link{margin-left:0px;}
    
form div{margin-bottom:10px;}

    """
    javascript=""" 
var t;
function notify(data){
    $('#notification').html(data);
    $('#notification').show();
    var fadefunc="$('#notification').hide('fade', {}, 200);";
    t=setTimeout(fadefunc,15000);
}
function changepassword(fields){
    $.post('/home/ajax/changepassword/',{fields:fields}, function(data){ notify(data);});}
function changeemail(fields){
    $.post('/home/ajax/changeemail/',{fields:fields}, function(data){ notify(data);});}

    """
    resources="<style type='text/css'>"+style+'</style><script type="text/javascript">'+javascript+'</script>'
    return glamsTemplate(article, username, resources=resources)
示例#7
0
 def logout(self):
     logout()
     return glamsTemplate("Logged out sucessfully!")
示例#8
0
def getlogin(args):

    ###################################################################################################################
    #                                                                                             STYLE AND JAVASCRIPT
    ###################################################################################################################
    style = """ 
h1 {
    text-align: center; 
    border-bottom:1px solid #D8D8D8;
    padding-bottom: 6px;
}
h1 span {
    font-size: large;
    text-shadow: none;
}
table{
    padding-top:10px;
    width:100%;
    table-layout:fixed;
        -webkit-border-radius: 10px; 
    -moz-border-radius: 10px; 
    border-radius: 10px; 
}

table td{
    width:50%;
    vertical-align: top;
    text-align:left;
}
input {
    -webkit-border-radius: 10px; 
    -moz-border-radius: 10px; 
    border-radius: 10px; 
    padding:2px;
}

    """
    javascript = """ 


    """
    resources = "<style type='text/css'>" + style + '</style><script type="text/javascript">' + javascript + '</script>'

    ###################################################################################################################
    #                                                                                             SUBMISSION FORMS
    ###################################################################################################################
    existingUserSubmissionForm = """
                                            <table>
                                                <form method="post" action='/home/login/' autocomplete="off" >
                                                    <tr>
                                                        <td>Username:</td>
                                                        <td><input name="username" type="text"/></td>
                                                    </tr>
                                                    <tr>
                                                        <td>Password:</td>
                                                        <td><input name="password" type="password"  /></td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <input type="submit" value="Submit" />
                                                        </td>
                                                    </tr>
                                                </form>
                                            </table>"""
    ###################################################################################################################
    #                                                                                             ARTICLE
    ###################################################################################################################
    article = """<h1 style="text-align:center">Log In</h1>
                <table style="width: 100%;table-layout: fixed; background:-webkit-linear-gradient(bottom, white, #FCFDFF);">
                    <tr>
                        <td>
                            """ + existingUserSubmissionForm + """
                        </td>
                    </tr>
                </table>"""

    name = checkPassword()  #Check if user already has correct cookie
    if name is not None:
        return """<meta http-equiv="refresh" content="0;url=/home/" />"""
    # else if there wasn't a cookie, or if it didn't have the right values:
    cookie = cherrypy.response.cookie

    ###################################################################################################################
    #                USER LOGIN
    ###################################################################################################################
    if 'username' in args and 'password' in args and args[
            'username'] != '' and args['password'] != '':
        print(args)
        sida = args['username']
        sidb = hashlib.md5(
            (args['password'] + salt).encode('utf-8')).hexdigest()
        if DI.isUser(sida, sidb):
            cookie['sida'] = sida
            cookie['sida']['expires'] = 12 * 30 * 24 * 60 * 60
            cookie['sida']["path"] = "/"
            cookie['sidb'] = sidb
            cookie['sidb']['expires'] = 12 * 30 * 24 * 60 * 60
            cookie['sidb']["path"] = "/"
            cherrypy.request.cookie = cookie
            article = """<meta http-equiv="refresh" content="0;url=/home/" /><h1>Login Sucessful!</h1>"""
        else:
            article = '''<p>Incorrect login.  Please try again.</p>''' + article
    else:
        article = '''<p>Enter username and password.</p>''' + article

    return glamsTemplate(article, name, resources=resources)
示例#9
0
def getAdmin():
    username=checkPassword()
    if not username or username!='admin':
        return """<meta http-equiv="refresh" content="0;url=/home/login" />"""
########################  CREATE ARTICLE ###############################################################################
        
    ###### ADMIN
    changepass=E.div(E.h2('Change admin password:'******'Current password:'******'name':'oldpassword', 'type':'password'})),
                             E.div(E.label('New password:'******'name':'newpassword1', 'type':'password'})),
                             E.div(E.label('Confirm new password:'******'name':'newpassword2', 'type':'password'})),
                             E.a({'class':'button-link','onclick':"changepassword($(this).parent().serialize());"},'Change password')))
                             
    changeemail=E.div(E.h2('Change admin email address:'),
                      E.form(
                                 E.div(E.label('Password:'******'name':'password','id':'emailpassword', 'type':'password'})),
                                 E.div(E.label('New email:'),  E.input({'name':'newemail1', 'id':'newemail1','type':'text'})),
                                 E.div(E.label('Confirm new email:'),  E.input({'name':'newemail2', 'id':'newemail2','type':'text'})),
                                 E.a({'class':'button-link','onclick':"changeemail($(this).parent().serialize());"},'Change email')))
                                 
                                 
                                 
                                 
    ###### USERS
    adduser=E.div(E.h2('Add User:'******'id':'adduserform'},
                             E.div(E.label('User name:'),E.input({'name':'newusername', 'type':'text'})),
                             E.div(E.label('Email address:'),E.input({'name':'email', 'type':'text'})),
                             E.div(E.label('User password:'******'name':'newpassword1', 'type':'password'})),
                             E.div(E.label('Confirm user password:'******'name':'newpassword2', 'type':'password'})),
                             E.a({'class':'button-link','onclick':"adduser($(this).parent().serialize());"},'Add user')))
    
    userlist=E.select({'name':'user'})
    vals=db.execute("SELECT name FROM lab_members")
    if vals==[]:
        userlist.append(E.option(''))
    else:
        for val in vals:
            userlist.append(E.option(val[0]))
    removeuser=E.div(E.h2('Remove User:'******'User name:'),userlist),
                             E.a({'class':'button-link','onclick':"removeuser($(this).parent().serialize());"},'Remove user')))



    
    ##### GENES
    addgene=E.div(E.h2('Add Gene:'),
                  E.form(   
                      E.div(E.label('Gene Name:'),E.input({'name':'genename','type':'text'})),
                      E.div(E.label('Wild Type Presence:'),E.select({'name':'genedefaultstatus'},E.option('+'),E.option('-') )),
                      E.a({'class':'button-link','onclick':"addgene($(this).parent().serialize());"},'Add gene')))
    genelist=E.select({'name':'gene'})
    vals=db.execute("SELECT name FROM genes")
    if vals==[]:
        genelist.append(E.option(''))
    else:
        for val in vals:
            genelist.append(E.option(val[0]))
    removegene=E.div(E.h2('Remove Gene:'),
                  E.form(  
                      E.div(E.label('Gene Name:'),genelist),
                      E.a({'class':'button-link','onclick':"removegene($(this).parent().serialize());"},'Remove gene')))



    ##### STRAINS
    addstrain=E.div(E.h2('Add Strain:'),
                  E.form(
                      E.div(E.label('Strain Name:'),E.input({'name':'strainname','type':'text'})),
                      E.a({'class':'button-link','onclick':"addstrain($(this).parent().serialize());"},'Add Strain')))
    strainlist=E.select({'name':'strain'})
    vals=db.execute("SELECT name FROM strains")
    if vals==[]:
        strainlist.append(E.option(''))
    else:
        for val in vals:
            strainlist.append(E.option(val[0]))
    removestrain=E.div(E.h2('Remove strain:'),
                  E.form({'class':'form'}, 
                         E.div(E.label('Strain Name:'),strainlist),
                         E.a({'class':'button-link','onclick':"removestrain($(this).parent().serialize());"},'Remove strain')))
    
    
    ### PUT ALL THE PIECES TOGETHER
    article=E.div(
                E.div({'id':'notification'},''),
                E.div({'class':'tabs'},
                    E.ul(E.li(E.a({'href':'#tab1'},'Admin')), 
                         E.li(E.a({'href':'#tab2'},'Users')),
                         E.li(E.a({'href':'#tab3'},'Genes')),
                         E.li(E.a({'href':'#tab4'},'Strains'))),
                    E.div(            
                        E.div({'id':'tab1'},changepass, changeemail),
                        E.div({'id':'tab2'},adduser, removeuser),
                        E.div({'id':'tab3'}, addgene,removegene),
                        E.div({'id':'tab4'}, addstrain, removestrain),
                    )
                )
            )
        
    article=etree.tostring(article, pretty_print=True)
                                
                            
####################### STYLE AND JAVASCRIPT #############################################################################            
    style=""" 
h2    {
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #D8D8D8;
    }
input{
    webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;
    padding: 4px;
}

table{
    width:500px;
    margin:10px;
}
#notification{
    display:none;
    padding:5px;
    margin:3px;
    background-color:#FFFF66;
    webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;}
label{
    display: inline-block;
    float: left;
    clear: left;
    width: 200px;
    margin-right: 10px;
    white-space: nowrap;}
    
form .button-link{
    margin-left:0px;
}
form div{margin-bottom:10px;}
    """
    javascript=""" 
var t;
function notify(data){
    $('#notification').html(data);
    $('#notification').show();
    var fadefunc="$('#notification').hide('fade', {}, 200);";
    t=setTimeout(fadefunc,15000);
}


function changepassword(fields){
    $.post('/home/ajax/changepassword/',{fields:fields}, function(data){ notify(data);});}
function changeemail(fields){
    alert(fields);
    $.post('/home/ajax/changeemail/',{fields:fields}, function(data){ notify(data);});}
    
function adduser(fields){
    $.post('/admin/adduser/',{fields:fields}, function(data){ notify(data);});}
function removeuser(fields){
    $.post('/admin/removeuser/',{fields:fields}, function(data){ notify(data);});}
    

 

function addgene(fields){
    $.post('/admin/addgene/',{fields:fields}, function(data){ notify(data);refreshgenes();});}
function removegene(fields){
    $.post('/admin/removegene/',{fields:fields}, function(data){ notify(data);refreshgenes();});}
function refreshgenes(){
    $.post('/admin/refreshgenes/', function(data){ $("select[name='gene']").html(data);});}  
function addstrain(fields){
    $.post('/admin/addstrain/',{fields:fields}, function(data){ notify(data);refreshstrains();});}
function removestrain(fields){
    $.post('/admin/removestrain/',{fields:fields}, function(data){ notify(data);refreshstrains();});}
function refreshstrains(){
    $.post('/admin/refreshstrains/', function(data){ $("select[name='strain']").html(data);});}  


$(document).ready(function(){
   $( ".tabs" ).tabs();
});

    """
    resources="<style type='text/css'>"+style+'</style><script type="text/javascript">'+javascript+'</script>'
    return glamsTemplate(article, username, resources=resources)
示例#10
0
def setup_glams():
    ''' 1) check if config.txt is created.  If it isn't, display a webpage to create one.'''
    print('Setting up glams...')
    try:
        from glams.databaseInterface.connect import importconfig
    except IOError:
        config={'database': 'glams', 'user': '', 'mysql_IP_address': 'localhost', 'calendarTag': '<div></div>', 'password': '', 'salt': '', 'port': '3306'}
        # config.txt doesn't exist.  This means we have to make it.
        from glams.glamsTemplate import glamsTemplate
        article=E.div(E.div({'id':'notification'},''),
                      E.h2('Configure GLAMS:'),
                      E.form(
                             E.div(E.label('MySQL IP address:'), E.input({'name':'mysql_IP_address', 'value':config['mysql_IP_address'],'type':'text'}), E.span('This is the IP address of your MySQL server. Leave as "localhost" if running on this computer. ')),
                             E.div(E.label('MySQL port:'), E.input({'name':'port', 'value':config['port'],'type':'text'}), E.span('This is the port to access your mysql server. This is almost always "3306".' )),
                             E.div(E.label('GLAMS database name:'), E.input({'name':'database', 'value':config['database'],'type':'text'}), E.span('This is the name of the MySQL database (aka schema).  This should be "glams".')),
                             E.div(E.label('GLAMS database salt:'), E.input({'name':'salt', 'value':config['salt'],'type':'text'}), E.span("This should be 5-10 random characters to use as a salt for better password encryption")),
                             E.div(E.label('MySQL user name:'), E.input({'name':'user', 'value':config['user'],'type':'text'}), E.span("Enter the name of the user you created to access the MySQL database.")),
                             E.div(E.label('MySQL password:'******'name':'password', 'value':config['password'],'type':'text'}), E.span("This is the above user's password. WARNING: Do not use your regular lab password.  This password will be saved in a textfile.")),
                             E.a({'class':'button-link','onclick':"config_glams($(this).parent().serialize());"},'Save Configuration')))
        article=etree.tostring(article, pretty_print=True)
        ####################### STYLE AND JAVASCRIPT #############################################################################            
        style=""" 
            h2    {
                margin-bottom: 10px;
                padding-bottom: 5px;
                border-bottom: 1px solid #D8D8D8;
                }
            input{
                webkit-border-radius: 8px;
                -moz-border-radius: 8px;
                border-radius: 8px;
                padding: 4px;
            }
            
            table{
                width:500px;
                margin:10px;
            }
            #notification{
                display:none;
                padding:5px;
                margin:3px;
                background-color:#FFFF66;
                webkit-border-radius: 8px;
                -moz-border-radius: 8px;
                border-radius: 8px;}
            label{
                display: inline-block;
                float: left;
                clear: left;
                width: 200px;
                margin-right: 10px;
                white-space: nowrap;}
                
            form .button-link{
                margin-left:0px;
            }
            form div{margin-bottom:10px;}
                """
        javascript=""" 
            var t;
            function notify(data){
                $('#notification').html(data);
                $('#notification').show();
                var fadefunc="$('#notification').hide('fade', {}, 200);";
                t=setTimeout(fadefunc,15000);
            }
            
            
            function config_glams(fields){
                notify('Testing connection to mysql server...')
                $.post('/ajax/config_glams/',{fields:fields}, function(data){ 
                    notify(data);
                    
                
                });}
            

            
        """
        resources="<style type='text/css'>"+style+'</style><script type="text/javascript">'+javascript+'</script>'
        return glamsTemplate(article, username='******', resources=resources)
示例#11
0
def setup_glams():
    ''' 1) check if config.txt is created.  If it isn't, display a webpage to create one.'''
    print('Setting up glams...')
    try:
        from glams.databaseInterface.connect import importconfig
    except IOError:
        config = {
            'database': 'glams',
            'user': '',
            'mysql_IP_address': 'localhost',
            'calendarTag': '<div></div>',
            'password': '',
            'salt': '',
            'port': '3306'
        }
        # config.txt doesn't exist.  This means we have to make it.
        from glams.glamsTemplate import glamsTemplate
        article = E.div(
            E.div({'id': 'notification'}, ''), E.h2('Configure GLAMS:'),
            E.form(
                E.div(
                    E.label('MySQL IP address:'),
                    E.input({
                        'name': 'mysql_IP_address',
                        'value': config['mysql_IP_address'],
                        'type': 'text'
                    }),
                    E.span(
                        'This is the IP address of your MySQL server. Leave as "localhost" if running on this computer. '
                    )),
                E.div(
                    E.label('MySQL port:'),
                    E.input({
                        'name': 'port',
                        'value': config['port'],
                        'type': 'text'
                    }),
                    E.span(
                        'This is the port to access your mysql server. This is almost always "3306".'
                    )),
                E.div(
                    E.label('GLAMS database name:'),
                    E.input({
                        'name': 'database',
                        'value': config['database'],
                        'type': 'text'
                    }),
                    E.span(
                        'This is the name of the MySQL database (aka schema).  This should be "glams".'
                    )),
                E.div(
                    E.label('GLAMS database salt:'),
                    E.input({
                        'name': 'salt',
                        'value': config['salt'],
                        'type': 'text'
                    }),
                    E.span(
                        "This should be 5-10 random characters to use as a salt for better password encryption"
                    )),
                E.div(
                    E.label('MySQL user name:'),
                    E.input({
                        'name': 'user',
                        'value': config['user'],
                        'type': 'text'
                    }),
                    E.span(
                        "Enter the name of the user you created to access the MySQL database."
                    )),
                E.div(
                    E.label('MySQL password:'******'name': 'password',
                        'value': config['password'],
                        'type': 'text'
                    }),
                    E.span(
                        "This is the above user's password. WARNING: Do not use your regular lab password.  This password will be saved in a textfile."
                    )),
                E.a(
                    {
                        'class': 'button-link',
                        'onclick':
                        "config_glams($(this).parent().serialize());"
                    }, 'Save Configuration')))
        article = etree.tostring(article, pretty_print=True)
        ####################### STYLE AND JAVASCRIPT #############################################################################
        style = """ 
            h2    {
                margin-bottom: 10px;
                padding-bottom: 5px;
                border-bottom: 1px solid #D8D8D8;
                }
            input{
                webkit-border-radius: 8px;
                -moz-border-radius: 8px;
                border-radius: 8px;
                padding: 4px;
            }
            
            table{
                width:500px;
                margin:10px;
            }
            #notification{
                display:none;
                padding:5px;
                margin:3px;
                background-color:#FFFF66;
                webkit-border-radius: 8px;
                -moz-border-radius: 8px;
                border-radius: 8px;}
            label{
                display: inline-block;
                float: left;
                clear: left;
                width: 200px;
                margin-right: 10px;
                white-space: nowrap;}
                
            form .button-link{
                margin-left:0px;
            }
            form div{margin-bottom:10px;}
                """
        javascript = """ 
            var t;
            function notify(data){
                $('#notification').html(data);
                $('#notification').show();
                var fadefunc="$('#notification').hide('fade', {}, 200);";
                t=setTimeout(fadefunc,15000);
            }
            
            
            function config_glams(fields){
                notify('Testing connection to mysql server...')
                $.post('/ajax/config_glams/',{fields:fields}, function(data){ 
                    notify(data);
                    
                
                });}
            

            
        """
        resources = "<style type='text/css'>" + style + '</style><script type="text/javascript">' + javascript + '</script>'
        return glamsTemplate(article, username='******', resources=resources)
示例#12
0
def getlogin(args):
    
###################################################################################################################
#                                                                                             STYLE AND JAVASCRIPT
###################################################################################################################    
    style=""" 
h1 {
    text-align: center; 
    border-bottom:1px solid #D8D8D8;
    padding-bottom: 6px;
}
h1 span {
    font-size: large;
    text-shadow: none;
}
table{
    padding-top:10px;
    width:100%;
    table-layout:fixed;
        -webkit-border-radius: 10px; 
    -moz-border-radius: 10px; 
    border-radius: 10px; 
}

table td{
    width:50%;
    vertical-align: top;
    text-align:left;
}
input {
    -webkit-border-radius: 10px; 
    -moz-border-radius: 10px; 
    border-radius: 10px; 
    padding:2px;
}

    """
    javascript=""" 


    """
    resources="<style type='text/css'>"+style+'</style><script type="text/javascript">'+javascript+'</script>'
    
###################################################################################################################
#                                                                                             SUBMISSION FORMS  
###################################################################################################################           
    existingUserSubmissionForm= """
                                            <table>
                                                <form method="post" action='/home/login/' autocomplete="off" >
                                                    <tr>
                                                        <td>Username:</td>
                                                        <td><input name="username" type="text"/></td>
                                                    </tr>
                                                    <tr>
                                                        <td>Password:</td>
                                                        <td><input name="password" type="password"  /></td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <input type="submit" value="Submit" />
                                                        </td>
                                                    </tr>
                                                </form>
                                            </table>"""
###################################################################################################################
#                                                                                             ARTICLE
###################################################################################################################    
    article="""<h1 style="text-align:center">Log In</h1>
                <table style="width: 100%;table-layout: fixed; background:-webkit-linear-gradient(bottom, white, #FCFDFF);">
                    <tr>
                        <td>
                            """+existingUserSubmissionForm+"""
                        </td>
                    </tr>
                </table>"""

    name=checkPassword() #Check if user already has correct cookie
    if name is not None:
        return """<meta http-equiv="refresh" content="0;url=/home/" />"""
    # else if there wasn't a cookie, or if it didn't have the right values:
    cookie = cherrypy.response.cookie

        
###################################################################################################################
#                USER LOGIN
###################################################################################################################    
    if 'username' in args and 'password' in args and args['username']!='' and args['password']!='':
        print(args)
        sida=args['username']
        sidb=hashlib.md5((args['password']+salt).encode('utf-8')).hexdigest()
        if DI.isUser(sida,sidb):
            cookie['sida']=sida
            cookie['sida']['expires'] = 12 * 30 * 24 * 60 * 60
            cookie['sida']["path"] = "/"
            cookie['sidb']=sidb
            cookie['sidb']['expires'] = 12 * 30 * 24 * 60 * 60
            cookie['sidb']["path"] = "/"
            cherrypy.request.cookie=cookie
            article= """<meta http-equiv="refresh" content="0;url=/home/" /><h1>Login Sucessful!</h1>"""
        else:
            article= '''<p>Incorrect login.  Please try again.</p>''' + article
    else:
        article= '''<p>Enter username and password.</p>''' + article
        

    return glamsTemplate(article, name, resources=resources)
示例#13
0
def getsettings():
    username = checkPassword()
    if not username:
        return """<meta http-equiv="refresh" content="0;url=/home/login" />"""
########################  CREATE ARTICLE ###############################################################################
    changepass = E.div(
        E.h2('Change password:'******'Current password:'******'name': 'oldpassword',
                      'type': 'password'
                  })),
            E.div(E.label('New password:'******'name': 'newpassword1',
                      'type': 'password'
                  })),
            E.div(E.label('Confirm new password:'******'name': 'newpassword2',
                      'type': 'password'
                  })),
            E.a(
                {
                    'class': 'button-link',
                    'onclick': "changepassword($(this).parent().serialize());"
                }, 'Change password')))

    changeemail = E.div(
        E.h2('Change email address:'),
        E.form(
            E.div(
                E.label('Password:'******'name': 'password',
                    'id': 'emailpassword',
                    'type': 'password'
                })),
            E.div(
                E.label('New email:'),
                E.input({
                    'name': 'newemail1',
                    'id': 'newemail1',
                    'type': 'text'
                })),
            E.div(
                E.label('Confirm new email:'),
                E.input({
                    'name': 'newemail2',
                    'id': 'newemail2',
                    'type': 'text'
                })),
            E.a(
                {
                    'class': 'button-link',
                    'onclick': "changeemail($(this).parent().serialize());"
                }, 'Change email')))
    article = E.div(E.div({'id': 'notification'}, ''),
                    E.div(changepass, changeemail))
    article = etree.tostring(article, pretty_print=True)

    ####################### STYLE AND JAVASCRIPT #############################################################################
    style = """ 
h2    {
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #D8D8D8;}
input{
    webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;
    padding: 4px;}

table{
    width:500px;
    margin:10px;}
    
#notification{
    display:none;
    padding:5px;
    margin:3px;
    background-color:#FFFF66;
    webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;}
    
label{
    display: inline-block;
    float: left;
    clear: left;
    width: 200px;
    margin-right: 10px;
    white-space: nowrap;}
    
form .button-link{margin-left:0px;}
    
form div{margin-bottom:10px;}

    """
    javascript = """ 
var t;
function notify(data){
    $('#notification').html(data);
    $('#notification').show();
    var fadefunc="$('#notification').hide('fade', {}, 200);";
    t=setTimeout(fadefunc,15000);
}
function changepassword(fields){
    $.post('/home/ajax/changepassword/',{fields:fields}, function(data){ notify(data);});}
function changeemail(fields){
    $.post('/home/ajax/changeemail/',{fields:fields}, function(data){ notify(data);});}

    """
    resources = "<style type='text/css'>" + style + '</style><script type="text/javascript">' + javascript + '</script>'
    return glamsTemplate(article, username, resources=resources)
示例#14
0
    def index(self):
        username = checkPassword()
        if not username:
            return """<meta http-equiv="refresh" content="0;url=/home/login" />"""

        style = """ 
            #db {
                 border-collapse: collapse;
                 border: 0;
             }
             table{
                  width:100%;
                  text-align:center;
             }
            #db th{
                 white-space: nowrap;
                background: none repeat scroll 0 0 #B0C4DE;  
                font-weight: normal;
            }
            #db th:hover {background-color: #C0D0E5
            }
            
            #db td{ 
                    font-family: arial,sans-serif;
                    overflow: hidden; 
                    text-overflow: ellipsis;
                    /*word-wrap: break-word; */
                    white-space: nowrap; 
            }

            td{
                font-size: small; 
                padding:6px;
                line-height:120%;
            }
            td a{
                text-decoration: none;
            }
            h1{
                text-align:center;
            }


            """
        javascript = """
        $( document ).ready(function(){
            
        });
        """

        resources = "<style type='text/css'>" + style + "</style>"
        resources += "<script type='text/javascript'>" + javascript + "</script>"
        resources += "<link rel='stylesheet' href='/support/css/dragtable.css' type='text/css' />"
        resources += "<script type='text/javascript' src='/support/javascript/jquery.dragtable.js'></script>"
        resources += "<script type='text/javascript' src='/support/javascript/experimentlog.js'></script>"
        resources += "<script type='text/javascript' src='/support/javascript/jquery.tablesorter.js'></script> "

        resources += "<link rel='stylesheet' type='text/css' href='/support/thirdparty/tooltipster/css/tooltipster.css' />"
        resources += "<script type='text/javascript' src='/support/thirdparty/tooltipster/js/jquery.tooltipster.js'></script>"

        #        viewtype,cols=db.execute("SELECT viewtype, columns FROM lab_members WHERE name=%s",(username,))[0]
        #        if viewtype is None:
        #            cols=['mousename','']
        #        else:
        #            cols=cols.split(',')
        #        if viewtype=='mouse':
        #            c=['checked','']
        #        else:
        #            c=['','checked']
        article = """<h1 style='margin-bottom: 20px;'>Experiment log</h1>
                    <table id='db' class="tablesorter"></table>"""

        rightbar = ''
        return glamsTemplate(article,
                             username,
                             resources=resources,
                             rightbar=rightbar)