示例#1
0
def file_manage( public ):
    fields = [
        db.t_file.f_filename
        , db.t_file.f_bionimbus_id
        , db.t_file.f_size
        , db.t_file.f_reads
        ]

    file_links = [
      lambda row: A('Download',_href=URL("default","file_download",args=[row.id]))
    ]

    if is_user_admin( db , auth ):
      file_links.append( lambda row: A('Delete',_href=URL("default","file_delete",args=[row.f_filename])) )

    if public == True:
        q = ( db.t_file.f_bionimbus_id == db.t_experiment_unit.f_bionimbus_id) & ( db.t_experiment_unit.f_is_public == 't' )
    else:
        if is_user_admin( db , auth ):
            q = db.t_file
        else:
            q = ( db.t_file.f_bionimbus_id == db.t_experiment_unit.f_bionimbus_id) & ( db.t_experiment_unit.f_project == db.t_user_project.f_project_id ) & ( db.t_user_project.f_user_id == auth.user_id )

    form = SQLFORM.grid( q ,
                         fields        = fields ,
                         field_id      = db.t_file.id ,
                         maxtextlength = 200 ,
                         deletable     = False ,
                         editable      = False ,
                         links         = file_links ,
                         create        = False ,
                         paginate = 1000 ,
                         selectable = lambda ids: add_file_id(ids) ,
                         )
    return locals()
示例#2
0
def project_manage():
    if is_user_admin(db, auth):
        q = db.t_project.id <> -1
    else:
        q = (db.t_project.id == db.t_user_project.f_project_id) & (
            db.t_user_project.f_user_id == auth.user_id)
    return proj(q)
示例#3
0
def subproject_manage():
    editable = is_user_admin(db, auth)
    form = SQLFORM.grid(db.t_subproject.id <> 1,
                        editable=editable,
                        create=editable,
                        deletable=False)
    return locals()
示例#4
0
def proj(q):
    fields = [
        db.t_project.id, db.t_project.f_name, db.t_project.f_organism,
        db.t_project.f_pi, db.t_project.f_public, db.t_project.f_cloud
    ]
    editable = is_user_admin(db, auth)

    links = [
        lambda row: A(
            'Libraries',
            _href=URL(
                "default",
                'my_experiments?keywords=t_experiment_unit.f_project+=+"%d"' %
                (row[db.t_project.id]))),
    ]

    form = SQLFORM.grid(
        q,
        fields=fields,
        #links = project_links ,
        editable=editable,
        create=editable,
        onupdate=auth.archive,
        paginate=1000,
        links=links,
        maxtextlength=150,
        deletable=False)
    return locals()
示例#5
0
def platform_manage():
    editable = is_user_admin( db , auth )

    form = SQLFORM.grid( db.t_platform ,
                         create    = editable ,
                         editable  = editable ,
                         deletable = False ,
                         )
    return locals()
示例#6
0
def facility_manage():
    editable = is_user_admin( db , auth )

    form = SQLFORM.grid( db.t_facility ,
                         create    = editable ,
                         editable  = editable ,
                         deletable = False ,
                         )
    return locals()
示例#7
0
def cloud_manage():
    editable = is_user_admin( db , auth )
    form = SQLFORM.grid( db.t_cloud ,
                         create    = editable ,
                         editable  = editable ,
                         deletable = editable ,
                         #fields    = fields
                         )
    return locals()
示例#8
0
def cloud_manage():
    editable = is_user_admin(db, auth)
    form = SQLFORM.grid(
        db.t_cloud,
        create=editable,
        editable=editable,
        deletable=editable,
        #fields    = fields
    )
    return locals()
示例#9
0
def sample_states():
    editable = is_user_admin( db , auth )
    form = SQLFORM.grid( db.t_sample_state ,
                         create    = editable ,
                         editable  = editable ,
                         deletable = editable ,
                         paginate = 1000 ,
                         maxtextlength = 150,
                         )
    return locals()
示例#10
0
def platform_manage():
    editable = is_user_admin(db, auth)

    form = SQLFORM.grid(
        db.t_platform,
        create=editable,
        editable=editable,
        deletable=False,
    )
    return locals()
