[PATCH 07/10] templates: Integrate series support

Andy Doan andy.doan at linaro.org
Fri Jun 24 04:26:44 AEST 2016


On 06/13/2016 05:41 AM, Stephen Finucane wrote:
> 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.finucane at intel.com>

Reviewed-by: Andy Doan <andy.doan at linaro.org>

> ---
>   patchwork/filters.py                          |   56 ++++++++++++++++++++++++-
>   patchwork/templates/patchwork/patch-list.html |   12 +++++
>   2 files changed, 66 insertions(+), 2 deletions(-)
>
> diff --git a/patchwork/filters.py b/patchwork/filters.py
> index 5650014..264ef24 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 SeriesRevision
> +from patchwork.models import State
>
>
>   class Filter(object):
> @@ -80,6 +82,55 @@ 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
> +        series_id = None
> +
> +        key = key.strip()
> +        if not key:
> +            return
> +
> +        try:
> +            series_id = int(key)
> +        except ValueError:
> +            pass
> +        except Exception:
> +            return
> +
> +        if not series_id:
> +            return
> +
> +        self.series = SeriesRevision.objects.get(id=series_id)
> +        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'
>
> @@ -399,7 +450,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 b7648d3..0050ab0 100644
> --- a/patchwork/templates/patchwork/patch-list.html
> +++ b/patchwork/templates/patchwork/patch-list.html
> @@ -83,6 +83,11 @@ $(document).ready(function() {
>      </th>
>
>      <th>
> +    <!-- TODO(stephenfin) Make this column sortable -->
> +    <span class="colinactive">Series</span>
> +   </th>
> +
> +   <th>
>       {% project_tags %}
>      </th>
>
> @@ -176,6 +181,13 @@ $(document).ready(function() {
>        {{ patch.name|default:"[no subject]"|truncatechars:100 }}
>       </a>
>      </td>
> +   <td>
> +    {% if patch.series %}
> +    <a href="?series={{patch.series.id}}">
> +     {{ patch.series.name|truncatechars:100 }}
> +    </a>

This produces a column like "[00/10] Add series support". Should we 
filter out the [00/10] part to make the column nicer to read?

> +    {% endif %}
> +   </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>
>


More information about the Patchwork mailing list