Skip to content

Commit fe7c868

Browse files
andrepapotivictor-accarini
authored andcommitted
views: add series-list view
This view is meant to give a quickoverview on a project since some of them can have hundreds of patches actives. This view also allows the user to apply changes on all of the series patches at once Signed-off-by: andrepapoti <andrepapoti@gmail.com>
1 parent 16d23ea commit fe7c868

File tree

5 files changed

+172
-0
lines changed

5 files changed

+172
-0
lines changed

htdocs/css/style.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,12 @@ span.p_mod { color: #a020f0; }
407407
font-weight: bold;
408408
}
409409

410+
/* series */
411+
a.series-list-header {
412+
color: inherit; /* Inherit color from parent element */
413+
text-decoration: none; /* Optional: removes underline */
414+
}
415+
410416
/* bundles */
411417
table.bundlelist {
412418
margin-top: 2em;
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{% extends "base.html" %}
2+
3+
{% load person %}
4+
{% load static %}
5+
6+
{% block title %}{{project.name}}{% endblock %}
7+
{% block series_active %}active{% endblock %}
8+
9+
{% block body %}
10+
11+
{% load person %}
12+
{% load listurl %}
13+
{% load patch %}
14+
{% load project %}
15+
{% load static %}
16+
17+
{% include "patchwork/partials/pagination.html" %}
18+
19+
<input type="hidden" name="form" value="serieslistform"/>
20+
<input type="hidden" name="project" value="{{project.id}}"/>
21+
22+
<table id="serieslist" class="table table-hover table-extra-condensed table-striped pw-list" data-toggle="checkboxes" data-range="true">
23+
<thead>
24+
<tr>
25+
{% if user.is_authenticated and user.profile.show_ids %}
26+
<th>
27+
ID
28+
</th>
29+
{% endif %}
30+
31+
<th>
32+
<span class="series-list-header">Series</span>
33+
</th>
34+
35+
<th>
36+
Version
37+
</th>
38+
39+
<th>
40+
<span class="series-list-header">Cover Letter</span>
41+
</th>
42+
43+
<th>
44+
<span class="series-list-header">Patches</span>
45+
</th>
46+
47+
<th>
48+
{% if 'date.asc' == order %}
49+
<a href="{% listurl order='date.desc' %}" class="colactive">
50+
<span class="glyphicon glyphicon-chevron-up"></span>
51+
{% elif 'date.desc' == order %}
52+
<a href="{% listurl order='date.asc' %}" class="colactive">
53+
<span class="glyphicon glyphicon-chevron-down"></span>
54+
{% endif %}
55+
<span class="series-list-header">Date</span>
56+
{% if 'date.asc' == order or 'date.desc' == order%}
57+
</a>
58+
{% endif %}
59+
</th>
60+
61+
<th>
62+
<span class="series-list-header">Submitter</span>
63+
</th>
64+
</tr>
65+
</thead>
66+
67+
<tbody>
68+
{% for series in page %}
69+
<tr id="series_row:{{series.id}}">
70+
{% if user.is_authenticated and user.profile.show_ids %}
71+
<td>
72+
<button type="button" class="btn btn-xs btn-copy" data-clipboard-text="{{ series.id }}" title="Copy to Clipboard">
73+
{{ series.id }}
74+
</button>
75+
</td>
76+
{% endif %}
77+
<td>
78+
{{ series.name|default:"[no subject]"|truncatechars:100 }}
79+
</td>
80+
<td>
81+
{{ series.version|default:"-"}}
82+
</td>
83+
84+
<td>
85+
{% if series.cover_letter.content %}
86+
<b>&check;</b>
87+
{% else %}
88+
-
89+
{% endif %}
90+
</td>
91+
<td>{{ series.received_total}}</td>
92+
<td class="text-nowrap">{{ series.date|date:"Y-m-d" }}</td>
93+
<td>{{ series.submitter|personify:project }}</td>
94+
</tr>
95+
{% empty %}
96+
<tr>
97+
<td colspan="8">No series to display</td>
98+
</tr>
99+
{% endfor %}
100+
</tbody>
101+
</table>
102+
103+
{% if page.paginator.count %}
104+
{% include "patchwork/partials/pagination.html" %}
105+
{% endif %}
106+
{% endblock %}

patchwork/urls.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,19 @@
3333
path('', project_views.project_list, name='project-list'),
3434
path(
3535
'project/<project_id>/list/',
36+
patch_views.patch_list_redirect,
37+
name='patch-list-redirect',
38+
),
39+
path(
40+
'project/<project_id>/patches/',
3641
patch_views.patch_list,
3742
name='patch-list',
3843
),
44+
path(
45+
'project/<project_id>/series/',
46+
series_views.series_list,
47+
name='series-list',
48+
),
3949
path(
4050
'project/<project_id>/bundles/',
4151
bundle_views.bundle_list,

patchwork/views/patch.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from django.http import HttpResponseRedirect
1111
from django.shortcuts import get_object_or_404
1212
from django.shortcuts import render
13+
from django.shortcuts import redirect
1314
from django.urls import reverse
1415

1516
from patchwork.forms import CreateBundleForm
@@ -38,6 +39,11 @@ def patch_list(request, project_id):
3839
return render(request, 'patchwork/list.html', context)
3940

4041

42+
def patch_list_redirect(request, project_id):
43+
new_url = reverse('patch-list', kwargs={'project_id': project_id})
44+
return redirect(f'{new_url}?{request.GET.urlencode()}')
45+
46+
4147
def patch_detail(request, project_id, msgid):
4248
project = get_object_or_404(Project, linkname=project_id)
4349
db_msgid = Patch.decode_msgid(msgid)

patchwork/views/series.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
# Copyright (C) 2017 Stephen Finucane <stephen@that.guru>
33
#
44
# SPDX-License-Identifier: GPL-2.0-or-later
5+
import collections
56

67
from django.http import HttpResponse
78
from django.shortcuts import get_object_or_404
9+
from django.shortcuts import render
810

911
from patchwork.models import Series
12+
from patchwork.models import Project
1013
from patchwork.views.utils import series_to_mbox
14+
from patchwork.paginator import Paginator
1115

1216

1317
def series_mbox(request, series_id):
@@ -20,3 +24,43 @@ def series_mbox(request, series_id):
2024
)
2125

2226
return response
27+
28+
29+
def series_list(request, project_id):
30+
project = get_object_or_404(Project, linkname=project_id)
31+
sort = request.GET.get('order', 'date.desc')
32+
sort_field, sort_dir = sort.split('.')
33+
sort_order = f"{'-' if sort_dir == 'desc' else ''}{sort_field}"
34+
context = {}
35+
series_list = (
36+
Series.objects.filter(project=project)
37+
.only(
38+
'submitter',
39+
'project',
40+
'version',
41+
'name',
42+
'date',
43+
'id',
44+
'cover_letter',
45+
)
46+
.select_related('project', 'submitter', 'cover_letter')
47+
.order_by(sort_order)
48+
)
49+
50+
paginator = Paginator(request, series_list)
51+
context.update(
52+
{
53+
'project': project,
54+
'projects': Project.objects.all(),
55+
'series_list': series_list,
56+
'page': paginator.current_page,
57+
'order': sort,
58+
'list_view': {
59+
'view': 'series-list',
60+
'view_params': {'project_id': project.linkname},
61+
'params': collections.OrderedDict(),
62+
},
63+
}
64+
)
65+
66+
return render(request, 'patchwork/series-list.html', context)

0 commit comments

Comments
 (0)