示例#11
0
def facility_manage():
    editable = is_user_admin(db, auth)

    form = SQLFORM.grid(
        db.t_facility,
        create=editable,
        editable=editable,
        deletable=False,
    )
    return locals()
示例#12
0
def file_manage(public):
    fields = [
        db.t_file.f_filename, db.t_file.f_bionimbus_id, db.t_file.f_size,
        db.t_file.f_reads
    ]

    file_links = [
        lambda row: A('Download',
                      _href=URL("default", "file_download", args=[row.id]))
    ]

    if is_user_admin(db, auth):
        file_links.append(lambda row: A(
            'Delete',
            _href=URL("default", "file_delete", args=[row.f_filename])))

    if public == True:
        q = (db.t_file.f_bionimbus_id == db.t_experiment_unit.f_bionimbus_id
             ) & (db.t_experiment_unit.f_is_public == 't')
    else:
        if is_user_admin(db, auth):
            q = db.t_file
        else:
            q = (db.t_file.f_bionimbus_id
                 == db.t_experiment_unit.f_bionimbus_id) & (
                     db.t_experiment_unit.f_project
                     == db.t_user_project.f_project_id) & (
                         db.t_user_project.f_user_id == auth.user_id)

    form = SQLFORM.grid(
        q,
        fields=fields,
        field_id=db.t_file.id,
        maxtextlength=200,
        deletable=False,
        editable=False,
        links=file_links,
        create=False,
        paginate=1000,
        selectable=lambda ids: add_file_id(ids),
    )
    return locals()
示例#13
0
def mailing_list_manage():
    editable = is_user_admin( db , auth )
    form = SQLFORM.grid( db.t_mail_list ,
                         create    = editable ,
                         editable  = editable ,
                         deletable = editable ,
                         paginate = 1000 ,
                         maxtextlength = 150,
                         #fields    = fields
                         )
    return locals()
示例#14
0
def sample_states():
    editable = is_user_admin(db, auth)
    form = SQLFORM.grid(
        db.t_sample_state,
        create=editable,
        editable=editable,
        deletable=editable,
        paginate=1000,
        maxtextlength=150,
    )
    return locals()
示例#15
0
def mailing_list_manage():
    editable = is_user_admin(db, auth)
    form = SQLFORM.grid(
        db.t_mail_list,
        create=editable,
        editable=editable,
        deletable=editable,
        paginate=1000,
        maxtextlength=150,
        #fields    = fields
    )
    return locals()
示例#16
0
def user_project_manage():
    arg = request.args(0)

    fields = [
        db.t_user_project.f_project_id, db.t_user_project.f_user_id,
        db.t_user_project.f_admin
    ]
    editable = is_user_admin(db, auth)
    form = SQLFORM.grid(db.t_user_project,
                        create=editable,
                        editable=editable,
                        deletable=editable,
                        paginate=1000,
                        maxtextlength=150,
                        fields=fields)

    #if arg == 'new':
    #  nfu = names_for_users()
    #  options = nameval_to_options( nfu )
    #  form[1][0][1][1] = TD( SELECT( *options ,  _class="generic-widget" , _id="t_user_project_f_user_id" , _name="f_user_id" ) )

    return locals()
示例#17
0
def organism_manage():
    fields = [
        db.t_organism.f_name
        , db.t_organism.f_common_name
        ]
    editable = is_user_admin( db , auth )

    links = [
        lambda row: A( 'Libraries' , 
                       _href=URL( "default" , 'my_experiments?keywords=t_experiment_unit.f_organism+=+"%d"' % (row[ db.t_organism.id ] ) ) ) ,
        ]

    form = SQLFORM.grid( db.t_organism ,
                         fields    = fields ,
                         create    = editable ,
                         editable  = editable ,
                         deletable = False ,
                         onupdate  = auth.archive ,
                         paginate = 1000 ,
                         maxtextlength = 150 ,
                         links = links
                         )
    return locals()
示例#18
0
def organism_manage():
    fields = [db.t_organism.f_name, db.t_organism.f_common_name]
    editable = is_user_admin(db, auth)

    links = [
        lambda row: A(
            'Libraries',
            _href=URL(
                "default",
                'my_experiments?keywords=t_experiment_unit.f_organism+=+"%d"' %
                (row[db.t_organism.id]))),
    ]

    form = SQLFORM.grid(db.t_organism,
                        fields=fields,
                        create=editable,
                        editable=editable,
                        deletable=False,
                        onupdate=auth.archive,
                        paginate=1000,
                        maxtextlength=150,
                        links=links)
    return locals()
