def get_actions(track, user, rights, project=None): # user own the track => all actions if track.user.id == user.id: return hoover_actions( helpers.export_link(track.id, url('/tracks'), project=project) + helpers.edit_link(track.id, url('/tracks'), project=project) + helpers.delete_link(track.id, url('/tracks'), project=project) ) right_ids = [r.id for r in rights] if rights is None: return hoover_actions('') debug('Get actions %s' % right_ids) if constants.rights['download']['id'] in right_ids and constants.rights['upload']['id'] in right_ids: debug('Download & Upload', 1) return hoover_actions( helpers.export_link(track.id, url('/tracks'), project=project) + helpers.edit_link(track.id, url('/tracks'), project=project) ) # user have the download right if constants.rights['download']['id'] in right_ids: debug('Download', 1) return hoover_actions( helpers.export_link(track.id, url('/tracks')) ) # user have upload right if constants.rights['upload']['id'] in right_ids: debug('Upload', 1) return hoover_actions( helpers.edit_link(track.id, url('/tracks')) ) debug('no rights', 1) return hoover_actions('')
def get_actions(track, user, rights, project=None): # user own the track => all actions if track.user.id == user.id: return hoover_actions( helpers.export_link(track.id, url('/tracks'), project=project) + helpers.edit_link(track.id, url('/tracks'), project=project) + helpers.delete_link(track.id, url('/tracks'), project=project)) right_ids = [r.id for r in rights] if rights is None: return hoover_actions('') debug('Get actions %s' % right_ids) if constants.rights['download']['id'] in right_ids and constants.rights[ 'upload']['id'] in right_ids: debug('Download & Upload', 1) return hoover_actions( helpers.export_link(track.id, url('/tracks'), project=project) + helpers.edit_link(track.id, url('/tracks'), project=project)) # user have the download right if constants.rights['download']['id'] in right_ids: debug('Download', 1) return hoover_actions(helpers.export_link(track.id, url('/tracks'))) # user have upload right if constants.rights['upload']['id'] in right_ids: debug('Upload', 1) return hoover_actions(helpers.edit_link(track.id, url('/tracks'))) debug('no rights', 1) return hoover_actions('')
def track_grid_user(user, project=None): return twf.DataGrid(fields=[ ('Name', 'name'), (hoover_action, lambda obj: hoover_actions( helpers.export_link(obj.id, url('/tracks'), project=project) + helpers.edit_link(obj.id, url('/tracks'), project=project) + helpers.delete_link(obj.id, url('/tracks'), project=project))), ('Color', lambda obj: genshi.Markup(helpers.track_color(obj))), ('Owner', 'owner'), ('Created', 'created'), ('Assembly', 'sequence'), ('Type', 'vizu'), (hidden_info, lambda obj: hide_info({ 'tr_id': obj.id, 'tr_status': obj.status, })), ])
def track_grid_user(user, project=None): return twf.DataGrid(fields=[ ('Name', 'name'), (hoover_action, lambda obj: hoover_actions( helpers.export_link(obj.id, url('/tracks'), project=project) + helpers.edit_link(obj.id, url('/tracks'), project=project) + helpers.delete_link(obj.id, url('/tracks'), project=project) )), ('Color', lambda obj: genshi.Markup(helpers.track_color(obj))), ('Owner', 'owner'), ('Created', 'created'), ('Assembly', 'sequence'), ('Type', 'vizu'), (hidden_info, lambda obj: hide_info({ 'tr_id': obj.id, 'tr_status': obj.status, })), ])
def etrack_grid_permissions(rights=None): if rights is not None: del_action = None right_ids = [r.id for r in rights] if constants.rights['download']['id'] in right_ids and constants.rights[ 'upload']['id'] in right_ids: actions = lambda obj: hoover_actions( helpers.export_link(obj.id, url('/tracks')) #+ helpers.edit_link(obj.id, url('/tracks')) #+ helpers.delete_link(obj.id, url('/tracks')) ) elif constants.rights['download']['id'] in right_ids: actions = lambda obj: hoover_actions( helpers.export_link(obj.id, url('/tracks'))) elif constants.rights['upload']['id'] in right_ids: actions = lambda obj: hoover_actions( helpers.edit_link(obj.id, url('/tracks')) + helpers. delete_link(obj.id, url('/tracks'))) else: actions = lambda obj: hoover_actions('') h_info = lambda obj: hide_info( { 'tr_id': obj.id, 'tr_status': obj.status, 'tr_color': helpers.get_track_color(obj), }) fields = [ ('Name', 'name'), (hoover_action, actions), ('Created', 'created'), ('Assembly', 'sequence'), ('Type', 'vizu'), (hidden_info, h_info), ] return twf.DataGrid(fields=fields)
def etrack_grid_permissions(rights=None): if rights is not None: del_action = None right_ids = [r.id for r in rights] if constants.rights['download']['id'] in right_ids and constants.rights['upload']['id'] in right_ids: actions = lambda obj: hoover_actions( helpers.export_link(obj.id, url('/tracks')) #+ helpers.edit_link(obj.id, url('/tracks')) #+ helpers.delete_link(obj.id, url('/tracks')) ) elif constants.rights['download']['id'] in right_ids: actions = lambda obj: hoover_actions( helpers.export_link(obj.id, url('/tracks'))) elif constants.rights['upload']['id'] in right_ids: actions = lambda obj: hoover_actions( helpers.edit_link(obj.id, url('/tracks')) + helpers.delete_link(obj.id, url('/tracks'))) else: actions = lambda obj: hoover_actions('') h_info = lambda obj: hide_info({ 'tr_id': obj.id, 'tr_status': obj.status, 'tr_color': helpers.get_track_color(obj), }) fields = [ ('Name', 'name'), (hoover_action, actions), ('Created', 'created'), ('Assembly', 'sequence'), ('Type', 'vizu'), (hidden_info, h_info), ] return twf.DataGrid(fields=fields)
def hoover_actions(actions): return genshi.Markup("<div class='hoover_actions table_hidden'>%s</div>" % actions) def hide_info(dict): span = '' for k, v in dict.iteritems(): span += "<span class='table_hidden %s'>%s</span>" % (k, v) return genshi.Markup("<div class='hidden_info'>%s</div>" % span) sequences_grid = twf.DataGrid(fields=[ ('ID', 'id'), (hoover_action, lambda obj: hoover_actions( helpers.edit_link(obj.id, url('/sequences')) )), ('SPECIES', 'species.name'), ('NAME', 'name'), ('TRACKS', lambda obj: ', '.join(['%s' % (t.name) for t in obj.default_tracks])), ('PUBLIC', 'public'), ('USERS', lambda obj: ', '.join(['%s' % (u.email) for u in obj.users])) ]) """ #column id = Column(Integer, autoincrement=True, primary_key=True) name = Column(Unicode(255), nullable=False) description = Column(Text(), nullable=False) _created = Column(DateTime, nullable=False, default=datetime.now)
def hoover_actions(actions): return genshi.Markup("<div class='hoover_actions table_hidden'>%s</div>" % actions) def hide_info(dict): span = '' for k, v in dict.iteritems(): span += "<span class='table_hidden %s'>%s</span>" % (k, v) return genshi.Markup("<div class='hidden_info'>%s</div>" % span) sequences_grid = twf.DataGrid(fields=[ ('ID', 'id'), (hoover_action, lambda obj: hoover_actions(helpers.edit_link(obj.id, url('/sequences'))) ), ('SPECIES', 'species.name'), ('NAME', 'name'), ('TRACKS', lambda obj: ', '.join(['%s' % (t.name) for t in obj.default_tracks])), ('PUBLIC', 'public' ), ('USERS', lambda obj: ', '.join(['%s' % (u.email) for u in obj.users])) ]) """ #column id = Column(Integer, autoincrement=True, primary_key=True) name = Column(Unicode(255), nullable=False) description = Column(Text(), nullable=False) _created = Column(DateTime, nullable=False, default=datetime.now) user_id = Column(Integer, ForeignKey('User.id', ondelete="CASCADE"), nullable=False) project_id = Column(Integer, ForeignKey('Project.id', ondelete="CASCADE"), nullable=True)