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
adefbd8a
Commit
adefbd8a
authored
Jul 10, 2016
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplifie le code, déplace les tests dans models, affiche un encart user à droite
parent
cc0e1cb3
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
137 additions
and
143 deletions
+137
-143
cotisations/views.py
cotisations/views.py
+5
-24
machines/models.py
machines/models.py
+6
-0
machines/templates/machines/sidebar.html
machines/templates/machines/sidebar.html
+2
-0
machines/views.py
machines/views.py
+2
-4
re2o/settings.py
re2o/settings.py
+1
-0
search/views.py
search/views.py
+1
-14
static/css/base.css
static/css/base.css
+30
-4
templates/base.html
templates/base.html
+13
-1
topologie/views.py
topologie/views.py
+2
-4
users/models.py
users/models.py
+50
-0
users/templates/users/aff_users.html
users/templates/users/aff_users.html
+7
-7
users/templates/users/profil.html
users/templates/users/profil.html
+7
-7
users/templates/users/sidebar.html
users/templates/users/sidebar.html
+4
-0
users/urls.py
users/urls.py
+1
-0
users/views.py
users/views.py
+6
-78
No files found.
cotisations/views.py
View file @
adefbd8a
...
...
@@ -23,25 +23,10 @@ def form(ctx, template, request):
c
.
update
(
csrf
(
request
))
return
render_to_response
(
template
,
c
,
context_instance
=
RequestContext
(
request
))
def
end_adhesion
(
user
):
""" Renvoie la date de fin d'adhésion d'un user, False sinon """
date_max
=
Cotisation
.
objects
.
all
().
filter
(
facture
=
Facture
.
objects
.
all
().
filter
(
user
=
user
).
exclude
(
valid
=
False
)).
aggregate
(
Max
(
'date_end'
))[
'date_end__max'
]
return
date_max
def
is_adherent
(
user
):
""" Renvoie si un user est à jour de cotisation """
end
=
end_adhesion
(
user
)
if
not
end
:
return
False
elif
end
<
timezone
.
now
():
return
False
else
:
return
True
def
create_cotis
(
facture
,
user
,
duration
):
""" Update et crée l'objet cotisation associé à une facture, prend en argument l'user, la facture pour la quantitéi, et l'article pour la durée"""
cotisation
=
Cotisation
(
facture
=
facture
)
date_max
=
end_adhesion
(
user
)
or
timezone
.
now
()
date_max
=
user
.
end_adhesion
(
)
or
timezone
.
now
()
if
date_max
<
timezone
.
now
():
datemax
=
timezone
.
now
()
cotisation
.
date_start
=
date_max
...
...
@@ -225,27 +210,23 @@ def del_banque(request):
@
login_required
@
permission_required
(
'cableur'
)
def
index_article
(
request
):
is_trez
=
request
.
user
.
has_perms
((
'trésorier'
,))
article_list
=
Article
.
objects
.
order_by
(
'name'
)
return
render
(
request
,
'cotisations/index_article.html'
,
{
'article_list'
:
article_list
,
'is_trez'
:
is_trez
})
return
render
(
request
,
'cotisations/index_article.html'
,
{
'article_list'
:
article_list
})
@
login_required
@
permission_required
(
'cableur'
)
def
index_paiement
(
request
):
is_trez
=
request
.
user
.
has_perms
((
'trésorier'
,))
paiement_list
=
Paiement
.
objects
.
order_by
(
'moyen'
)
return
render
(
request
,
'cotisations/index_paiement.html'
,
{
'paiement_list'
:
paiement_list
,
'is_trez'
:
is_trez
})
return
render
(
request
,
'cotisations/index_paiement.html'
,
{
'paiement_list'
:
paiement_list
})
@
login_required
@
permission_required
(
'cableur'
)
def
index_banque
(
request
):
is_trez
=
request
.
user
.
has_perms
((
'trésorier'
,))
banque_list
=
Banque
.
objects
.
order_by
(
'name'
)
return
render
(
request
,
'cotisations/index_banque.html'
,
{
'banque_list'
:
banque_list
,
'is_trez'
:
is_trez
})
return
render
(
request
,
'cotisations/index_banque.html'
,
{
'banque_list'
:
banque_list
})
@
login_required
@
permission_required
(
'cableur'
)
def
index
(
request
):
is_cableur
=
request
.
user
.
has_perms
((
'cableur'
,))
facture_list
=
Facture
.
objects
.
order_by
(
'date'
).
reverse
()
return
render
(
request
,
'cotisations/index.html'
,
{
'facture_list'
:
facture_list
,
'is_cableur'
:
is_cableur
})
return
render
(
request
,
'cotisations/index.html'
,
{
'facture_list'
:
facture_list
})
machines/models.py
View file @
adefbd8a
...
...
@@ -33,6 +33,12 @@ class Machine(models.Model):
name
=
models
.
CharField
(
max_length
=
255
,
help_text
=
"Optionnel"
,
blank
=
True
,
null
=
True
)
active
=
models
.
BooleanField
(
default
=
True
)
def
is_active
(
self
):
""" Renvoie si une interface doit avoir accès ou non """
machine
=
self
.
machine
user
=
machine
.
user
return
machine
.
active
and
user
.
has_access
()
def
__str__
(
self
):
return
str
(
self
.
user
)
+
' - '
+
str
(
self
.
id
)
+
' - '
+
str
(
self
.
name
)
...
...
machines/templates/machines/sidebar.html
View file @
adefbd8a
{% extends "base.html" %}
{% block sidebar %}
{% if is_cableur %}
<p><a
href=
"{% url "
machines:index-machinetype
"
%}"
>
Liste des types de machine
</a></p>
<p><a
href=
"{% url "
machines:index-extension
"
%}"
>
Liste des types des extensions
</a></p>
{% endif %}
{% endblock %}
machines/views.py
View file @
adefbd8a
...
...
@@ -215,13 +215,11 @@ def index(request):
@
login_required
@
permission_required
(
'cableur'
)
def
index_machinetype
(
request
):
is_infra
=
request
.
user
.
has_perms
((
'infra'
,))
machinetype_list
=
MachineType
.
objects
.
order_by
(
'type'
)
return
render
(
request
,
'machines/index_machinetype.html'
,
{
'machinetype_list'
:
machinetype_list
,
'is_infra'
:
is_infra
})
return
render
(
request
,
'machines/index_machinetype.html'
,
{
'machinetype_list'
:
machinetype_list
})
@
login_required
@
permission_required
(
'cableur'
)
def
index_extension
(
request
):
is_infra
=
request
.
user
.
has_perms
((
'infra'
,))
extension_list
=
Extension
.
objects
.
order_by
(
'name'
)
return
render
(
request
,
'machines/index_extension.html'
,
{
'extension_list'
:
extension_list
,
'is_infra'
:
is_infra
})
return
render
(
request
,
'machines/index_extension.html'
,
{
'extension_list'
:
extension_list
})
re2o/settings.py
View file @
adefbd8a
...
...
@@ -85,6 +85,7 @@ TEMPLATES = [
'django.template.context_processors.request'
,
'django.contrib.auth.context_processors.auth'
,
'django.contrib.messages.context_processors.messages'
,
're2o.context_processors.context_user'
,
],
},
},
...
...
search/views.py
View file @
adefbd8a
...
...
@@ -13,8 +13,6 @@ from machines.models import Machine, Interface
from
topologie.models
import
Port
,
Switch
from
cotisations.models
import
Facture
from
search.models
import
SearchForm
,
SearchFormPlus
from
users.views
import
has_access
from
cotisations.views
import
end_adhesion
def
form
(
ctx
,
template
,
request
):
c
=
ctx
...
...
@@ -53,21 +51,10 @@ def search_result(search, type, request):
switchlist
=
None
portlist
=
None
connexion
=
[]
is_cableur
=
request
.
user
.
has_perms
((
'cableur'
,))
is_bofh
=
request
.
user
.
has_perms
((
'bofh'
,))
for
i
in
aff
:
if
i
==
'0'
:
users
=
User
.
objects
.
filter
((
Q
(
pseudo__icontains
=
search
)
|
Q
(
name__icontains
=
search
)
|
Q
(
surname__icontains
=
search
))
&
query
)
connexion
=
[]
for
user
in
users
:
end
=
end_adhesion
(
user
)
access
=
has_access
(
user
)
if
(
len
(
co
)
==
0
or
(
len
(
co
)
==
1
and
bool
(
co
[
0
])
==
access
)
or
(
len
(
co
)
==
2
and
(
bool
(
co
[
0
])
==
access
or
bool
(
co
[
1
])
==
access
))):
if
(
end
!=
None
):
connexion
.
append
([
user
,
access
,
end
])
else
:
connexion
.
append
([
user
,
access
,
"Non adhérent"
])
query
=
Q
(
user__pseudo__icontains
=
search
)
|
Q
(
user__name__icontains
=
search
)
|
Q
(
user__surname__icontains
=
search
)
if
i
==
'1'
:
machines
=
Interface
.
objects
.
filter
(
machine
=
Machine
.
objects
.
filter
(
query
))
|
Interface
.
objects
.
filter
(
Q
(
dns__icontains
=
search
))
...
...
@@ -81,7 +68,7 @@ def search_result(search, type, request):
portlist
=
Port
.
objects
.
filter
(
details__icontains
=
search
)
if
i
==
'6'
:
switchlist
=
Switch
.
objects
.
filter
(
details__icontains
=
search
)
return
{
'users_list'
:
connexion
,
'interfaces_list'
:
machines
,
'facture_list'
:
factures
,
'ban_list'
:
bans
,
'white_list'
:
whitelists
,
'port_list'
:
portlist
,
'switch_list'
:
switchlist
,
'is_cableur'
:
is_cableur
,
'is_bofh'
:
is_bofh
}
return
{
'users_list'
:
users
,
'interfaces_list'
:
machines
,
'facture_list'
:
factures
,
'ban_list'
:
bans
,
'white_list'
:
whitelists
,
'port_list'
:
portlist
,
'switch_list'
:
switchlist
}
@
login_required
def
search
(
request
):
...
...
static/css/base.css
View file @
adefbd8a
/* Remove the navbar's default margin-bottom and rounded borders */
/* Sticky footer hacks */
html
,
body
{
height
:
100%
;
}
#wrap
{
min-height
:
100%
;
}
#main
{
overflow
:
auto
;
padding-bottom
:
60px
;
/* this needs to be bigger than footer height*/
}
footer
{
position
:
relative
;
margin-top
:
-50px
;
/* negative value of footer height */
height
:
50px
;
clear
:
both
;
padding-top
:
20px
;
}
/* Remove the navbar's default margin-bottom and rounded borders */
.navbar
{
margin-bottom
:
0
;
border-radius
:
0
;
}
/* Set height of the grid so .sidenav can be 100% (adjust as needed) */
.row.content
{
height
:
450px
}
.row.content
{
height
:
100%
;
overflow
:
hidden
;
}
/* Set gray background color and 100% height */
.sidenav
{
padding-top
:
20px
;
background-color
:
#f1f1f1
;
height
:
100%
;
margin-bottom
:
-9999px
;
padding-bottom
:
9999px
;
}
/* Set black background color, white text and some padding */
...
...
@@ -27,5 +53,5 @@ footer {
height
:
auto
;
padding
:
15px
;
}
.row.content
{
height
:
auto
;}
.row.content
{
height
:
auto
;}
}
templates/base.html
View file @
adefbd8a
...
...
@@ -28,11 +28,14 @@
</div>
<div
class=
"collapse navbar-collapse"
id=
"myNavbar"
>
<ul
class=
"nav navbar-nav"
>
<li><a
href=
"{% url "
users:mon-profil
"
%}"
>
Mon profil
</a></li>
{% if is_cableur %}
<li><a
href=
"{% url "
users:index
"
%}"
>
Adhérents
</a></li>
<li><a
href=
"{% url "
machines:index
"
%}"
>
Machines
</a></li>
<li><a
href=
"{% url "
cotisations:index
"
%}"
>
Cotisations
</a></li>
<li><a
href=
"{% url "
topologie:index
"
%}"
>
Topologie
</a></li>
<li><a
href=
"#"
>
Statistiques
</a></li>
{% endif %}
</ul>
<div
class=
"col-sm-3 col-md-3 navbar-right"
>
<form
action=
"{% url "
search:search
"%}"
method=
"POST"
class=
"navbar-form"
role=
"search"
>
...
...
@@ -82,7 +85,16 @@
</div>
<div
class=
"col-sm-2 sidenav"
>
<div
class=
"well"
>
<p>
ADS
</p>
{% if user.is_authenticated %}
<li>
{{ user.name }} {{ user.surname }}
</li>
<li>
Pseudo : {{ user.pseudo }}
</li>
<li>
Chambre : {{ user.room }}
</li>
<li>
Connexion : {% if user.actif == True %}
<font
color=
"green"
>
Active
</font>
{% else %}
<font
color=
"red"
>
Désactivée
</font>
{% endif %}
</li>
<li>
Fin d'adhésion : {% if user.end_adhesion != None %}
<font
color=
"green"
>
{{ user.end_adhesion }}
</font>
{% else %}
<font
color=
"red"
>
Non adhérent
</font>
{% endif %}
</li>
<p><a
href=
"{% url "
users:mon-profil
"
%}"
>
Voir mon profil
</a></p>
{% else %}
<p>
Vous n'êtes pas authentifié
</p>
{% endif %}
</div>
<div
class=
"well"
>
<p>
ADS
</p>
...
...
topologie/views.py
View file @
adefbd8a
...
...
@@ -10,21 +10,19 @@ from users.views import form
@
login_required
@
permission_required
(
'cableur'
)
def
index
(
request
):
is_infra
=
request
.
user
.
has_perms
((
'infra'
,))
switch_list
=
Switch
.
objects
.
order_by
(
'building'
,
'number'
)
return
render
(
request
,
'topologie/index.html'
,
{
'switch_list'
:
switch_list
,
'is_infra'
:
is_infra
})
return
render
(
request
,
'topologie/index.html'
,
{
'switch_list'
:
switch_list
})
@
login_required
@
permission_required
(
'cableur'
)
def
index_port
(
request
,
switch_id
):
is_infra
=
request
.
user
.
has_perms
((
'infra'
,))
try
:
switch
=
Switch
.
objects
.
get
(
pk
=
switch_id
)
except
Switch
.
DoesNotExist
:
messages
.
error
(
request
,
u
"Switch inexistant"
)
return
redirect
(
"/topologie/"
)
port_list
=
Port
.
objects
.
filter
(
switch
=
switch
).
order_by
(
'port'
)
return
render
(
request
,
'topologie/index_p.html'
,
{
'port_list'
:
port_list
,
'id_switch'
:
switch_id
,
'nom_switch'
:
switch
,
'is_infra'
:
is_infra
})
return
render
(
request
,
'topologie/index_p.html'
,
{
'port_list'
:
port_list
,
'id_switch'
:
switch_id
,
'nom_switch'
:
switch
})
@
login_required
@
permission_required
(
'infra'
)
...
...
users/models.py
View file @
adefbd8a
from
django.db
import
models
from
django.forms
import
ModelForm
,
Form
from
django
import
forms
import
re
from
django.utils
import
timezone
from
django.contrib.auth.models
import
AbstractBaseUser
,
BaseUserManager
from
topologie.models
import
Room
from
cotisations.models
import
Cotisation
,
Facture
def
remove_user_room
(
room
):
""" Déménage de force l'ancien locataire de la chambre """
...
...
@@ -143,6 +145,54 @@ class User(AbstractBaseUser):
def
has_perm
(
self
,
perm
,
obj
=
None
):
return
True
def
end_adhesion
(
self
):
date_max
=
Cotisation
.
objects
.
all
().
filter
(
facture
=
Facture
.
objects
.
all
().
filter
(
user
=
self
).
exclude
(
valid
=
False
)).
aggregate
(
models
.
Max
(
'date_end'
))[
'date_end__max'
]
return
date_max
def
is_adherent
(
self
):
end
=
self
.
end_adhesion
()
if
not
end
:
return
False
elif
end
<
timezone
.
now
():
return
False
else
:
return
True
def
end_ban
(
self
):
""" Renvoie la date de fin de ban d'un user, False sinon """
date_max
=
Ban
.
objects
.
all
().
filter
(
user
=
self
).
aggregate
(
models
.
Max
(
'date_end'
))[
'date_end__max'
]
return
date_max
def
end_whitelist
(
self
):
""" Renvoie la date de fin de ban d'un user, False sinon """
date_max
=
Whitelist
.
objects
.
all
().
filter
(
user
=
self
).
aggregate
(
models
.
Max
(
'date_end'
))[
'date_end__max'
]
return
date_max
def
is_ban
(
self
):
""" Renvoie si un user est banni ou non """
end
=
self
.
end_ban
()
if
not
end
:
return
False
elif
end
<
timezone
.
now
():
return
False
else
:
return
True
def
is_whitelisted
(
self
):
""" Renvoie si un user est whitelisté ou non """
end
=
self
.
end_whitelist
()
if
not
end
:
return
False
elif
end
<
timezone
.
now
():
return
False
else
:
return
True
def
has_access
(
self
):
""" Renvoie si un utilisateur a accès à internet """
return
self
.
state
==
User
.
STATE_ACTIVE
\
and
not
self
.
is_ban
()
and
(
self
.
is_adherent
()
or
self
.
is_whitelisted
())
def
has_module_perms
(
self
,
app_label
):
# Simplest version again
return
True
...
...
users/templates/users/aff_users.html
View file @
adefbd8a
...
...
@@ -9,19 +9,19 @@
<th>
Profil
</th>
</tr>
</thead>
{% for
donnee
in users_list %}
{% for
user
in users_list %}
<tr>
<td>
{{
donnee.0
.name }}
</td>
<td>
{{
donnee.0
.surname }}
</td>
<td>
{{
donnee.0
.pseudo }}
</td>
<td>
{
{ donnee.2 }
}
</td>
<td>
{% if
donnee.1
== True %}
<td>
{{
user
.name }}
</td>
<td>
{{
user
.surname }}
</td>
<td>
{{
user
.pseudo }}
</td>
<td>
{
% if user.is_adherent %}{{ user.end_adhesion }}{% else %}Non adhérent{% endif %
}
</td>
<td>
{% if
user.has_access
== True %}
<font
color=
"green"
>
Active
</font>
{% else %}
<font
color=
"red"
>
Désactivée
</font>
{% endif %}
</td>
<td><a
href=
"{% url "
users:profil
"
donnee.0
.id
%}"
class=
"btn btn-primary btn-sm"
role=
"button"
><i
class=
"glyphicon glyphicon-user"
></i></a>
<td><a
href=
"{% url "
users:profil
"
user
.id
%}"
class=
"btn btn-primary btn-sm"
role=
"button"
><i
class=
"glyphicon glyphicon-user"
></i></a>
</td>
</tr>
{% endfor %}
...
...
users/templates/users/profil.html
View file @
adefbd8a
...
...
@@ -38,21 +38,21 @@
</tr>
<tr>
<th>
Fin d'adhésion
</th>
{% if end_adhesion != None %}
<td><font
color=
"green"
>
{{ end_adhesion }}
</font></td>
{% if
user.
end_adhesion != None %}
<td><font
color=
"green"
>
{{
user.
end_adhesion }}
</font></td>
{% else %}
<td><font
color=
"red"
>
Non adhérent
</font></td>
{% endif %}
<th>
Accès gracieux
</th>
{% if end_whitelist != None %}
<td><font
color=
"green"
>
{{ end_whitelist }}
</font></td>
{% if
user.
end_whitelist != None %}
<td><font
color=
"green"
>
{{
user.
end_whitelist }}
</font></td>
{% else %}
<td><font
color=
"orange"
>
Aucun
</font></td>
{% endif %}
<tr>
<th>
Bannissement
</th>
{% if end_ban != None %}
<td><font
color=
"red"
>
{{ end_ban }}
</font></td>
{% if
user.
end_ban != None %}
<td><font
color=
"red"
>
{{
user.
end_ban }}
</font></td>
{% else %}
<td><font
color=
"green"
>
Non banni
</font></td>
{% endif %}
...
...
@@ -67,7 +67,7 @@
</tr>
<tr>
<th>
Connexion
</th>
{% if actif == True %}
{% if
user.
actif == True %}
<td><font
color=
"green"
>
Active
</font></td>
{% else %}
<td><font
color=
"red"
>
Désactivée
</font></td>
...
...
users/templates/users/sidebar.html
View file @
adefbd8a
{% extends "base.html" %}
{% block sidebar %}
{% if is_cableur %}
<p><a
href=
"{% url "
users:new-user
"
%}"
>
Créer un adhérent
</a></p>
<p><a
href=
"{% url "
users:index
"
%}"
>
Liste des adhérents
</a></p>
<p><a
href=
"{% url "
users:index-ban
"
%}"
>
Liste des bannissements
</a></p>
<p><a
href=
"{% url "
users:index-white
"
%}"
>
Liste des accès à titre gracieux
</a></p>
<p><a
href=
"{% url "
users:index-school
"
%}"
>
Liste des établissements
</a></p>
{% if is_bureau %}
<p><a
href=
"{% url "
users:del-right
"
%}"
>
Retirer un droit
</a></p>
{% endif %}
{% endif %}
{% endblock %}
users/urls.py
View file @
adefbd8a
...
...
@@ -20,6 +20,7 @@ urlpatterns = [
url
(
r
'^index_ban/$'
,
views
.
index_ban
,
name
=
'index-ban'
),
url
(
r
'^index_white/$'
,
views
.
index_white
,
name
=
'index-white'
),
url
(
r
'^index_school/$'
,
views
.
index_school
,
name
=
'index-school'
),
url
(
r
'^mon_profil/$'
,
views
.
mon_profil
,
name
=
'mon-profil'
),
url
(
r
'^$'
,
views
.
index
,
name
=
'index'
),
]
...
...
users/views.py
View file @
adefbd8a
...
...
@@ -16,7 +16,6 @@ from users.models import InfoForm, BaseInfoForm, StateForm, RightForm, SchoolFor
from
cotisations.models
import
Facture
from
machines.models
import
Machine
,
Interface
from
users.forms
import
PassForm
from
cotisations.views
import
is_adherent
,
end_adhesion
from
machines.views
import
unassign_ips
,
assign_ips
from
re2o.login
import
hashNT
...
...
@@ -33,56 +32,6 @@ def unarchive(user):
assign_ips
(
user
)
return
def
end_ban
(
user
):
""" Renvoie la date de fin de ban d'un user, False sinon """
date_max
=
Ban
.
objects
.
all
().
filter
(
user
=
user
).
aggregate
(
Max
(
'date_end'
))[
'date_end__max'
]
return
date_max
def
end_whitelist
(
user
):
""" Renvoie la date de fin de ban d'un user, False sinon """
date_max
=
Whitelist
.
objects
.
all
().
filter
(
user
=
user
).
aggregate
(
Max
(
'date_end'
))[
'date_end__max'
]
return
date_max
def
is_ban
(
user
):
""" Renvoie si un user est banni ou non """
end
=
end_ban
(
user
)
if
not
end
:
return
False
elif
end
<
timezone
.
now
():
return
False
else
:
return
True
def
is_whitelisted
(
user
):
""" Renvoie si un user est whitelisté ou non """
end
=
end_whitelist
(
user
)
if
not
end
:
return
False
elif
end
<
timezone
.
now
():
return
False
else
:
return
True
def
has_access
(
user
):
""" Renvoie si un utilisateur a accès à internet """
return
user
.
state
==
User
.
STATE_ACTIVE
\
and
not
is_ban
(
user
)
and
(
is_adherent
(
user
)
or
is_whitelisted
(
user
))
def
is_active
(
interface
):
""" Renvoie si une interface doit avoir accès ou non """
machine
=
interface
.
machine
user
=
machine
.
user
return
machine
.
active
and
has_access
(
user
)
def
form
(
ctx
,
template
,
request
):
c
=
ctx
c
.
update
(
csrf
(
request
))
...
...
@@ -317,22 +266,13 @@ def del_school(request):
@
permission_required
(
'cableur'
)
def
index
(
request
):
users_list
=
User
.
objects
.
order_by
(
'pk'
)
connexion
=
[]
for
user
in
users_list
:
end
=
end_adhesion
(
user
)
access
=
has_access
(
user
)
if
(
end
is
not
None
):
connexion
.
append
([
user
,
access
,
end
])
else
:
connexion
.
append
([
user
,
access
,
"Non adhérent"
])
return
render
(
request
,
'users/index.html'
,
{
'users_list'
:
connexion
})
return
render
(
request
,
'users/index.html'
,
{
'users_list'
:
users_list
})
@
login_required
@
permission_required
(
'cableur'
)
def
index_ban
(
request
):
is_bofh
=
request
.
user
.
has_perms
((
'bofh'
,))
ban_list
=
Ban
.
objects
.
order_by
(
'date_start'
)
return
render
(
request
,
'users/index_ban.html'
,
{
'ban_list'
:
ban_list
,
'is_bofh'
:
is_bofh
})
return
render
(
request
,
'users/index_ban.html'
,
{
'ban_list'
:
ban_list
})
@
login_required
@
permission_required
(
'cableur'
)
...
...
@@ -350,6 +290,10 @@ def index_school(request):
school_list
=
School
.
objects
.
order_by
(
'name'
)
return
render
(
request
,
'users/index_schools.html'
,
{
'school_list'
:
school_list
})
@
login_required
def
mon_profil
(
request
):
return
redirect
(
"/users/profil/"
+
str
(
request
.
user
.
id
))
@
login_required
def
profil
(
request
,
userid
):
if
not
request
.
user
.
has_perms
((
'cableur'
,))
and
str
(
userid
)
!=
str
(
request
.
user
.
id
):
...
...
@@ -366,16 +310,7 @@ def profil(request, userid):
factures
=
Facture
.
objects
.
filter
(
user__pseudo
=
users
)
bans
=
Ban
.
objects
.
filter
(
user__pseudo
=
users
)
whitelists
=
Whitelist
.
objects
.
filter
(
user__pseudo
=
users
)
end_bans
=
None
end_whitelists
=
None
if
(
is_ban
(
users
)):
end_bans
=
end_ban
(
users
)
if
(
is_whitelisted
(
users
)):
end_whitelists
=
end_whitelist
(
users
)
list_droits
=
Right
.
objects
.
filter
(
user
=
users
)
is_bofh
=
request
.
user
.
has_perms
((
'bofh'
,))
is_bureau
=
request
.
user
.
has_perms
((
'bureau'
,))
is_cableur
=
request
.
user
.
has_perms
((
'cableur'
,))
return
render
(
request
,
'users/profil.html'
,
...
...
@@ -385,14 +320,7 @@ def profil(request, userid):
'facture_list'
:
factures
,
'ban_list'
:
bans
,
'white_list'
:
whitelists
,
'end_ban'
:
end_bans
,
'end_whitelist'
:
end_whitelists
,
'end_adhesion'
:
end_adhesion
(
users
),
'actif'
:
has_access
(
users
),
'list_droits'
:
list_droits
,
'is_bofh'
:
is_bofh
,
'is_bureau'
:
is_bureau
,
'is_cableur'
:
is_cableur
,
}
)
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