Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
e538d3b2
Commit
e538d3b2
authored
Nov 15, 2016
by
guimoz
Committed by
chirac
Nov 15, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajout du domaine d'ip
parent
d82e1af4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
81 additions
and
10 deletions
+81
-10
logs/templates/logs/aff_stats_users.html
logs/templates/logs/aff_stats_users.html
+6
-1
logs/views.py
logs/views.py
+24
-4
machines/admin.py
machines/admin.py
+1
-1
machines/forms.py
machines/forms.py
+2
-2
machines/migrations/0028_iptype_domaine_ip.py
machines/migrations/0028_iptype_domaine_ip.py
+19
-0
machines/migrations/0029_iptype_domaine_range.py
machines/migrations/0029_iptype_domaine_range.py
+20
-0
machines/models.py
machines/models.py
+3
-0
machines/templates/machines/aff_iptype.html
machines/templates/machines/aff_iptype.html
+6
-2
No files found.
logs/templates/logs/aff_stats_users.html
View file @
e538d3b2
<ul
class=
"pagination nav navbar-nav"
>
<li><a
href=
"?onglet=1"
>
1 mois
</a></li>
<li><a
href=
"?onglet=2"
>
2 mois
</a></li>
</ul>
{% for key_dict, stats_dict in stats_list.items %}
{% for key, stats in stats_dict.items %}
<table
class=
"table table-striped"
>
<h4>
Statistiques par {{ key_dict }} de {{ key }}
</h4>
<thead>
<h4>
Statistiques par {{ key_dict }} de {{ key }}
</h4>
<tr>
<th>
{{ key_dict }}
</th>
<th>
Nombre de {{ key }} par {{ key_dict }}
</th>
...
...
logs/views.py
View file @
e538d3b2
...
...
@@ -24,6 +24,18 @@ from topologie.models import Switch, Port, Room
from
re2o.settings
import
PAGINATION_NUMBER
,
PAGINATION_LARGE_NUMBER
from
django.utils
import
timezone
from
dateutil.relativedelta
import
relativedelta
STATS_DICT
=
{
0
:
[
"Tout"
,
36
],
1
:
[
"1 mois"
,
1
],
2
:
[
"2 mois"
,
2
],
3
:
[
"6 mois"
,
6
],
4
:
[
"1 an"
,
12
],
5
:
[
"2 an"
,
24
],
}
def
form
(
ctx
,
template
,
request
):
c
=
ctx
c
.
update
(
csrf
(
request
))
...
...
@@ -105,11 +117,18 @@ def stats_models(request):
@
login_required
@
permission_required
(
'cableur'
)
def
stats_users
(
request
):
onglet
=
request
.
GET
.
get
(
'onglet'
)
try
:
search_field
=
STATS_DICT
[
onglet
]
except
:
search_field
=
STATS_DICT
[
0
]
onglet
=
0
start_date
=
timezone
.
now
()
+
relativedelta
(
months
=-
search_field
[
1
])
stats
=
{
'Utilisateur'
:
{
'Machines'
:
User
.
objects
.
annotate
(
num
=
Count
(
'machine'
)).
order_by
(
'-num'
)[:
10
],
'Facture'
:
User
.
objects
.
annotate
(
num
=
Count
(
'facture'
)).
order_by
(
'-num'
)[:
10
],
'Bannissement'
:
User
.
objects
.
annotate
(
num
=
Count
(
'ban'
)).
order_by
(
'-num'
)[:
10
],
'Machines'
:
User
.
objects
.
filter
(
registered__gt
=
search_field
[
1
]).
annotate
(
num
=
Count
(
'machine'
)).
order_by
(
'-num'
)[:
10
],
'Facture'
:
User
.
objects
.
filter
(
registered__gt
=
search_field
[
1
]).
annotate
(
num
=
Count
(
'facture'
)).
order_by
(
'-num'
)[:
10
],
'Bannissement'
:
User
.
objects
.
filter
(
registered__gt
=
search_field
[
1
]).
annotate
(
num
=
Count
(
'ban'
)).
order_by
(
'-num'
)[:
10
],
'Accès gracieux'
:
User
.
objects
.
annotate
(
num
=
Count
(
'whitelist'
)).
order_by
(
'-num'
)[:
10
],
'Droits'
:
User
.
objects
.
annotate
(
num
=
Count
(
'right'
)).
order_by
(
'-num'
)[:
10
],
},
...
...
@@ -123,11 +142,12 @@ def stats_users(request):
'Utilisateur'
:
Banque
.
objects
.
annotate
(
num
=
Count
(
'facture'
)).
order_by
(
'-num'
)[:
10
],
},
}
return
render
(
request
,
'logs/stats_users.html'
,
{
'stats_list'
:
stats
})
return
render
(
request
,
'logs/stats_users.html'
,
{
'stats_list'
:
stats
,
'stats_dict'
:
STATS_DICT
,
'active_field'
:
onglet
})
@
login_required
@
permission_required
(
'cableur'
)
def
stats_actions
(
request
):
onglet
=
request
.
GET
.
get
(
'onglet'
)
stats
=
{
'Utilisateur'
:
{
'Action'
:
User
.
objects
.
annotate
(
num
=
Count
(
'revision'
)).
order_by
(
'-num'
)[:
40
],
...
...
machines/admin.py
View file @
e538d3b2
...
...
@@ -7,7 +7,7 @@ class MachineAdmin(VersionAdmin):
list_display
=
(
'user'
,
'name'
,
'active'
)
class
IpTypeAdmin
(
VersionAdmin
):
list_display
=
(
'type'
,
'extension'
,
'need_infra'
)
list_display
=
(
'type'
,
'extension'
,
'need_infra'
,
'domaine_ip'
,
'domaine_range'
)
class
MachineTypeAdmin
(
VersionAdmin
):
list_display
=
(
'type'
,
'ip_type'
)
...
...
machines/forms.py
View file @
e538d3b2
...
...
@@ -88,7 +88,7 @@ class DelMachineTypeForm(ModelForm):
class
IpTypeForm
(
ModelForm
):
class
Meta
:
model
=
IpType
fields
=
[
'type'
,
'extension'
,
'need_infra'
]
fields
=
[
'type'
,
'extension'
,
'need_infra'
,
'domaine_ip'
,
'domaine_range'
]
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
IpTypeForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
...
...
@@ -98,7 +98,7 @@ class DelIpTypeForm(ModelForm):
iptypes
=
forms
.
ModelMultipleChoiceField
(
queryset
=
IpType
.
objects
.
all
(),
label
=
"Types d'ip actuelles"
,
widget
=
forms
.
CheckboxSelectMultiple
)
class
Meta
:
exclude
=
[
'type'
,
'extension'
,
'need_infra'
]
exclude
=
[
'type'
,
'extension'
,
'need_infra'
,
'domaine_ip'
,
'domaine_range'
]
model
=
IpType
...
...
machines/migrations/0028_iptype_domaine_ip.py
0 → 100644
View file @
e538d3b2
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'machines'
,
'0027_alias'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'iptype'
,
name
=
'domaine_ip'
,
field
=
models
.
GenericIPAddressField
(
blank
=
True
,
unique
=
True
,
null
=
True
,
protocol
=
'IPv4'
),
),
]
machines/migrations/0029_iptype_domaine_range.py
0 → 100644
View file @
e538d3b2
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django.core.validators
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'machines'
,
'0028_iptype_domaine_ip'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'iptype'
,
name
=
'domaine_range'
,
field
=
models
.
IntegerField
(
null
=
True
,
validators
=
[
django
.
core
.
validators
.
MinValueValidator
(
8
),
django
.
core
.
validators
.
MaxValueValidator
(
32
)],
blank
=
True
),
),
]
machines/models.py
View file @
e538d3b2
...
...
@@ -4,6 +4,7 @@ from django.dispatch import receiver
from
django.forms
import
ValidationError
from
macaddress.fields
import
MACAddressField
from
netaddr
import
EUI
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
from
re2o.settings
import
MAIN_EXTENSION
...
...
@@ -33,6 +34,8 @@ class IpType(models.Model):
type
=
models
.
CharField
(
max_length
=
255
)
extension
=
models
.
ForeignKey
(
'Extension'
,
on_delete
=
models
.
PROTECT
)
need_infra
=
models
.
BooleanField
(
default
=
False
)
domaine_ip
=
models
.
GenericIPAddressField
(
protocol
=
'IPv4'
,
unique
=
True
,
blank
=
True
,
null
=
True
)
domaine_range
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
,
validators
=
[
MinValueValidator
(
8
),
MaxValueValidator
(
32
)])
def
__str__
(
self
):
return
self
.
type
...
...
machines/templates/machines/aff_iptype.html
View file @
e538d3b2
...
...
@@ -4,7 +4,9 @@
<th>
Type d'ip
</th>
<th>
Extension
</th>
<th>
Nécessite l'autorisation infra
</th>
<th></th>
<th>
Domaine d'ip
</th>
<th>
Range
</th>
<th></th>
<th></th>
</tr>
</thead>
...
...
@@ -13,7 +15,9 @@
<td>
{{ type.type }}
</td>
<td>
{{ type.extension }}
</td>
<td>
{{ type.need_infra }}
</td>
<td>
{% if is_infra %}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'machines:edit-iptype' type.id %}"
><i
class=
"glyphicon glyphicon-pushpin"
></i>
Editer
</a>
{% endif %}
</td>
<td>
{{ type.domaine_ip }}
</td>
<td>
{{ type.domaine_range }}
</td>
<td>
{% if is_infra %}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'machines:edit-iptype' type.id %}"
><i
class=
"glyphicon glyphicon-pushpin"
></i>
Editer
</a>
{% endif %}
</td>
<td><a
class=
"btn btn-info btn-sm"
role=
"button"
href=
"{% url 'machines:history' 'iptype' type.id %}"
><i
class=
"glyphicon glyphicon-repeat"
></i>
Historique
</a></td>
</tr>
{% endfor %}
...
...
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