diff --git a/atdb/atdb/settings/base.py b/atdb/atdb/settings/base.py index 547df94eade771fc771ca22717f29fce705346a1..080ef9e46e81495da3f8a5e2b6206f6f612cefb1 100644 --- a/atdb/atdb/settings/base.py +++ b/atdb/atdb/settings/base.py @@ -43,6 +43,8 @@ INSTALLED_APPS = [ 'django_filters', 'django_extensions', 'bootstrap_pagination', + 'django_tables2', + 'bootstrap3' ] MIDDLEWARE = [ diff --git a/atdb/requirements/base.txt b/atdb/requirements/base.txt index 1f1472aa4750ac24961049ebd37503988b0883c4..844e68d1e692ed24d50f156e72de29136a3ca92d 100644 --- a/atdb/requirements/base.txt +++ b/atdb/requirements/base.txt @@ -7,3 +7,5 @@ django-extensions==3.1.0 django-bootstrap-pagination==1.7.0 whitenoise==5.0.1 six==1.15.0 +django-tables2-2.3.4 +django-bootstrap3-14.2.0 \ No newline at end of file diff --git a/atdb/taskdatabase/models.py b/atdb/taskdatabase/models.py index 3cc13d894c8c299206a6f9c8c17fb98be74c873b..f264735f284f6c8fa0721d77c1002e6f19e900c3 100644 --- a/atdb/taskdatabase/models.py +++ b/atdb/taskdatabase/models.py @@ -25,7 +25,7 @@ class Task(models.Model): status = models.CharField(db_index=True, default="unknown", max_length=50,blank=True, null=True) resume = models.BooleanField(default=True) - creationTime = models.DateTimeField(default=datetime.utcnow, blank=True) + creationTime = models.DateTimeField(verbose_name="CreationTime",default=datetime.utcnow, blank=True) priority = models.IntegerField(default=100, null=True) purge_policy = models.CharField(max_length=5, default="no", blank=True, null=True) diff --git a/atdb/taskdatabase/tables.py b/atdb/taskdatabase/tables.py new file mode 100644 index 0000000000000000000000000000000000000000..cf035b11bfbeeb84dbe2af2bf837af6f1e7fd647 --- /dev/null +++ b/atdb/taskdatabase/tables.py @@ -0,0 +1,33 @@ +# tables.py +import django_tables2 as tables +from .models import Task + +# render the StatusColumn based on the style.css +class StatusColumn(tables.Column): + attrs = { + "td": { + "class": lambda record: record.status + }, + "tr": { + "class": lambda record: record.status + } + } + def render(self, record): + return "{}".format(record.status) + + +class TaskTable(tables.Table): + + class Meta: + model = Task + template_name = "django_tables2/bootstrap4.html" + fields = ("id", "priority", "status", "project", "sas_id", "workflow", "creationtime", "size_to_process","buttons") + + # columns that need specific rendering + status = StatusColumn() + creationtime = tables.Column(verbose_name='CreationTime') + + buttons = tables.TemplateColumn(verbose_name='Actions', + template_name='tables2/buttons.html', + orderable=False) # orderable not sortable + diff --git a/atdb/taskdatabase/templates/dashboard/base.html b/atdb/taskdatabase/templates/dashboard/base.html index 114f614a2b4b3c7e6433bfafaf1449cb7da6baf8..9964dc807362b2c37e8f31da80b8ac3b4dbf2d2f 100644 --- a/atdb/taskdatabase/templates/dashboard/base.html +++ b/atdb/taskdatabase/templates/dashboard/base.html @@ -1,4 +1,5 @@ <!DOCTYPE html> +{% load static %} <html lang="en"> <head> @@ -12,11 +13,10 @@ <title>{% block title %}{% endblock %}</title> <!-- Custom fonts for this template--> - <link href="/static/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css"> + <link href="{% static 'vendor/fontawesome-free/css/all.min.css' %}" rel="stylesheet" type="text/css"> <!-- Page level plugin CSS--> - <link href="/static/vendor/datatables/dataTables.bootstrap4.css" rel="stylesheet"> - + <link href="{% static 'vendor/datatables/dataTables.bootstrap4.css' %}" rel="stylesheet"> {% block links %} {% endblock %} diff --git a/atdb/taskdatabase/templates/dashboard/index.html b/atdb/taskdatabase/templates/dashboard/index.html index c8edf442e0d07731a5a26be73917d59723745086..47a0f653b794719bb207002459738adc88074a0f 100644 --- a/atdb/taskdatabase/templates/dashboard/index.html +++ b/atdb/taskdatabase/templates/dashboard/index.html @@ -1,10 +1,10 @@ {% extends "dashboard/base.html" %} - +{% load static %} {% block title %}LDV Dashboard{% endblock %} {% block links %} <!-- Custom styles for this template--> - <link href="/static/css/sb-admin.css" rel="stylesheet"> + <link href="{% static 'css/sb-admin.css' %}" rel="stylesheet"> {% endblock %} {% block body %} <body id="page-top"> diff --git a/atdb/taskdatabase/templates/tables2/base.html b/atdb/taskdatabase/templates/tables2/base.html new file mode 100644 index 0000000000000000000000000000000000000000..2c7e0811b958a9be37548054f6be5cb1ffd29d96 --- /dev/null +++ b/atdb/taskdatabase/templates/tables2/base.html @@ -0,0 +1,52 @@ + +<!DOCTYPE html> + +<!-- loads the path to static files --> +{% load static %} + +<html lang="en"> +<head> + + <!-- Required meta tags --> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> + + <title>{% block myBlockTitle %}ATDB-LDV{% endblock %}</title> + + <!-- loads bootstrap --> + + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" /> + <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script> + <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script> + + <link rel="stylesheet" type="text/css" href="{% static 'taskdatabase/style.css' %}"/> + <link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'> + <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" integrity="sha384-/rXc/GQVaYpyDdyxK+ecHPVYJSN9bmVFBvjA/9eOB+pb3F2w2N6fc5qB9Ew5yIns" crossorigin="anonymous"> + + <link rel="icon" href="{% static 'favicon.ico' %}"> + + {% block extra_js %}{% endblock %} + +</head> +<body> + <nav class="navbar navbar-expand-lg navbar-light bg-light"> + <div class="container-fluid"> + + <!-- Header --> + <div class="navbar-header"> + <a class="navbar-brand mb-0 h1"> + + <img src="{% static 'taskdatabase/ldvlogo.png' %}" height="90" alt=""> + </a> + </div> + </div> + {% include 'taskdatabase/search.html' %} + </nav> + + <!-- to add blocks of code --> + {% block myBlock %} + {% endblock %} + +</body> +</html> \ No newline at end of file diff --git a/atdb/taskdatabase/templates/tables2/buttons.html b/atdb/taskdatabase/templates/tables2/buttons.html new file mode 100644 index 0000000000000000000000000000000000000000..3d0b16a3070df64a62a1532f9f6d0af54d68c662 --- /dev/null +++ b/atdb/taskdatabase/templates/tables2/buttons.html @@ -0,0 +1,20 @@ + +{% if record.status == "defining" %} + <a href="{% url 'task-setstatus' record.pk 'defined' '1' %}" class="btn btn-success btn-sm" role="button">Stage</a> + {% endif %} + + {% if record.status != "defining" %} + <a href="{% url 'task-setstatus' record.pk 'defining' '1' %}" class="btn btn-warning btn-sm" role="button">Reset</a> + {% endif %} + + <a href="{% url 'task-setstatus' record.pk 'staged' '1' %}" class="btn btn-primary btn-sm" role="button">staged</a> + <a href="{% url 'task-setstatus' record.pk 'processed' '1' %}" class="btn btn-primary btn-sm" role="button">processed</a> + <a href="{% url 'task-setstatus' record.pk 'validated' '1' %}" class="btn btn-primary btn-sm" role="button">validated</a> + <a href="{% url 'task-setstatus' record.pk 'scrub' '1' %}" class="btn btn-warning btn-sm" role="button">scrub</a> + <a href="{% url 'task-setstatus' record.pk 'scrubbed' '1' %}" class="btn btn-primary btn-sm" role="button">scrubbed</a> + <a href="{% url 'task-setstatus' record.pk 'archived' '1' %}" class="btn btn-primary btn-sm" role="button">archived</a> + <a href="{% url 'task-setstatus' record.pk 'finished' '1' %}" class="btn btn-primary btn-sm" role="button">finished</a> + + {% if record.status == "processed" %} + <a href="{% url 'task-setstatus' record.pk 'validated' '1' %}" class="btn btn-success btn-sm" role="button">Validate</a> + {% endif %} diff --git a/atdb/taskdatabase/templates/tables2/index.html b/atdb/taskdatabase/templates/tables2/index.html new file mode 100644 index 0000000000000000000000000000000000000000..7d27fdc5b11ce9a551b6b43741acf3ec3548e927 --- /dev/null +++ b/atdb/taskdatabase/templates/tables2/index.html @@ -0,0 +1,42 @@ +{% extends 'tables2/base.html' %} +{% load render_table from django_tables2 %} +{% load bootstrap3 %} + +{# Load CSS and JavaScript #} +{% bootstrap_css %} +{% bootstrap_javascript %} + +{% block myBlock %} + +<div class="container-fluid details-container"> + <h4>Tasks</h4> + + {% if filter %} + <form action="" method="get" class="form form-inline"> + {% bootstrap_form filter.form layout='inline' %} + {% bootstrap_button 'filter' %} + </form> + {% endif %} + {% render_table table 'django_tables2/bootstrap4.html' %} + +</div> + +<p class="footer"> Version 1.0.0 (2 mar 2021 - 14:30) +<script type="text/javascript"> + (function(seconds) { + var refresh, + intvrefresh = function() { + clearInterval(refresh); + refresh = setTimeout(function() { + //location.href = location.href; + location.reload(); + }, seconds * 1000); + }; + + $(document).on('keypress click', function() { intvrefresh() }); + intvrefresh(); + + }(10)); +</script> + +{% endblock %} \ No newline at end of file diff --git a/atdb/taskdatabase/templates/tables2/tables2.html b/atdb/taskdatabase/templates/tables2/tables2.html new file mode 100644 index 0000000000000000000000000000000000000000..e2455f67949d12c8f449d6a148511ce5bf795560 --- /dev/null +++ b/atdb/taskdatabase/templates/tables2/tables2.html @@ -0,0 +1,11 @@ +{% load render_table from django_tables2 %} +<!doctype html> +<html> + <head> + <title>ATDB Tables2</title> + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" /> + </head> + <body> + {% render_table table %} + </body> +</html> \ No newline at end of file diff --git a/atdb/taskdatabase/templates/taskdatabase/base.html b/atdb/taskdatabase/templates/taskdatabase/base.html index 6831dc1ab833a7d26f73ae86616c54a7e08f2def..b15c3365d08413bd67cc339936732dde09cad8d1 100644 --- a/atdb/taskdatabase/templates/taskdatabase/base.html +++ b/atdb/taskdatabase/templates/taskdatabase/base.html @@ -19,7 +19,7 @@ <link rel="stylesheet" type="text/css" href="{% static 'taskdatabase/style.css' %}"/> <link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'> - <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" integrity="sha384-/rXc/GQVaYpyDdyxK+ecHPVYJSN9bmVFBvjA/9eOB+pb3F2w2N6fc5qB9Ew5yIns" crossorigin="anonymous"> + <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" integrity="sha384-/rXc/GQVaYpyDdyxK+ecHPVYJSN9bmVFBvjA/9eOB+pb3F2w2N6fc5qB9Ew5yIns" crossorigin="anonymous"> <link rel="icon" href="{% static 'favicon.ico' %}"> @@ -35,15 +35,13 @@ <a class="navbar-brand mb-0 h1"> <img src="{% static 'taskdatabase/ldvlogo.png' %}" height="90" alt=""> -<!-- - <img src="{% static 'taskdatabase/atdb_logo.jpg' %}" width="180" height="90" alt=""> ---> </a> </div> </div> {% include 'taskdatabase/search.html' %} + </nav> <!-- to add blocks of code --> diff --git a/atdb/taskdatabase/templates/taskdatabase/filter_buttons.html b/atdb/taskdatabase/templates/taskdatabase/filter_buttons.html new file mode 100644 index 0000000000000000000000000000000000000000..b95ee0cdb8bdccb5648547bc0faa5104a70a3143 --- /dev/null +++ b/atdb/taskdatabase/templates/taskdatabase/filter_buttons.html @@ -0,0 +1,22 @@ +<table> +<tr> + <h5>Click to Filter<h5> + <td> + <a href="{% url 'task-set-filter' 'all' %}" class="btn btn-success btn-sm" role="button">ALL</a> + <a href="{% url 'task-set-filter' 'defined' %}" class="btn btn-primary btn-sm" role="button">defined</a> + <a href="{% url 'task-set-filter' 'staging' %}" class="btn btn-secondary btn-sm" role="button">staging</a> + <a href="{% url 'task-set-filter' 'staged' %}" class="btn btn-primary btn-sm" role="button">staged</a> + <a href="{% url 'task-set-filter' 'processing' %}" class="btn btn-secondary btn-sm" role="button">processing</a> + <a href="{% url 'task-set-filter' 'processed' %}" class="btn btn-success btn-sm" role="button">processed</a> + <a href="{% url 'task-set-filter' 'validated' %}" class="btn btn-primary btn-sm" role="button">validated</a> + <a href="{% url 'task-set-filter' 'scrub' %}" class="btn btn-secondary btn-sm" role="button">to scrub</a> + <a href="{% url 'task-set-filter' 'scrubbing' %}" class="btn btn-secondary btn-sm" role="button">scrubbing</a> + <a href="{% url 'task-set-filter' 'scrubbed' %}" class="btn btn-primary btn-sm" role="button">scrubbed</a> + <a href="{% url 'task-set-filter' 'archiving' %}" class="btn btn-secondary btn-sm" role="button">archiving</a> + <a href="{% url 'task-set-filter' 'archived' %}" class="btn btn-primary btn-sm" role="button">archived</a> + <a href="{% url 'task-set-filter' 'finished' %}" class="btn btn-primary btn-sm" role="button">finished</a> + <a href="{% url 'task-set-filter' 'failed' %}" class="btn btn-danger btn-sm" role="button">failed</a> + + </td> +</tr> +</table> \ No newline at end of file diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html index 25b0c5e7740aa71146ca305ea292ed5cdad5bc38..c563eba698e603f943b5c8283ff1b99d3ba9fc48 100644 --- a/atdb/taskdatabase/templates/taskdatabase/index.html +++ b/atdb/taskdatabase/templates/taskdatabase/index.html @@ -1,20 +1,22 @@ {% extends 'taskdatabase/base.html' %} {% load static %} -{% block myBlock %} +{% block myBlock %} <div class="container-fluid details-container"> - <h4>Tasks</h4> {% include 'taskdatabase/pagination.html' %} + <div class="row"> <div class="col-sm-12 col-md-12 col-lg-12"> + {% include 'taskdatabase/filter_buttons.html' %} {% if my_tasks %} <div class="panel panel-success"> <div class="panel-body"> <table class="table table-striped table-bordered table-sm"> + <thead> <tr> <th width="5%">ID</th> @@ -31,7 +33,6 @@ </thead> <tbody> {% include 'taskdatabase/tasks.html' %} - </tbody> </table> {% else %} @@ -45,39 +46,40 @@ </div> {% include 'taskdatabase/pagination.html' %} </div> - <p class="footer"> Version 1.0.0 (1 mar 2021 - 14:30) - <script type="text/javascript"> - (function(seconds) { - var refresh, - intvrefresh = function() { - clearInterval(refresh); - refresh = setTimeout(function() { - //location.href = location.href; - location.reload(); - }, seconds * 1000); - }; - - $(document).on('keypress click', function() { intvrefresh() }); - intvrefresh(); - - }(10)); - </script> - - <script type="text/javascript"> - function readFromLocalStorage(id) { - var s = localStorage.getItem(id); - if (s !== null) { - document.getElementById(id).value = s; - } - } - </script> - - <script type="text/javascript"> - function writeToLocalStorage(id) { - var s = document.getElementById(id).value - localStorage.setItem(id, s); + +<p class="footer"> Version 1.0.0 (2 mar 2021 - 15:00) +<script type="text/javascript"> + (function(seconds) { + var refresh, + intvrefresh = function() { + clearInterval(refresh); + refresh = setTimeout(function() { + //location.href = location.href; + location.reload(); + }, seconds * 1000); + }; + + $(document).on('keypress click', function() { intvrefresh() }); + intvrefresh(); + + }(10)); +</script> + +<script type="text/javascript"> + function readFromLocalStorage(id) { + var s = localStorage.getItem(id); + if (s !== null) { + document.getElementById(id).value = s; + } } - </script> +</script> + +<script type="text/javascript"> +function writeToLocalStorage(id) { + var s = document.getElementById(id).value + localStorage.setItem(id, s); +} +</script> {% endblock %} diff --git a/atdb/taskdatabase/templates/taskdatabase/tasks.html b/atdb/taskdatabase/templates/taskdatabase/tasks.html index fe7eb6288994ae49d83701370a329edbbf68ddba..929f2fdbc9f817b654ab21071662932fefb02b6e 100644 --- a/atdb/taskdatabase/templates/taskdatabase/tasks.html +++ b/atdb/taskdatabase/templates/taskdatabase/tasks.html @@ -9,9 +9,9 @@ <a href="{{ task.get_absolute_url }}" target="_blank">{{ task.id }} </a> </td> <td> - <a href="{% url 'task-setstatus-view' task.pk 'lower' my_tasks.number %}" class="btn btn-primary btn-sm" role="button">-</a> + <a href="{% url 'task-change-priority' task.pk '-10' my_tasks.number %}" class="btn btn-primary btn-sm" role="button">-10</a> {{ task.priority }} - <a href="{% url 'task-setstatus-view' task.pk 'higher' my_tasks.number %}" class="btn btn-primary btn-sm" role="button">+</a> + <a href="{% url 'task-change-priority' task.pk '10' my_tasks.number %}" class="btn btn-primary btn-sm" role="button">+10</a> </td> <td>{{ task.status }}</td> diff --git a/atdb/taskdatabase/urls.py b/atdb/taskdatabase/urls.py index 1e0931e9ae00bd5d63ade9db57afccf4b7c409ad..8cdce933fee8bab94b104bf0e01a4fbf51965764 100644 --- a/atdb/taskdatabase/urls.py +++ b/atdb/taskdatabase/urls.py @@ -6,9 +6,13 @@ urlpatterns = [ # --- GUI --- path('', views.IndexView.as_view(), name='index'), + path('dashboard/', views.DashboardView.as_view(), name='dashboard'), path('dashboard/charts', views.ChartsView.as_view(), name='dashboard-charts'), + path('tables2basic/', views.TaskTables2View.as_view(), name='tasktables2'), + path('tables2/', views.FilteredTaskListView.as_view(), name='tables2'), + # --- REST API --- path('tasks/', views.TaskListViewAPI.as_view()), path('tasks/<int:pk>/', views.TaskDetailsViewAPI.as_view(), name='task-detail-view-api'), @@ -25,16 +29,14 @@ urlpatterns = [ # --- custom requests --- # /atdb/get_size?status__in=defined,staged - path('tasks/get_size', - views.GetSizeView.as_view(), - name='get-size-view'), + path('tasks/get_size', views.GetSizeView.as_view(), name='get-size-view'), # --- controller resources --- - path('tasks/<int:pk>/setstatus/<new_status>/<page>', - views.TaskSetStatus, - name='task-setstatus-view'), + path('tasks/<int:pk>/setstatus/<new_status>/<page>', views.TaskSetStatus, name='task-setstatus-view'), + path('tasks/<int:pk>/change_priority/<priority_change>/<page>', views.TaskChangePriority, name='task-change-priority'), + path('tasks/set_filter/<filter>', views.TaskSetFilter, name='task-set-filter'), + + path('tasks/<int:pk>/set_status/<new_status>/<page>', views.TaskSetStatusTables2, name = 'task-setstatus'), - path('tasks/<int:pk>/skip/<skip_it>/<page>', - views.Skip, - name='task-skip-view'), + path('tasks/<int:pk>/skip/<skip_it>/<page>', views.Skip, name='task-skip-view'), ] \ No newline at end of file diff --git a/atdb/taskdatabase/views.py b/atdb/taskdatabase/views.py index 497626a75db4d0036a705368fbe180ea0b56cd56..629c4cf6c5f0477862598f40133e479da4416614 100644 --- a/atdb/taskdatabase/views.py +++ b/atdb/taskdatabase/views.py @@ -9,10 +9,17 @@ from django.views.generic import ListView from rest_framework import generics, pagination from rest_framework.response import Response from django_filters import rest_framework as filters +from django_filters.views import FilterView +from django_tables2.views import SingleTableMixin + from django.shortcuts import render, redirect from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger +from django_tables2 import SingleTableView + from .models import Task, Status, Workflow, LogEntry, Configuration +from .tables import TaskTable + from django.db.models import Q from .serializers import \ TaskWriteSerializer, \ @@ -41,6 +48,19 @@ class TaskFilter(filters.FilterSet): 'priority': ['exact'], } +class TaskFilterGUI(filters.FilterSet): + + class Meta: + model = Task + + fields = { + 'priority': ['exact'], + 'status': ['icontains', 'in'], + 'project': ['icontains'], + 'sas_id': ['icontains'], + } + + class WorkflowFilter(filters.FilterSet): class Meta: @@ -71,6 +91,13 @@ class ConfigurationFilter(filters.FilterSet): 'key': ['exact', 'icontains'], } +# implementation with tables2: http://localhost:8000/atdb/tables2 +class FilteredTaskListView(SingleTableMixin, FilterView): + table_class = TaskTable + model = Task + template_name = "tables2/index.html" + filterset_class = TaskFilterGUI + # ---------- GUI Views ----------- class IndexView(ListView): @@ -88,17 +115,19 @@ class IndexView(ListView): not_status = self.request.GET.get('not_status') search_box = self.request.GET.get('search_box', None) + tasks = Task.objects.order_by('-creationTime') + + try: + filter = self.request.session['task_filter'] + if filter!='all': + tasks = get_searched_tasks(filter) + except: + pass + if (search_box is not None): tasks = get_searched_tasks(search_box) - else: - tasks = Task.objects.order_by('-creationTime') - if (status is not None): - tasks = get_filtered_tasks(status) - if (not_status is not None): - tasks = get_unfiltered_tasks(not_status) paginator = Paginator(tasks, config.TASKS_PER_PAGE) # Show 50 tasks per page - page = self.request.GET.get('page') try: @@ -112,23 +141,10 @@ class IndexView(ListView): return tasks -# an attempt to get a filtering mechanism in the GUI -# filter on a single status -# http://localhost:8000/atdb/query?status=scheduled -def get_filtered_tasks(status): - q = Task.objects.order_by('-creationTime') - q = q.filter(status=status) - #q = q.exclude(status__icontains='removed') - return q - -# http://localhost:8000/atdb/query?not_status=removed -def get_unfiltered_tasks(status): - q = Task.objects.order_by('-creationTime') - q = q.exclude(status=status) - return q def get_searched_tasks(search): tasks = Task.objects.filter( + Q(id__contains=search) | Q(sas_id__contains=search) | Q(task_type__icontains=search) | Q(status__icontains=search) | @@ -137,9 +153,6 @@ def get_searched_tasks(search): class DashboardView(ListView): - """ - This is the main view of ATDB. It shows a pagination list of tasks, sorted by creationTime. - """ template_name = 'dashboard/index.html' model = Task queryset = Task.objects.all() @@ -148,15 +161,19 @@ class DashboardView(ListView): context_object_name = 'my_tasks' class ChartsView(ListView): - """ - This is the main view of ATDB. It shows a pagination list of tasks, sorted by creationTime. - """ + template_name = 'dashboard/charts.html' model = Task queryset = Task.objects.all() # by default this returns the list in an object called object_list, so use 'object_list' in the html page. # but if 'context_object_name' is defined, then this returned list is named and can be accessed that way in html. context_object_name = 'my_tasks' + +class TaskTables2View(SingleTableView): + model = Task + table_class = TaskTable + template_name = 'tables2/tables2.html' + # ---------- REST API views ----------- # example: /atdb/tasks/ @@ -284,6 +301,27 @@ def TaskSetStatus(request,pk,new_status,page): return redirect('/atdb/?page='+page) +def TaskSetFilter(request,filter): + request.session['task_filter'] = filter + return redirect('/atdb/?page=1') + + +def TaskChangePriority(request,pk,priority_change,page): + model = Task + task = Task.objects.get(pk=pk) + priority = task.priority + int(priority_change) + task.priority = priority + task.save() + return redirect('/atdb/?page='+page) + + +def TaskSetStatusTables2(request,pk,new_status,page): + model = Task + task = Task.objects.get(pk=pk) + task.new_status = new_status + task.save() + return redirect('/atdb/tables2/?page='+page) + # /atdb/get_size?status__in=defined,staged class GetSizeView(generics.ListAPIView): queryset = Task.objects.all()