Commit d3629dcb authored by HERBERT Ryan's avatar HERBERT Ryan Committed by Mikaël Salson

sample_set* some minor refactoring

passing the helper to the view instead of the type in order to call some
helper functions from the view. Notably to fix the add button which only
worked for generic.
parent 4402838e
......@@ -201,7 +201,7 @@ def all():
return dict(query = result,
fields = fields,
type = type,
helper = helper,
isAdmin = isAdmin,
reverse = False,
step = step,
......
......@@ -3,6 +3,9 @@ class SampleSet(object):
def __init__(self, type):
self.type = type
def get_type(self):
return self.type
def __getitem__(self, key):
return getattr(self, key, None)
......@@ -71,6 +74,9 @@ class SampleSet(object):
row['string'] = [row['name'], row['confs'], row['groups'], str(row['info'])]
return filter(lambda row : vidjil_utils.advanced_filter(row['string'], filter_str), data)
def get_add_route(self):
return 'sample_set/add'
def get_info_dict(self, data):
return dict(name = "sample_set : %s" % db.sample_set[data.sample_set_id].sample_type,
filename = "sample_set_%d" % data.id,
......
......@@ -29,5 +29,8 @@ class Patient(SampleSet):
info = data.info
)
def get_add_route(self):
return 'patient/add'
def get_data(self, sample_set_id):
return db(db.patient.sample_set_id == sample_set_id).select()[0]
......@@ -28,5 +28,8 @@ class Run(SampleSet):
info = data.info
)
def get_add_route(self):
return 'run/add'
def get_data(self, sample_set_id):
return db(db.run.sample_set_id == sample_set_id).select()[0]
......@@ -8,16 +8,16 @@
<div class="db_block">
<div class="db_block_left">
search
<input id="db_filter_input" type="text" value="{{=request.vars["filter"]}}" onchange="db.call('sample_set/all', {'type': '{{=type}}', 'filter' : this.value} )">
<input id="db_filter_input" type="text" value="{{=request.vars["filter"]}}" onchange="db.call('sample_set/all', {'type': '{{=helper.get_type()}}', 'filter' : this.value} )">
</div>
<div class="db_block_right">
page:
{{ if page > 0: }}
<div class="button" onclick="db.call('sample_set/all', {'type': '{{=type}}', 'page': {{=page-1}}})"><</div>
<div class="button" onclick="db.call('sample_set/all', {'type': '{{=helper.get_type()}}', 'page': {{=page-1}}})"><</div>
{{ pass }}
{{= page + 1 }}
{{if len(query) > step : }}
<div class="button" onclick="db.call('sample_set/all', {'type': '{{=type}}', 'page': {{=page+1}}})">></div>
<div class="button" onclick="db.call('sample_set/all', {'type': '{{=helper.get_type()}}', 'page': {{=page+1}}})">></div>
{{ pass }}
</div>
</div>
......@@ -56,7 +56,7 @@
{{if isAdmin:}} <td onclick="db.call('sample_set/permission', {'id' :'{{=data.id}}'} )" > <i class="icon-key" title="set permissions"></i> </td> {{else:}} <td></td> {{pass}}
{{if data.has_permission:}}
<td onclick="db.call('sample_set/edit', {'id' :'{{=data.id}}'} )" > <i class="icon-pencil-2" title="{{='edit %s information' % 'sample_set'}}"></i> </td>
<td onclick="db.call('sample_set/confirm', {'id' :'{{=data.id}}'} )" > <i class="icon-erase" title="{{='delete %s' % type}}"></i> </td>
<td onclick="db.call('sample_set/confirm', {'id' :'{{=data.id}}'} )" > <i class="icon-erase" title="{{='delete %s' % helper.get_type()}}"></i> </td>
{{else:}} <td></td><td></td>{{pass}}
</tr>
{{pass}}
......@@ -69,7 +69,7 @@
<div class="db_block_left">
{{if auth.can_create_patient():}}
<span class="button2" onclick="db.call('sample_set/add')"> + new {{=type}} </span>
<span class="button2" onclick="db.call('{{=helper.get_add_route()}}')"> + new {{=helper.get_type()}} </span>
<span class="button2" onclick="db.call('sample_set/custom', {'filter': '{{=request.vars['filter']}}' })"> compare samples/patients </span>
{{else:}}
<!-- <span class="button2 inactive" onclick="db.call('sample_set/add')" title="you don't have permission to create new {{=type}}"> add sample_set </span> -->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment