Commit 61ff3343 authored by Mathieu Giraud's avatar Mathieu Giraud

models/SampleSet.py, views/sample_set/all.html: define and use SampleSet.get_type_display()

Following the previous commit, we encode a new method to display 'set' for SET_TYPE_GENERIC.
See #2282.
parent 6ebff939
...@@ -6,6 +6,9 @@ class SampleSet(object): ...@@ -6,6 +6,9 @@ class SampleSet(object):
def get_type(self): def get_type(self):
return self.type return self.type
def get_type_display(self):
return 'set' if self.type == defs.SET_TYPE_GENERIC else self.type
  • Le polymorphisme n'aurait pas été plus efficace ici ? (comme ceci: 963241a0 )

  • Même, dans mon example, le 'set' en dur pourrait (voire devrait ?) référencer la variable dans defs.py

    Edited by Ryan Herbert
Please register or sign in to reply
def __getitem__(self, key): def __getitem__(self, key):
return getattr(self, key, None) return getattr(self, key, None)
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
{{if isAdmin:}} <td onclick="db.call('sample_set/permission', {'id' :'{{=data.sample_set_id}}'} )" > <i class="icon-key" title="set permissions"></i> </td> {{else:}} <td></td> {{pass}} {{if isAdmin:}} <td onclick="db.call('sample_set/permission', {'id' :'{{=data.sample_set_id}}'} )" > <i class="icon-key" title="set permissions"></i> </td> {{else:}} <td></td> {{pass}}
{{if data.has_permission:}} {{if data.has_permission:}}
<td onclick="db.call('sample_set/edit', {'id' :'{{=data.sample_set_id}}'} )" > <i class="icon-pencil-2" title="{{='edit %s information' % 'sample_set'}}"></i> </td> <td onclick="db.call('sample_set/edit', {'id' :'{{=data.sample_set_id}}'} )" > <i class="icon-pencil-2" title="{{='edit %s information' % 'sample_set'}}"></i> </td>
<td onclick="db.call('sample_set/confirm', {'id' :'{{=data.sample_set_id}}'} )" > <i class="icon-erase" title="{{='delete %s' % helper.get_type()}}"></i> </td> <td onclick="db.call('sample_set/confirm', {'id' :'{{=data.sample_set_id}}'} )" > <i class="icon-erase" title="{{='delete %s' % helper.get_type_display()}}"></i> </td>
{{else:}} <td></td><td></td>{{pass}} {{else:}} <td></td><td></td>{{pass}}
</tr> </tr>
{{pass}} {{pass}}
...@@ -59,16 +59,16 @@ ...@@ -59,16 +59,16 @@
<div class="db_block_left"> <div class="db_block_left">
{{if auth.can_create_patient():}} {{if auth.can_create_patient():}}
<span class="button2" onclick="db.call('{{=helper.get_add_route()}}')"> + new {{=helper.get_type()}} </span> <span class="button2" onclick="db.call('{{=helper.get_add_route()}}')"> + new {{=helper.get_type_display()}} </span>
<span class="button2" onclick="db.call('sample_set/custom', {'filter': '{{=request.vars['filter']}}' })"> compare samples/patients </span> <span class="button2" onclick="db.call('sample_set/custom', {'filter': '{{=request.vars['filter']}}' })"> compare samples/patients </span>
{{else:}} {{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> --> <!-- <span class="button2 inactive" onclick="db.call('sample_set/add')" title="you don't have permission to create new {{=helper.get_type_display()}}s"> add sample_set </span> -->
{{pass}} {{pass}}
</div> </div>
<div class="db_block_right"> <div class="db_block_right">
<br /> <br />
{{ =min(step, len(query)) }} {{=helper.get_type()}}s, {{ =total_file_count }} files ({{ =vidjil_utils.format_size(total_size) }}) {{ =min(step, len(query)) }} {{=helper.get_type_display()}}s, {{ =total_file_count }} files ({{ =vidjil_utils.format_size(total_size) }})
</div> </div>
</div> </div>
<div class="db_block_center"> <div class="db_block_center">
......
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