From d3629dcb5c00fa056dd462861c9b10dc09af6bc9 Mon Sep 17 00:00:00 2001 From: Ryan Herbert Date: Wed, 30 Nov 2016 14:52:06 +0100 Subject: [PATCH] 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. --- .../applications/vidjil/controllers/sample_set.py | 2 +- server/web2py/applications/vidjil/models/SampleSet.py | 6 ++++++ server/web2py/applications/vidjil/models/patient.py | 3 +++ server/web2py/applications/vidjil/models/run.py | 3 +++ .../applications/vidjil/views/sample_set/all.html | 10 +++++----- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/server/web2py/applications/vidjil/controllers/sample_set.py b/server/web2py/applications/vidjil/controllers/sample_set.py index 5a8215a72..5b0b06686 100644 --- a/server/web2py/applications/vidjil/controllers/sample_set.py +++ b/server/web2py/applications/vidjil/controllers/sample_set.py @@ -201,7 +201,7 @@ def all(): return dict(query = result, fields = fields, - type = type, + helper = helper, isAdmin = isAdmin, reverse = False, step = step, diff --git a/server/web2py/applications/vidjil/models/SampleSet.py b/server/web2py/applications/vidjil/models/SampleSet.py index 25e2f13b6..d19e1c86d 100644 --- a/server/web2py/applications/vidjil/models/SampleSet.py +++ b/server/web2py/applications/vidjil/models/SampleSet.py @@ -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, diff --git a/server/web2py/applications/vidjil/models/patient.py b/server/web2py/applications/vidjil/models/patient.py index 65234387b..c4f23fcf6 100644 --- a/server/web2py/applications/vidjil/models/patient.py +++ b/server/web2py/applications/vidjil/models/patient.py @@ -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] diff --git a/server/web2py/applications/vidjil/models/run.py b/server/web2py/applications/vidjil/models/run.py index a2c59026f..6e0d66d30 100644 --- a/server/web2py/applications/vidjil/models/run.py +++ b/server/web2py/applications/vidjil/models/run.py @@ -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] diff --git a/server/web2py/applications/vidjil/views/sample_set/all.html b/server/web2py/applications/vidjil/views/sample_set/all.html index 5af73c5d0..f14fe514d 100644 --- a/server/web2py/applications/vidjil/views/sample_set/all.html +++ b/server/web2py/applications/vidjil/views/sample_set/all.html @@ -8,16 +8,16 @@
search - +
page: {{ if page > 0: }} -
<
+
<
{{ pass }} {{= page + 1 }} {{if len(query) > step : }} -
>
+
>
{{ pass }}
@@ -56,7 +56,7 @@ {{if isAdmin:}} {{else:}} {{pass}} {{if data.has_permission:}} - + {{else:}} {{pass}} {{pass}} @@ -69,7 +69,7 @@
{{if auth.can_create_patient():}} - + new {{=type}} + + new {{=helper.get_type()}} compare samples/patients {{else:}} -- GitLab