Skip to content

Commit 7ce7068

Browse files
andrepapotivictor-accarini
authored andcommitted
views: add series navigation buttons for patch-detail view
Signed-off-by: Victor Accarini <[email protected]>
1 parent 33132c6 commit 7ce7068

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

patchwork/templates/patchwork/submission.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@
2020
<h1>{{ submission.name }}</h1>
2121
</div>
2222

23+
<div class="btn-group pull-right">
24+
<a class="btn btn-default {% if not next_submission %} disabled {% endif %}"
25+
{% if next_submission %} href="{% url 'patch-detail' project_id=project.linkname msgid=next_submission.encoded_msgid %}" {% endif %}>
26+
next
27+
</a>
28+
</div>
29+
30+
<div class="btn-group pull-right">
31+
<a class="btn btn-default {% if not previous_submission %} disabled {% endif %}"
32+
{% if previous_submission %} href="{% url 'patch-detail' project_id=project.linkname msgid=previous_submission.encoded_msgid %}" {% endif %}>
33+
previous
34+
</a>
35+
</div>
36+
2337
<table id="patch-meta" class="patch-meta" data-submission-type={{submission|verbose_name_plural|lower}} data-submission-id={{submission.id}}>
2438
<tr>
2539
<th>Message ID</th>

patchwork/views/patch.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,20 @@ def patch_detail(request, project_id, msgid):
190190
if errors:
191191
context['errors'] = errors
192192

193+
try:
194+
context['previous_submission'] = Patch.objects.get(
195+
series=patch.series, number=patch.number - 1
196+
)
197+
except Patch.DoesNotExist:
198+
context['previous_submission'] = None
199+
200+
try:
201+
context['next_submission'] = Patch.objects.get(
202+
series=patch.series, number=patch.number + 1
203+
)
204+
except Patch.DoesNotExist:
205+
context['next_submission'] = None
206+
193207
return render(request, 'patchwork/submission.html', context)
194208

195209

0 commit comments

Comments
 (0)