Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
6507bc5b
Commit
6507bc5b
authored
Oct 28, 2017
by
Gabriel Detraz
Committed by
root
Oct 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nouvelles methodes pour user
parent
65dedc07
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
4 deletions
+31
-4
users/models.py
users/models.py
+31
-4
No files found.
users/models.py
View file @
6507bc5b
...
...
@@ -378,6 +378,22 @@ class User(AbstractBaseUser):
user
=
self
)
.
exclude
(
valid
=
False
)
)
)
.
filter
(
Q
(
type_cotisation
=
'All'
)
|
Q
(
type_cotisation
=
'Adhesion'
)
)
.
aggregate
(
models
.
Max
(
'date_end'
))[
'date_end__max'
]
return
date_max
def
end_connexion
(
self
):
""" Renvoie la date de fin de connexion d'un user. Examine les objets
cotisation"""
date_max
=
Cotisation
.
objects
.
filter
(
vente__in
=
Vente
.
objects
.
filter
(
facture__in
=
Facture
.
objects
.
filter
(
user
=
self
)
.
exclude
(
valid
=
False
)
)
)
.
filter
(
Q
(
type_cotisation
=
'All'
)
|
Q
(
type_cotisation
=
'Connexion'
)
)
.
aggregate
(
models
.
Max
(
'date_end'
))[
'date_end__max'
]
return
date_max
...
...
@@ -392,6 +408,17 @@ class User(AbstractBaseUser):
else
:
return
True
def
is_connected
(
self
):
""" Renvoie True si l'user est adhérent : si
self.end_adhesion()>now et end_connexion>now"""
end
=
self
.
end_connexion
()
if
not
end
:
return
False
elif
end
<
DT_NOW
:
return
False
else
:
return
self
.
is_adherent
()
@
cached_property
def
end_ban
(
self
):
""" Renvoie la date de fin de ban d'un user, False sinon """
...
...
@@ -433,20 +460,20 @@ class User(AbstractBaseUser):
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
)
and
not
self
.
is_ban
and
(
self
.
is_
connected
()
or
self
.
is_whitelisted
)
def
end_access
(
self
):
""" Renvoie la date de fin normale d'accès (adhésion ou whiteliste)"""
if
not
self
.
end_
adhes
ion
():
if
not
self
.
end_
connex
ion
():
if
not
self
.
end_whitelist
:
return
None
else
:
return
self
.
end_whitelist
else
:
if
not
self
.
end_whitelist
:
return
self
.
end_
adhes
ion
()
return
self
.
end_
connex
ion
()
else
:
return
max
(
self
.
end_
adhes
ion
(),
self
.
end_whitelist
)
return
max
(
self
.
end_
connex
ion
(),
self
.
end_whitelist
)
@
cached_property
def
solde
(
self
):
...
...
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