Skip to content

Commit 09a6a81

Browse files
andrepapotivictor-accarini
authored andcommitted
views: add series-detail view
Signed-off-by: andrepapoti <[email protected]> Signed-off-by: Victor Accarini <[email protected]>
1 parent a90c63b commit 09a6a81

File tree

6 files changed

+98
-3
lines changed

6 files changed

+98
-3
lines changed

patchwork/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,10 +1095,10 @@ def add_patch(self, patch, number):
10951095
return patch
10961096

10971097
def get_absolute_url(self):
1098-
# TODO(stephenfin): We really need a proper series view
10991098
return reverse(
1100-
'patch-list', kwargs={'project_id': self.project.linkname}
1101-
) + ('?series=%d' % self.id)
1099+
'series-detail',
1100+
kwargs={'project_id': self.project.linkname, 'series_id': self.id},
1101+
)
11021102

11031103
def get_mbox_url(self):
11041104
return reverse('series-mbox', kwargs={'series_id': self.id})

patchwork/templates/patchwork/partials/download-buttons.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<div class="btn-group pull-right">
2+
{% if submission %}
23
<button type="button" class="btn btn-default btn-copy"
34
data-clipboard-text="{{ submission.id }}" title="Copy to Clipboard">
45
{{ submission.id }}
@@ -24,4 +25,14 @@
2425
series
2526
</a>
2627
{% endif %}
28+
{% elif series %}
29+
<button type="button" class="btn btn-default btn-copy"
30+
data-clipboard-text="{{ series.id }}" title="Copy to Clipboard">
31+
{{ series.id }}
32+
</button>
33+
<a href="{% url 'series-mbox' series_id=series.id %}"
34+
class="btn btn-default" role="button" title="Download series mbox">
35+
series
36+
</a>
37+
{% endif %}
2738
</div>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{% extends "base.html" %}
2+
3+
{% load humanize %}
4+
{% load syntax %}
5+
{% load person %}
6+
{% load patch %}
7+
{% load static %}
8+
{% load utils %}
9+
10+
{% block title %}{{series.name}}{% endblock %}
11+
12+
{% block body %}
13+
14+
<div>
15+
{% include "patchwork/partials/download-buttons.html" %}
16+
<h1>{{ series.name }}</h1>
17+
</div>
18+
19+
<table class="patch-meta">
20+
<tr>
21+
<th>Series ID</th>
22+
<td>
23+
{{ series.id }}
24+
<span class="btn-link btn-copy glyphicon glyphicon-copy" data-clipboard-text="{{ request.build_absolute_uri }}{{ series.get_absolute_url }}" title="Copy to Clipboard"></span>
25+
</td>
26+
</tr>
27+
<tr>
28+
<th>Date</th>
29+
<td>{{ series.date }}</td>
30+
</tr>
31+
<tr>
32+
<th>Submitter</th>
33+
<td>{{ series.submitter }}</td>
34+
</tr>
35+
<tr>
36+
<th>Total</th>
37+
<td>{{ series.patches }}</td>
38+
</tr>
39+
</table>
40+
<br>
41+
<h2>Patches</h2>
42+
<br>
43+
{% include "patchwork/partials/patch-list.html" %}
44+
45+
<div id="cover-letter">
46+
<h2>Cover Letter</h2>
47+
{% if series.cover_letter.content %}
48+
<pre class="content">{{ series.cover_letter.content }}</pre>
49+
{% else %}
50+
No cover letter available
51+
{% endif %}
52+
</div>
53+
54+
{% endblock %}

patchwork/templates/patchwork/series-list.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@
8484
</td>
8585
{% endif %}
8686
<td>
87+
<a href="{% url 'series-detail' project_id=project.linkname series_id=series.id %}?state=*">
8788
{{ series.name|default:"[no subject]"|truncatechars:100 }}
89+
</a>
8890
</td>
8991
<td>
9092
{{ series.version|default:"-"}}

patchwork/urls.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@
120120
name='comment-redirect',
121121
),
122122
# series views
123+
path(
124+
'project/<project_id>/series/<int:series_id>/',
125+
series_views.series_detail,
126+
name='series-detail',
127+
),
123128
path(
124129
'series/<int:series_id>/mbox/',
125130
series_views.series_mbox,

patchwork/views/series.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
from django.shortcuts import render
1010

1111
from patchwork.models import Series
12+
from patchwork.models import Patch
1213
from patchwork.models import Project
14+
from patchwork.views import generic_list
1315
from patchwork.views.utils import series_to_mbox
1416
from patchwork.paginator import Paginator
1517

@@ -26,6 +28,27 @@ def series_mbox(request, series_id):
2628
return response
2729

2830

31+
def series_detail(request, project_id, series_id):
32+
series = get_object_or_404(Series, id=series_id)
33+
34+
patches = Patch.objects.filter(series=series)
35+
36+
context = generic_list(
37+
request,
38+
series.project,
39+
'series-detail',
40+
view_args={
41+
'project_id': project_id,
42+
'series_id': series_id,
43+
},
44+
patches=patches,
45+
)
46+
47+
context.update({'series': series})
48+
49+
return render(request, 'patchwork/series-detail.html', context)
50+
51+
2952
def series_list(request, project_id):
3053
project = get_object_or_404(Project, linkname=project_id)
3154
sort = request.GET.get('order', 'date.desc')

0 commit comments

Comments
 (0)