示例#19
0
#   ]),
#(T('Sample'),URL('default','sample_manage')==URL(),URL('default','sample_manage'),[]),
#(T('Agent'),URL('default','agent_manage')==URL(),URL('default','agent_manage'),[]),
(T('Key Generation'),URL('keygen','keygen_spreadsheet')==URL(),URL('keygen','keygen_spreadsheet'),[]),
]

u = A('User Documentation',_href='/Bionimbus/static/bd/bd.html',_target='docs')
#u2 = A('Quick start',_href='https://docs.google.com/document/d/1RPb8UEQsDgsZmuDCW_rTEMHtAgGCDnNYTm7BaRsmgAo/view?usp=sharing',_target='docs')

response.menu.append( ( 'Docs' , True , None , [
  (T('Documentation'),False,u,[]),
  #(T('Quick Start'),False,u2,[])
] ) )


from permissions import is_user_admin

if is_user_admin( db , auth ):
  response.menu.append( ( 'Admin' , True , None , [ 
   (T('Sample Tracking'),URL('default','sample_tracking')==URL(),URL('default','sample_tracking'),[]) ,
   (T('Project Users'),URL('permissions','user_project_manage')==URL(),URL('permissions','user_project_manage'),[]) ,
   (T('Barcodes'),URL('default','barcode_manage')==URL(),URL('default','barcode_manage'),[]) ,
   (T('Facilities'),URL('default','facility_manage')==URL(),URL('default','facility_manage'),[]) ,
   (T('Mailing Lists'),URL('default','mailing_list_manage')==URL(),URL('default','mailing_list_manage'),[]),
   (T('Clouds'),URL('default','cloud_manage')==URL(),URL('default','cloud_manage'),[]),
   (T('Platform'),URL('default','platform_manage')==URL(),URL('default','platform_manage'),[]),
   (T('Library Types'),URL('default','library_type_manage')==URL(),URL('default','library_type_manage'),[]),
   (T('Archives'),URL('default','archives')==URL(),URL('default','archives'),[])
    ] ) )

示例#20
0
def experiment_unit_manage( public , fields = basic_experiment_fields , type = None , is_active = True ):
    if type<>None:
        type = db( db.t_library_type.f_name == type ).select()[ 0 ][ db.t_library_type.id ]
    pub = 'my'
    if public:
        pub = 'public'
    experiment_links = [
        lambda row: downloadRow( row ),
        lambda row: fileRow( pub , row ),
        lambda row: stateRow( row )
        ]

    if is_active == False:
        experiment_links.insert( 0 , lambda row: A('Restore', _href=URL( "default" , "bn_restore",args=[row.f_bionimbus_id,request.env.path_info])))

    editable = True
    arg = request.args( 0 )

    if ( arg == 'view' ):
        #experiment_links.append( lambda row: "http://www.opensciencedatacloud.org/keyservice/ark:/31807/bn%s" % row.f_bionimbus_id )
        if db.t_experiment_unit[ request.args[ 2 ] ].f_spreadsheet <> None:
            experiment_links.append( lambda row: A('Spreadsheet Download'    , _href=URL("default","spreadsheet_download",             args=[row.f_spreadsheet])))

    if ( arg == 'edit' ):
        if is_user_admin( db , auth ):
            editable = True
            if is_active == True:
                experiment_links.insert( 0 , lambda row: A('Archive', _href=URL( "default" , "bn_archive",args=[row.f_bionimbus_id])))
        else:
            id = int( request.args( 2 ) )
            rows = db( ( db.t_user_project.f_user_id    == auth.user_id ) &
                       ( db.t_user_project.f_admin == 'T') & 
                       ( db.t_experiment_unit.id == id ) ).select( db.t_experiment_unit.id , left = experiment_project_join(db) )
            #response.flash = db._lastsql 
            if len(rows)<1:
                response.flash = "you can't edit that experiment"
                editable = False
            else:
                editable = True

    if public == True:
        q = db.t_experiment_unit.f_is_public == 't'
    else:
        if is_user_admin( db , auth ):
            q = ( db.t_experiment_unit.id <> -1 )
        else:
            q = ( db.t_experiment_unit.f_project == db.t_user_project.f_project_id ) & ( db.t_user_project.f_user_id == auth.user_id )

    if type <> None:
        q = q & ( db.t_experiment_unit.f_library_type == type )

    q = q & ( db.t_experiment_unit.is_active == is_active )

    #db( q ).select()
    #print db._lastsql

    form = SQLFORM.grid( q , 
                         fields = fields ,
                         links = experiment_links ,
                         editable = editable ,
                         onupdate = auth.archive ,
                         deletable = False ,
                         create = False ,
                         maxtextlength = 150,
                         paginate = 100 ,
                         headers = { 0 : 'poopy' } ,
                         selectable = lambda ids: add_bn_id(ids) ,
                         orderby=~db.t_experiment_unit.f_sample_state_changed
                         )
    #need this try-catch in case the table is empty, and therefore has no submit button
    try:
        form.element('.web2py_table input[type=submit]')['_value'] = T('Add To Dropbox')
    except:
        pass
    return locals()
