Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
32045459
authored
Jul 25, 2013
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: add latest changes to index
parent
2d70750e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
network/templates/network/index.html
+22
-0
network/views.py
+29
-0
No files found.
network/templates/network/index.html
View file @
32045459
...
...
@@ -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>
...
...
network/views.py
View file @
32045459
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment