diff --git a/network/templates/network/index.html b/network/templates/network/index.html index d478474..229b3cc 100644 --- a/network/templates/network/index.html +++ b/network/templates/network/index.html @@ -26,6 +26,28 @@ {% endfor %} </table> + +<div class="page-header"> + <h1>Latest blacklists</h1> +</div> + +<table class="table table-striped table-bordered"> + <tr> + <th>IP</th> + <th>Reason</th> + <th>Type</th> + <th>Time elapsed</th> + </tr> + {% for b in latest_blacklists %} + <tr> + <td><a href="{{ b.get_absolute_url }}">{{ b.ipv4 }}</a></td> + <td>{{ b.reason }}</td> + <td>{{ b.type }}</td> + <td>{{ b.modified_at|timesince }}</td> + </tr> + {% endfor %} +</table> + <div class="page-header"> <h1>Dashboard <small>foo bar baz</small></h1> </div> diff --git a/network/views.py b/network/views.py index 74830d3..11a0e45 100644 --- a/network/views.py +++ b/network/views.py @@ -37,8 +37,8 @@ class IndexView(TemplateView): rules = Rule.objects.all().order_by('-modified_at')[:size] result_list = [] - for i in (sorted(chain(blacklists, domains, groups, hosts, - records, vlans, vlangroups, rules), + for i in (sorted(chain(domains, groups, hosts, records, vlans, + vlangroups, rules), key=lambda x: x.modified_at, reverse=True)[:size]): result_list.append( { @@ -49,6 +49,7 @@ class IndexView(TemplateView): 'link': i.get_absolute_url() }) + context['latest_blacklists'] = blacklists context['latest'] = result_list return context