Skip to content

Commit 98bf401

Browse files
committed
views: add series navigation buttons for patch-detail view
Signed-off-by: andrepapoti <[email protected]>
1 parent 7097a4a commit 98bf401

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

patchwork/templates/patchwork/submission.html

+16
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@
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
32+
class="btn btn-default {% if not previous_submission %} disabled {% endif %}"
33+
{% if previous_submission %} href="{% url 'patch-detail' project_id=project.linkname msgid=previous_submission.encoded_msgid %}" {% endif %}
34+
>
35+
previous
36+
</a>
37+
</div>
38+
2339
<table id="patch-meta" class="patch-meta" data-submission-type={{submission|verbose_name_plural|lower}} data-submission-id={{submission.id}}>
2440
<tr>
2541
<th>Message ID</th>

patchwork/views/patch.py

+14
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,20 @@ def patch_detail(request, project_id, msgid):
148148
context['related_same_project'] = related_same_project
149149
context['related_different_project'] = related_different_project
150150

151+
try:
152+
context['previous_submission'] = Patch.objects.get(
153+
series=patch.series, number=patch.number - 1
154+
)
155+
except Patch.DoesNotExist:
156+
context['previous_submission'] = None
157+
158+
try:
159+
context['next_submission'] = Patch.objects.get(
160+
series=patch.series, number=patch.number + 1
161+
)
162+
except Patch.DoesNotExist:
163+
context['next_submission'] = None
164+
151165
return render(request, 'patchwork/submission.html', context)
152166

153167

0 commit comments

Comments
 (0)