Skip to content

Commit 8bf7872

Browse files
authored
Merge pull request #379 from hongwei1/develop
refactor/added the Pagination for Consumers page
2 parents 8757ce5 + 15911d1 commit 8bf7872

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{% load i18n %}
2+
<form class="form-inline" method="get">
3+
<div class="form-group">
4+
<label for="offset">{% trans "Offset" %}:</label>
5+
<input type="number" class="form-control" name="offset" id="offset" placeholder="0" value="{{ offset }}">
6+
</div>
7+
<div class="form-group">
8+
<label for="limit">{% trans "Limit" %}:</label>
9+
<input type="number" class="form-control" name="limit" id="limit" placeholder="50" value="{{ limit }}">
10+
</div>
11+
<input type="submit" class="btn btn-default" value ='{% trans "Refresh" %} ' onclick="javascript: form.action='';"></input>
12+
</form>

apimanager/consumers/templates/consumers/index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ <h1>{% trans "Consumers" %}</h1>
4444
</div>
4545
</div>
4646

47+
<div class="row">
48+
<div class="col-xs-12">
49+
<h4>{% trans "Pagination" %}</h4>
50+
{% include "consumers/includes/filter_pagination.html" %}
51+
</div>
52+
</div>
53+
4754
<h4>{% trans "Statistics" %}</h4>
4855
<ul id="statistics">
4956
<li>{% trans "Total number of consumers" %}: {{ statistics.consumers_num }} </li>

apimanager/consumers/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ def get_context_data(self, **kwargs):
6969
sorted_consumers=[]
7070
api = API(self.request.session.get('obp'))
7171
try:
72-
urlpath = '/management/consumers'
72+
limit = self.request.GET.get('limit', 50)
73+
offset = self.request.GET.get('offset', 0)
74+
urlpath = '/management/consumers?limit={}&offset={}'.format(limit, offset)
7375
consumers = api.get(urlpath)
7476
if 'code' in consumers and consumers['code'] >= 400:
7577
messages.error(self.request, consumers['message'])
@@ -86,6 +88,8 @@ def get_context_data(self, **kwargs):
8688

8789
context.update({
8890
'consumers': sorted_consumers,
91+
'limit': limit,
92+
'offset': offset,
8993
'statistics': self.compile_statistics(consumers),
9094
})
9195
except APIError as err:

0 commit comments

Comments
 (0)