示例#21
0
def experiment_unit_manage(public,
                           fields=basic_experiment_fields,
                           type=None,
                           is_active=True):
    if type <> None:
        type = db(
            db.t_library_type.f_name == type).select()[0][db.t_library_type.id]
    pub = 'my'
    if public:
        pub = 'public'
    experiment_links = [
        lambda row: downloadRow(row), lambda row: fileRow(pub, row),
        lambda row: stateRow(row)
    ]

    if is_active == False:
        experiment_links.insert(
            0, lambda row: A(
                'Restore',
                _href=URL("default",
                          "bn_restore",
                          args=[row.f_bionimbus_id, request.env.path_info])))

    editable = True
    arg = request.args(0)

    if (arg == 'view'):
        #experiment_links.append( lambda row: "http://www.opensciencedatacloud.org/keyservice/ark:/31807/bn%s" % row.f_bionimbus_id )
        if db.t_experiment_unit[request.args[2]].f_spreadsheet <> None:
            experiment_links.append(
                lambda row: A('Spreadsheet Download',
                              _href=URL("default",
                                        "spreadsheet_download",
                                        args=[row.f_spreadsheet])))

    if (arg == 'edit'):
        if is_user_admin(db, auth):
            editable = True
            if is_active == True:
                experiment_links.insert(
                    0, lambda row: A('Archive',
                                     _href=URL("default",
                                               "bn_archive",
                                               args=[row.f_bionimbus_id])))
        else:
            id = int(request.args(2))
            rows = db((db.t_user_project.f_user_id == auth.user_id)
                      & (db.t_user_project.f_admin == 'T')
                      & (db.t_experiment_unit.id == id)).select(
                          db.t_experiment_unit.id,
                          left=experiment_project_join(db))
            #response.flash = db._lastsql
            if len(rows) < 1:
                response.flash = "you can't edit that experiment"
                editable = False
            else:
                editable = True

    if public == True:
        q = db.t_experiment_unit.f_is_public == 't'
    else:
        if is_user_admin(db, auth):
            q = (db.t_experiment_unit.id <> -1)
        else:
            q = (db.t_experiment_unit.f_project
                 == db.t_user_project.f_project_id) & (
                     db.t_user_project.f_user_id == auth.user_id)

    if type <> None:
        q = q & (db.t_experiment_unit.f_library_type == type)

    q = q & (db.t_experiment_unit.is_active == is_active)

    #db( q ).select()
    #print db._lastsql

    form = SQLFORM.grid(q,
                        fields=fields,
                        links=experiment_links,
                        editable=editable,
                        onupdate=auth.archive,
                        deletable=False,
                        create=False,
                        maxtextlength=150,
                        paginate=100,
                        headers={0: 'poopy'},
                        selectable=lambda ids: add_bn_id(ids),
                        orderby=~db.t_experiment_unit.f_sample_state_changed)
    #need this try-catch in case the table is empty, and therefore has no submit button
    try:
        form.element('.web2py_table input[type=submit]')['_value'] = T(
            'Add To Dropbox')
    except:
        pass
    return locals()