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
intranet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nounous-archives
intranet
Commits
aa1f3101
Commit
aa1f3101
authored
Nov 25, 2015
by
Gabriel Detraz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redirige vers la bonne liste des factures (cf voir dans mon compte)
parent
77676c09
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
31 deletions
+66
-31
compte/templates/compte/affichage.html
compte/templates/compte/affichage.html
+1
-1
factures/urls.py
factures/urls.py
+5
-1
factures/views.py
factures/views.py
+60
-29
No files found.
compte/templates/compte/affichage.html
View file @
aa1f3101
...
...
@@ -41,7 +41,7 @@
{% endif %}
Jusqu'au {{ luser.fin_connexion.value }}
</span>
(
<a
href=
"{% url 'factures:
index'
%}"
>
détails
</a>
)
(
<a
href=
"{% url 'factures:
liste' 'adh' luser.aid.0
%}"
>
détails
</a>
)
</div>
{% if cablage %}
<div
class=
"four columns"
>
...
...
factures/urls.py
View file @
aa1f3101
...
...
@@ -4,5 +4,9 @@ import views
urlpatterns
=
patterns
(
''
,
url
(
'^$'
,
views
.
index
,
name
=
'index'
),
url
(
'(?P<fid>[0-9]+).pdf'
,
views
.
facture
)
url
(
'^liste/(?P<ptype>club)/(?P<cid>[0-9]+)/$'
,
views
.
index
,
name
=
'liste'
),
url
(
'^liste/(?P<ptype>adh)/(?P<aid>[0-9]+)/$'
,
views
.
index
,
name
=
'liste'
),
url
(
'(?P<fid>[0-9]+).pdf'
,
views
.
facture
,
name
=
'facture'
),
url
(
'^liste/(?P<ptype>adh)/(?P<aid>[0-9]+)/(?P<fid>[0-9]+).pdf/$'
,
views
.
facture
,
name
=
'facture'
),
url
(
'^liste/(?P<ptype>club)/(?P<cid>[0-9]+)/(?P<fid>[0-9]+).pdf/$'
,
views
.
facture
,
name
=
'facture'
)
)
factures/views.py
View file @
aa1f3101
...
...
@@ -6,6 +6,7 @@ from django.template.loader import render_to_string
from
django.shortcuts
import
render
,
redirect
from
django.contrib.auth.decorators
import
login_required
from
django.utils.decorators
import
method_decorator
from
django.template
import
RequestContext
...
...
@@ -17,32 +18,62 @@ import hashlib
import
time
from
intranet
import
settings
,
conn_pool
@
login_required
def
index
(
request
):
luser
=
conn_pool
.
get_user
(
request
.
user
)
return
render
(
request
,
'factures/index.html'
,
{
'luser'
:
luser
})
@
login_required
def
facture
(
request
,
fid
):
luser
=
conn_pool
.
get_user
(
request
.
user
)
f
=
conn_pool
.
get_conn
(
request
.
user
).
search
(
u
"fid=%s"
%
int
(
fid
))
if
not
f
:
return
redirect
(
'factures:index'
)
else
:
f
=
f
[
0
]
if
not
f
.
dn
in
[
fac
.
dn
for
fac
in
luser
.
factures
()]:
return
redirect
(
'factures:index'
)
total
=
0
for
i
in
range
(
0
,
len
(
f
[
'article'
])):
f
[
'article'
][
i
].
value
[
'ptotal'
]
=
int
(
f
[
'article'
][
i
][
'nombre'
])
*
float
(
f
[
'article'
][
i
][
'pu'
])
total
+=
f
[
'article'
][
i
].
value
[
'ptotal'
]
if
f
.
get
(
'recuPaiement'
,
[]):
paid
=
total
else
:
paid
=
0
(
jour
,
heure
)
=
f
[
'historique'
][
0
].
value
.
split
(
','
)[
0
].
split
(
" "
)
date
=
u
"Le %s à %s"
%
(
jour
,
heure
.
replace
(
":"
,
"h"
))
topay
=
total
-
paid
# return render(request, 'factures/facture.tex', {'total':total, 'paid':paid, 'topay':total-paid, 'date':f['historique'][0].value.split(',')[0], 'f':f})
return
render_tex
(
request
,
'factures/facture.tex'
,
{
'total'
:
total
,
'paid'
:
paid
,
'topay'
:
topay
,
'DATE'
:
date
,
'f'
:
f
,
'fid'
:
fid
})
from
django.views.generic
import
View
from
intranet.mixins
import
CableurOrSelfMixin
,
CableurMixin
class
IndexView
(
CableurOrSelfMixin
,
View
):
"""
Classe de base pour l'index
"""
template_name
=
"factures/index.html"
def
get
(
self
,
request
,
aid
,
cid
,
ptype
,
*
args
,
**
kwargs
):
if
ptype
==
"adh"
:
luser
=
conn_pool
.
get_conn
(
request
.
user
).
search
(
u
'aid=%s'
%
aid
)[
0
]
elif
ptype
==
"club"
:
luser
=
conn_pool
.
get_conn
(
request
.
user
).
search
(
u
'cid=%s'
%
aid
)[
0
]
return
render
(
request
,
self
.
template_name
,
{
'luser'
:
luser
})
@
method_decorator
(
login_required
)
def
dispatch
(
self
,
request
,
aid
=
None
,
cid
=
None
,
ptype
=
None
,
*
args
,
**
kwargs
):
if
not
aid
and
not
cid
:
# Si aid=None, on renvoit celui de l'user
luser
=
conn_pool
.
get_user
(
request
.
user
)
if
luser
.
ldap_name
==
'club'
:
cid
=
luser
[
'cid'
][
0
]
ptype
=
'club'
else
:
aid
=
luser
[
'aid'
][
0
]
ptype
=
'adh'
return
super
(
IndexView
,
self
).
dispatch
(
request
,
aid
,
cid
,
ptype
,
*
args
,
**
kwargs
)
index
=
IndexView
.
as_view
()
class
FactureView
(
View
):
def
get
(
self
,
request
,
fid
):
luser
=
conn_pool
.
get_user
(
request
.
user
)
f
=
conn_pool
.
get_conn
(
request
.
user
).
search
(
u
"fid=%s"
%
int
(
fid
))
if
not
f
:
return
redirect
(
'factures:index'
)
else
:
f
=
f
[
0
]
if
not
f
.
dn
in
[
fac
.
dn
for
fac
in
luser
.
factures
()]
and
not
request
.
user
.
has_perm
(
'auth.crans_cableur'
):
return
redirect
(
'factures:index'
)
total
=
0
for
i
in
range
(
0
,
len
(
f
[
'article'
])):
f
[
'article'
][
i
].
value
[
'ptotal'
]
=
int
(
f
[
'article'
][
i
][
'nombre'
])
*
float
(
f
[
'article'
][
i
][
'pu'
])
total
+=
f
[
'article'
][
i
].
value
[
'ptotal'
]
if
f
.
get
(
'recuPaiement'
,
[]):
paid
=
total
else
:
paid
=
0
(
jour
,
heure
)
=
f
[
'historique'
][
0
].
value
.
split
(
','
)[
0
].
split
(
" "
)
date
=
u
"Le %s à %s"
%
(
jour
,
heure
.
replace
(
":"
,
"h"
))
topay
=
total
-
paid
return
render_tex
(
request
,
'factures/facture.tex'
,
{
'total'
:
total
,
'paid'
:
paid
,
'topay'
:
topay
,
'DATE'
:
date
,
'f'
:
f
,
'fid'
:
fid
})
facture
=
FactureView
.
as_view
()
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