Skip to content

Commit 1799337

Browse files
committed
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 7494873 commit 1799337

File tree

3 files changed

+143
-1
lines changed

3 files changed

+143
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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="colinactive">Series</span>
33+
</th>
34+
35+
<th>
36+
Version
37+
</th>
38+
39+
<th>
40+
<span class="colinactive">Cover Letter</span>
41+
</th>
42+
43+
<th>
44+
<span class="colinactive">Patches</span>
45+
</th>
46+
47+
<th>
48+
<span class="colinactive">Date</span>
49+
</th>
50+
51+
<th>
52+
<span class="colinactive">Submitter</span>
53+
</th>
54+
</tr>
55+
</thead>
56+
57+
<tbody>
58+
{% for series in page %}
59+
<tr id="series_row:{{series.id}}">
60+
{% if user.is_authenticated and user.profile.show_ids %}
61+
<td>
62+
<button type="button" class="btn btn-xs btn-copy" data-clipboard-text="{{ series.id }}" title="Copy to Clipboard">
63+
{{ series.id }}
64+
</button>
65+
</td>
66+
{% endif %}
67+
<td>
68+
<a href="{% url 'series-detail' project_id=project.linkname series_id=series.id %}">
69+
{{ series.name|default:"[no subject]"|truncatechars:100 }}
70+
</a>
71+
</td>
72+
<td>
73+
{{ series.version|default:"-"}}
74+
</td>
75+
76+
<td>
77+
{% if series.cover_letter.content %}
78+
<b>&check;</b>
79+
{% else %}
80+
-
81+
{% endif %}
82+
</td>
83+
<td>{{ series.received_total}}</td>
84+
<td class="text-nowrap">{{ series.date|date:"Y-m-d" }}</td>
85+
<td>{{ series.submitter|personify:project }}</td>
86+
</tr>
87+
{% empty %}
88+
<tr>
89+
<td colspan="8">No series to display</td>
90+
</tr>
91+
{% endfor %}
92+
</tbody>
93+
</table>
94+
95+
{% if page.paginator.count %}
96+
{% include "patchwork/partials/pagination.html" %}
97+
{% endif %}
98+
{% endblock %}

patchwork/urls.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,15 @@
3232
path('admin/', admin.site.urls),
3333
path('', project_views.project_list, name='project-list'),
3434
path(
35-
'project/<project_id>/list/',
35+
'project/<project_id>/patches/',
3636
patch_views.patch_list,
3737
name='patch-list',
3838
),
39+
path(
40+
'project/<project_id>/series/',
41+
series_views.series_list,
42+
name='series-list',
43+
),
3944
path(
4045
'project/<project_id>/bundles/',
4146
bundle_views.bundle_list,

patchwork/views/series.py

+39
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,38 @@ 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+
context = {}
32+
series_list = (
33+
Series.objects.filter(project=project)
34+
.only(
35+
'submitter',
36+
'project',
37+
'version',
38+
'name',
39+
'date',
40+
'id',
41+
)
42+
.select_related('project')
43+
.order_by('date')
44+
)
45+
46+
paginator = Paginator(request, series_list)
47+
context.update(
48+
{
49+
'project': project,
50+
'projects': Project.objects.all(),
51+
'series_list': series_list,
52+
'page': paginator.current_page,
53+
'list_view': {
54+
'view': 'series-list',
55+
'view_params': {'project_id': project.linkname},
56+
'params': collections.OrderedDict(),
57+
},
58+
}
59+
)
60+
61+
return render(request, 'patchwork/series-list.html', context)

0 commit comments

Comments
 (0)