From 2ca15117e4bbda38cda07511d0ff317273f91528 Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Tue, 7 Jan 2014 13:10:42 +0000 Subject: toaster: Toaster GUI, generic search, filter and order This patch implements table searching, filtering and ordering, in a generic mode reusable for all tables. The search operates list of fields defined in the corresponding class for each model, search_allowed_fields. The search expression and filters are sent through GET requests using a QuerySet-like input. The inputs are filtered and validated before usage to prevent inadvertent or malicious use. Filters and table headers are defined in the views for each table, and rendered by generic code which is easily modified for various tables. The Build table and Configuration table are implemented using this framework as an example of how it should be used. [YOCTO #4249] [YOCTO #4254] [YOCTO #4255] [YOCTO #4256] [YOCTO #4257] [YOCTO #4259] [YOCTO #4260] Signed-off-by: Alexandru DAMIAN --- lib/toaster/orm/models.py | 10 +- lib/toaster/toastergui/static/css/default.css | 5 +- .../toastergui/templates/basetable_bottom.html | 13 +- .../toastergui/templates/basetable_top.html | 79 ++-- lib/toaster/toastergui/templates/build.html | 129 ++++--- .../toastergui/templates/configuration.html | 63 +++- lib/toaster/toastergui/templates/configvars.html | 40 ++ .../toastergui/templates/filtersnippet.html | 19 + lib/toaster/toastergui/templatetags/projecttags.py | 9 +- lib/toaster/toastergui/urls.py | 1 + lib/toaster/toastergui/views.py | 412 +++++++++++++-------- 11 files changed, 499 insertions(+), 281 deletions(-) create mode 100644 lib/toaster/toastergui/templates/configvars.html create mode 100644 lib/toaster/toastergui/templates/filtersnippet.html diff --git a/lib/toaster/orm/models.py b/lib/toaster/orm/models.py index b30e405c0..ff26c7d43 100644 --- a/lib/toaster/orm/models.py +++ b/lib/toaster/orm/models.py @@ -31,8 +31,8 @@ class Build(models.Model): (IN_PROGRESS, 'In Progress'), ) - search_allowed_fields = ['machine', - 'cooker_log_path'] + search_allowed_fields = ['machine', 'image_fstypes', + 'cooker_log_path', "target__target"] machine = models.CharField(max_length=100) image_fstypes = models.CharField(max_length=100) @@ -102,6 +102,8 @@ class Task(models.Model): (OUTCOME_NA, 'Not Available'), ) + search_allowed_fields = [ "recipe__name", "task_name" ] + build = models.ForeignKey(Build, related_name='task_build') order = models.IntegerField(null=True) task_executed = models.BooleanField(default=False) # True means Executed, False means Prebuilt @@ -217,6 +219,8 @@ class Layer_Version(models.Model): class Variable(models.Model): + search_allowed_fields = ['variable_name', 'variable_value', + 'variablehistory__file_name', "description"] build = models.ForeignKey(Build, related_name='variable_build') variable_name = models.CharField(max_length=100) variable_value = models.TextField(blank=True) @@ -225,7 +229,7 @@ class Variable(models.Model): description = models.TextField(blank=True) class VariableHistory(models.Model): - variable = models.ForeignKey(Variable) + variable = models.ForeignKey(Variable, related_name='vhistory') file_name = models.FilePathField(max_length=255) line_number = models.IntegerField(null=True) operation = models.CharField(max_length=16) diff --git a/lib/toaster/toastergui/static/css/default.css b/lib/toaster/toastergui/static/css/default.css index 844f6dcd5..53c50043b 100644 --- a/lib/toaster/toastergui/static/css/default.css +++ b/lib/toaster/toastergui/static/css/default.css @@ -171,4 +171,7 @@ dd p {line-height:20px;} .tooltip { z-index: 2000 !important; } /* this makes tooltips work inside modal dialogs */ .tooltip code { background-color:transparent; color:#FFFFFF; font-weight:normal; border:none; font-size: 1em; } .manual { margin-top:11px;} -.heading-help { font-size:14px;} \ No newline at end of file +.heading-help { font-size:14px;} + + +.no-results { margin: 10px 0 0; } diff --git a/lib/toaster/toastergui/templates/basetable_bottom.html b/lib/toaster/toastergui/templates/basetable_bottom.html index 00703fe4c..3e4b0cc5a 100644 --- a/lib/toaster/toastergui/templates/basetable_bottom.html +++ b/lib/toaster/toastergui/templates/basetable_bottom.html @@ -1,3 +1,4 @@ + @@ -8,15 +9,15 @@