Ejemplo n.º 1
0
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('')
Ejemplo n.º 2
0
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('')
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
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,
        })),
    ])
Ejemplo n.º 6
0
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,
        })),
    ])
Ejemplo n.º 7
0
    ('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,
        })),
    ])


track_grid = twf.DataGrid(fields=[
    ('Name', 'name'),
    (hoover_action, 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'))
    )),
    ('Color', lambda obj: genshi.Markup(helpers.track_color(obj))),
     ('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):
Ejemplo n.º 8
0
        ('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,
        })),
    ])


track_grid = twf.DataGrid(fields=[
    ('Name', 'name'),
    (hoover_action, 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')))),
    ('Color', lambda obj: genshi.Markup(helpers.track_color(obj))),
    ('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: