Commit 32045459 by Kálmán Viktor

network: add latest changes to index

parent 2d70750e
......@@ -4,6 +4,28 @@
{% load staticfiles %}
{% block content %}
<div class="page-heading">
<h1>Latest modifications</h1>
</div>
<table class="table table-striped table-bordered">
<tr>
<th>Action</th>
<th>Model</th>
<th>Name</th>
<th>Time since</th>
</tr>
{% for l in latest %}
<tr>
<td>{% if l.modified_at == l.created_at %}created{% else %}modified{% endif %}</td>
<td>{{ l.class_name }}</td>
<td><a href="{{ l.link }}">{{ l.name }}</a></td>
<td>{{ l.modified_at|timesince }}</td>
</tr>
{% endfor %}
</table>
<div class="page-heading">
<h1>Dashboard <small>foo bar baz</small></h1>
</div>
......
......@@ -10,10 +10,39 @@ from .tables import (HostTable, VlanTable, SmallHostTable, DomainTable,
from .forms import (HostForm, VlanForm, DomainForm, GroupForm, RecordForm,
BlacklistForm)
from itertools import chain
class IndexView(TemplateView):
template_name = "network/index.html"
def get_context_data(self, **kwargs):
context = super(IndexView, self).get_context_data(**kwargs)
size = 13
blacklists = Blacklist.objects.all().order_by('-modified_at')[:size]
domains = Domain.objects.all().order_by('-modified_at')[:size]
groups = Group.objects.all().order_by('-modified_at')[:size]
hosts = Host.objects.all().order_by('-modified_at')[:size]
records = Record.objects.all().order_by('-modified_at')[:size]
vlans = Vlan.objects.all().order_by('-modified_at')[:size]
result_list = []
for i in (sorted(chain(blacklists, domains, groups, hosts,
records, vlans),
key=lambda x: x.modified_at, reverse=True)[:size]):
result_list.append(
{
'class_name': unicode(i.__class__.__name__),
'modified_at': i.modified_at,
'created_at': i.created_at,
'name': unicode(i),
'link': i.get_absolute_url()
})
context['latest'] = result_list
return context
class BlacklistList(SingleTableView):
model = Blacklist
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment