Skip to content

Commit 22c589a

Browse files
committed
views: add series navigation buttons for patch-detail view
1 parent 9f74950 commit 22c589a

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Diff for: patchwork/templates/patchwork/submission.html

+14
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>

Diff for: patchwork/views/patch.py

+14
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,20 @@ def patch_detail(request, project_id, msgid):
152152
context['related_same_project'] = related_same_project
153153
context['related_different_project'] = related_different_project
154154

155+
try:
156+
context['previous_submission'] = Patch.objects.get(
157+
series=patch.series, number=patch.number - 1
158+
)
159+
except Patch.DoesNotExist:
160+
context['previous_submission'] = None
161+
162+
try:
163+
context['next_submission'] = Patch.objects.get(
164+
series=patch.series, number=patch.number + 1
165+
)
166+
except Patch.DoesNotExist:
167+
context['next_submission'] = None
168+
155169
return render(request, 'patchwork/submission.html', context)
156170

157171

0 commit comments

Comments
 (0)