diff options
author | Stephen Finucane <stephen@that.guru> | 2016-10-29 14:13:39 +0100 |
---|---|---|
committer | Stephen Finucane <stephen@that.guru> | 2016-10-31 16:37:17 +0000 |
commit | f3c5cb55b617f0837cd558c132a97b010f7d4c91 (patch) | |
tree | 2eede0ef2c7d3c149f8cd77fc82c4ec45ca0daed | |
parent | 5136285b1f0dac3caa251ce8b96173b5a9048ecc (diff) | |
download | patchwork-f3c5cb55b617f0837cd558c132a97b010f7d4c91.tar patchwork-f3c5cb55b617f0837cd558c132a97b010f7d4c91.tar.gz |
templates: Integrate series support
Integrate support for series in the web UI. This is rather
straightforward, the only significant change being the addition of a
filter for series filtering.
Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
Tested-by: Russell Currey <ruscur@russell.cc>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
-rw-r--r-- | patchwork/filters.py | 49 | ||||
-rw-r--r-- | patchwork/templates/patchwork/patch-list.html | 13 | ||||
-rw-r--r-- | patchwork/views/__init__.py | 4 |
3 files changed, 62 insertions, 4 deletions
diff --git a/patchwork/filters.py b/patchwork/filters.py index ea832b7..bc8ca41 100644 --- a/patchwork/filters.py +++ b/patchwork/filters.py @@ -25,7 +25,9 @@ from django.utils.safestring import mark_safe from django.utils import six from django.utils.six.moves.urllib.parse import quote -from patchwork.models import Person, State +from patchwork.models import Person +from patchwork.models import Series +from patchwork.models import State class Filter(object): @@ -82,6 +84,48 @@ class Filter(object): return '%s: %s' % (self.name, self.kwargs()) +class SeriesFilter(Filter): + param = 'series' + name = 'Series' + + def __init__(self, filters): + super(SeriesFilter, self).__init__(filters) + self.series = None + + def _set_key(self, key): + self.series = None + + key = key.strip() + if not key: + return + + try: + self.series = Series.objects.get(id=int(key)) + except (ValueError, Series.DoesNotExist): + return + + self.applied = True + + def kwargs(self): + if self.series: + return {'series': self.series} + return {} + + def condition(self): + if self.series: + return self.series.name + return '' + + def _form(self): + return mark_safe(('<input type="text" name="series" ' + + 'id="series_input" class="form-control">')) + + def key(self): + if self.series: + return self.series.id + return + + class SubmitterFilter(Filter): param = 'submitter' @@ -391,7 +435,8 @@ class DelegateFilter(Filter): self.forced = True -filterclasses = [SubmitterFilter, +filterclasses = [SeriesFilter, + SubmitterFilter, StateFilter, SearchFilter, ArchiveFilter, diff --git a/patchwork/templates/patchwork/patch-list.html b/patchwork/templates/patchwork/patch-list.html index 937a609..4b979ac 100644 --- a/patchwork/templates/patchwork/patch-list.html +++ b/patchwork/templates/patchwork/patch-list.html @@ -83,6 +83,10 @@ $(document).ready(function() { </th> <th> + <span class="colinactive">Series</span> + </th> + + <th> {% project_tags %} </th> @@ -176,6 +180,15 @@ $(document).ready(function() { {{ patch.name|default:"[no subject]"|truncatechars:100 }} </a> </td> + <td> + {% with patch.series.all.0 as series %} + {% if series %} + <a href="?series={{series.id}}"> + {{ series|truncatechars:100 }} + </a> + {% endif %} + {% endwith %} + </td> <td class="text-nowrap">{{ patch|patch_tags }}</td> <td class="text-nowrap">{{ patch|patch_checks }}</td> <td class="text-nowrap">{{ patch.date|date:"Y-m-d" }}</td> diff --git a/patchwork/views/__init__.py b/patchwork/views/__init__.py index 8b5e881..a29da83 100644 --- a/patchwork/views/__init__.py +++ b/patchwork/views/__init__.py @@ -297,8 +297,8 @@ def generic_list(request, project, view, view_args=None, filter_settings=None, # rendering the list template patches = patches.select_related('state', 'submitter', 'delegate') - # we also need checks - patches = patches.prefetch_related('check_set') + # we also need checks and series + patches = patches.prefetch_related('check_set', 'series') paginator = Paginator(request, patches) |