summaryrefslogtreecommitdiffstats
path: root/lib/toaster/toastergui/templatetags
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2014-01-07 13:10:42 +0000
committerPaul Eggleton <paul.eggleton@linux.intel.com>2014-01-10 14:13:53 +0000
commit2ca15117e4bbda38cda07511d0ff317273f91528 (patch)
treedb0342b2d339e9cb2369b2427134d221a3e8f142 /lib/toaster/toastergui/templatetags
parentbf7fbf5c0ee39564d813f82e194242f9d4f73c47 (diff)
downloadbitbake-2ca15117e4bbda38cda07511d0ff317273f91528.tar.gz
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 <alexandru.damian@intel.com>
Diffstat (limited to 'lib/toaster/toastergui/templatetags')
-rw-r--r--lib/toaster/toastergui/templatetags/projecttags.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/toaster/toastergui/templatetags/projecttags.py b/lib/toaster/toastergui/templatetags/projecttags.py
index 145502675..15a1757b3 100644
--- a/lib/toaster/toastergui/templatetags/projecttags.py
+++ b/lib/toaster/toastergui/templatetags/projecttags.py
@@ -16,8 +16,9 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-from datetime import datetime
+from datetime import datetime, timedelta
from django import template
+from django.utils import timezone
register = template.Library()
@@ -42,8 +43,14 @@ def query(qs, **kwargs):
@register.filter
def divide(value, arg):
+ if int(arg) == 0:
+ return -1
return int(value) / int(arg)
@register.filter
def multiply(value, arg):
return int(value) * int(arg)
+
+@register.assignment_tag
+def datecompute(delta, start = timezone.now()):
+ return start + timedelta(delta)