Exemple #1
0
def do_importgroup(args, dbh, settings):

    cerr('Importing group')
    groups = yaml.load(open(args.importgroup))

    from rhombus.models.user import UserClass, Group

    Group.bulk_insert(groups, dbsession=dbh.session())
Exemple #2
0
def setup(session):
    """ populate database with essential GenAF data, mostly taken from FATools constants """

    EK.bulk_insert(ek_initlist, dbsession=session)

    # get default group, which is system

    adm_group = Group.search("_DataAdm_", dbsession=session)

    # create undefined marker
    marker = Marker(code="undefined", species="X")
    cerr("INFO - marker 'undefined' created.")
    session.add(marker)

    # create ladder marker
    marker = Marker(code="ladder", species="X")
    cerr("INFO - marker 'ladder' created.")
    session.add(marker)

    # create combined marker
    marker = Marker(code="combined", species="X")
    cerr("INFO - marker 'combined' created.")
    session.add(marker)

    # create default panel
    panel = Panel(code="undefined", group_id=adm_group.id)
    cerr("INFO - panel 'undefined' created.")
    session.add(panel)

    # create default batch
    batch = Batch(code="default", group_id=adm_group.id, assay_provider_id=adm_group.id, species="X")
    cerr("INFO - default batch created.")
    session.add(batch)
Exemple #3
0
def setup( dbh ):
    """ populate the database with basic, essential data """

    if get_datalogger():
        get_clsreg().sync()
        session.commit()

    dbsession = dbh.session()

    EK.bulk_update( ek_initlist, dbsession=dbsession )
    Group.bulk_insert( essential_groups, dbsession=dbsession )
    UserClass.bulk_insert( system_userclass, dbsession=dbsession )

    group_id = Group._id('_SysAdm_', dbsession)
    file = File( path='/', group_id = group_id, permanent = True )
    dbsession.add( file )
    file.type = 'file/folder'
    file.mimetype = 'application/x-directory'

    cerr('INFO: root password is %s\n' % root_password)
Exemple #4
0
def setup_db( *ops ):
    """ setup the database (create tables, etc) and populate with basic data """

    base = get_base()

    # WARN: use alembic to create initial tables
    #base.metadata.create_all()

    with transaction.manager:
        if get_datalogger():
            get_clsreg().sync()

    with transaction.manager:
        EK.bulk_insert( ek_initlist )
        Group.bulk_insert( essential_groups )

        file = File( path='/', type='file/folder', mimetype='application/x-directory',
                    group_id = Group._id('_SysAdm_'), permanent = True )
        dbsession.add( file )

        for op in ops:
            op()
Exemple #5
0
    def update(self, obj):

        self._update(obj)
        session = object_session(self) or self._dbh_session_

        if type(obj) == dict:

            if 'group' in obj:
                with session.no_autoflush:
                    group = Group.search(obj['group'], session)
                    self.group = group

        else:
            raise NotImplementedError()


        # verify that each marker in data exists
        session = object_session(self) or self._dbh_session_
        for m_code in self.data['markers']:
            m = Marker.search(m_code, session)
            if m is None:
                cerr("ERR: can't find marker: %s" % m_code)
                sys.exit(1)
Exemple #6
0
def index(request):
    """ list groups """

    dbh = get_dbhandler()
    groups = Group.query(dbh.session())

    html, code = format_grouptable(groups, request)

    if request.user.has_roles(SYSADM):

        add_button = ( 'New group',
                        request.route_url('rhombus.group-edit', id=0)
        )

        bar = selection_bar('group-ids', action=request.route_url('rhombus.group-action'),
                    add = add_button)
        html, code = bar.render(html, code)


    return render_to_response('rhombus:templates/group/index.mako',
                {   'html': html,
                    'code': code,
                }, request=request )
Exemple #7
0
def populate_db( dbsession, initial_groups=None, initial_userclass=None ):

    if initial_groups:
        Group.bulk_insert( initial_groups, dbsession=dbsession )
    if initial_userclass:
        UserClass.bulk_insert( initial_userclass, dbsession=dbsession )