def createCols(self): cols = super(OrmTableFactory, self).createCols() from luban.content.table import View selected_col = View.Column(label='', measure='selected') id_col = View.Column(label='ID', measure='id') description_col = View.Column(label='Description', measure='description') date_col = View.Column(label='Date', measure='date') cols = [selected_col, id_col, description_col] + cols + [date_col] return cols
def view(cols, editable=True): global columns columns = filter(lambda col: col.measure in cols, columns) view = View(columns=columns, editable=True) return view
class model(Model): selectone = Model.descriptors.radio_button(name='selectone') id = Model.descriptors.str(name='id') description = Model.descriptors.str(name='description') visualize = Model.descriptors.link(name='visualize') chemical_formula = Model.descriptors.str(name='chemical_formula') created = Model.descriptors.str(name='created') row_identifiers = ['id'] columns = [ View.Column(label='', measure='selectone'), View.Column(label='ID', measure='id'), View.Column(label='Description', measure='description', editable=True), View.Column(label='Visualize', measure='visualize'), View.Column(label='Chemical_formula', measure='chemical_formula'), View.Column(label='Date created', measure='created'), ] def view(cols, editable=True): global columns columns = filter(lambda col: col.measure in cols, columns) view = View(columns=columns, editable=True) return view
from luban.content.Link import Link class model(Model): selected = Model.descriptors.bool(name='selected') id = Model.descriptors.str(name='id') description = Model.descriptors.link(name='description') created = Model.descriptors.date(name='created') creator = Model.descriptors.str(name='creator') row_identifiers = ['id'] columns = [ View.Column(label='', measure='selected'), View.Column(label='ID', measure='id', hidden=True), View.Column(label='Description', measure='description'), # editable=True), View.Column(label='Creator', measure='creator'), View.Column(label='Date created', measure='created'), ] def view(cols, editable=True): global columns columns = filter(lambda col: col.measure in cols, columns) view = View(columns=columns, editable=editable) return view class AttrFetcher(object):
from luban.content.Link import Link class model(Model): selected = Model.descriptors.bool(name='selected') id = Model.descriptors.link(name='id') description = Model.descriptors.str(name='description') sample = Model.descriptors.str(name='sample') created = Model.descriptors.date(name='created') row_identifiers = ['id'] columns = [ View.Column(label='', measure='selected'), View.Column(label='ID', measure='id'), View.Column(label='Description', measure='description', editable=True), View.Column(label='Sample', measure='sample'), View.Column(label='Date created', measure='created'), ] def view(cols, editable=True): global columns columns = filter(lambda col: col.measure in cols, columns) return View(columns=columns, editable=True) class Formatter: def __init__(self, db):
class model(Model): selectone = Model.descriptors.radio_button(name='selectone') id = Model.descriptors.str(name='id') description = Model.descriptors.str(name='description') visualize = Model.descriptors.link(name='visualize') chemical_formula = Model.descriptors.str(name='chemical_formula') created = Model.descriptors.str(name='created') row_identifiers = ['id'] columns = [ View.Column(label='', measure='selectone'), View.Column(label='ID', measure='id'), View.Column(label='Filename', measure='filename'), View.Column(label='Description', measure='description', editable=True), View.Column(label='Author', measure='creator'), View.Column(label='Date created', measure='created'), ] def view(cols, editable=True): global columns columns = filter(lambda col: col.measure in cols, columns) view = View(columns=columns, editable=True) return view
def tableSimulations(headers, names, columns, ids): from luban.content.table import Table, Model, View # create a model class class model(Model): name = Model.descriptors.link(name='name') type = Model.descriptors.str(name='type') description = Model.descriptors.str(name='description') configs = Model.descriptors.str(name='configs') created = Model.descriptors.str(name='created') edit = Model.descriptors.link(name='edit') remove = Model.descriptors.link(name='remove') use = Model.descriptors.link(name='use') # create a view view = View(columns=[ View.Column(label=headers[0], measure='name'), View.Column(label=headers[1], measure='type'), View.Column(label=headers[2], measure='description'), View.Column(label=headers[3], measure='configs'), View.Column(label=headers[4], measure='created'), View.Column(label=headers[5], measure='edit'), View.Column(label=headers[6], measure='remove'), View.Column(label=headers[7], measure='use'), ]) # Populate the data list def name(i): link = Link(label=names[i], onclick=load(actor='espresso/sim-view', routine='link', id=ids[i])) return link def edit(i): link = Link(label="Edit", onclick=load(actor='espresso/sim-edit', routine='link', id=ids[i])) return link def delete(i): link = Link(label="Delete", onclick=load(actor='espresso/sim-delete', routine='link', id=ids[i])) return link def use(i): link = Link(label="Clone", onclick=load(actor='espresso/sim-use', routine='link', id=ids[i])) return link data = [] for i in range(len(names)): n = [name(i)] data.append(n) data[i] += columns[i] data[i] += [edit(i)] data[i] += [delete(i)] data[i] += [use(i)] # create the table table = Table(model=model, data=data, view=view) return table
from luban.content.Link import Link class model(Model): selectone = Model.descriptors.radio_button(name='selectone') id = Model.descriptors.str(name='id') description = Model.descriptors.str(name='description') type = Model.descriptors.str(name='type') date = Model.descriptors.str(name='date') row_identifiers = ['id', 'type'] columns = [ View.Column(label='', measure='selectone'), View.Column(label='ID', measure='id'), View.Column(label='Description', measure='description'), View.Column(label='Type', measure='type'), View.Column(label='Date created', measure='date'), ] def view(cols, editable=True): global columns columns = filter(lambda col: col.measure in cols, columns) view = View(columns=columns, editable=True) return view
def view(cols, editable=False): global columns columns = filter(lambda col: col.measure in cols, columns) return View(columns=columns, editable=editable)
from luban.content.Link import Link class model(Model): selected = Model.descriptors.bool(name='selected') id = Model.descriptors.link(name='id') description = Model.descriptors.str(name='description') type = Model.descriptors.str(name='type') matter = Model.descriptors.str(name='matter') created = Model.descriptors.date(name='created') row_identifiers = ['id', 'type'] columns = [ View.Column(label='', measure='selected'), View.Column(label='ID', measure='id'), View.Column(label='Description', measure='description', editable=True), View.Column(label='Type', measure='type'), View.Column(label='Matter', measure='matter'), View.Column(label='Date created', measure='created'), ] def view(cols, editable=False): global columns columns = filter(lambda col: col.measure in cols, columns) return View(columns=columns, editable=editable)
def tableJobs(headers, jobids, simids, simnames, columns): from luban.content.table import Table, Model, View # create a model class class model(Model): jobid = Model.descriptors.link(name='jobid') simulation = Model.descriptors.link(name='simulation') server = Model.descriptors.str(name='server') user = Model.descriptors.str(name='user') submitted = Model.descriptors.str(name='submitted') status = Model.descriptors.str(name='status') delete = Model.descriptors.link(name='delete') refresh = Model.descriptors.link(name='refresh') # create a view view = View(columns=[ View.Column(label=headers[0], measure='jobid'), View.Column(label=headers[1], measure='simulation'), View.Column(label=headers[2], measure='server'), View.Column(label=headers[3], measure='user'), View.Column(label=headers[4], measure='submitted'), View.Column(label=headers[5], measure='status'), View.Column(label=headers[6], measure='delete'), View.Column(label=headers[7], measure='refresh'), ]) # Populate the data list def jobid(i): link = Link(label=jobids[i], onclick=load(actor='jobs/view', routine='link', id=jobids[i])) return link def sim(i): link = Link(label=simnames[i], onclick=load(actor='espresso/sim-view', routine='link', id=simids[i])) return link def delete(i): link = Link(label="Delete", onclick=load(actor='jobs/delete', routine='link', id=jobids[i])) return link def refresh(i): link = Link(label="Refresh", onclick=load(actor='jobs/index', routine='link', id=jobids[i])) #ids[i] return link data = [] for i in range(len(jobids)): # just need size of list (e.g. from jobids) n = [jobid(i)] data.append(n) data[i] += [sim(i)] data[i] += columns[i] data[i] += [refresh(i)] data[i] += [delete(i)] # create the table table = Table(model=model, data=data, view=view) return table
from luban.content import load from luban.content.Link import Link class model(Model): selected = Model.descriptors.bool(name='selected') id = Model.descriptors.link(name='id') description = Model.descriptors.str(name='description') time_start = Model.descriptors.str(name='time_start') state = Model.descriptors.str(name='state') row_identifiers = ['id'] columns = [ View.Column(label='', measure='selected'), View.Column(label='ID', measure='id'), View.Column(label='Description', measure='description', editable=True), View.Column(label='Time started', measure='time_start'), View.Column(label='Status', measure='state'), ] def view(cols, editable=True): global columns columns = filter(lambda col: col.measure in cols, columns) return View(columns=columns, editable=True) def getSelected(record): return False def getId(record):