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
B
BonVivens
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
0
Merge Requests
0
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
groupe-bonvivens
BonVivens
Commits
3e8a7355
Commit
3e8a7355
authored
Sep 05, 2016
by
Gabriel Detraz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Empeche les commandes et modifications tardives
parent
16f92d3a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
+16
-5
panier/templates/panier/aff_paniers.html
panier/templates/panier/aff_paniers.html
+6
-5
panier/views.py
panier/views.py
+10
-0
No files found.
panier/templates/panier/aff_paniers.html
View file @
3e8a7355
...
...
@@ -25,7 +25,7 @@
<th>
Prix
</th>
<th>
Livré
</th>
<th>
Date de livraison
</th>
<th></th>
<th>
Pas de modification après
</th>
<th></th>
</tr>
</thead>
...
...
@@ -41,17 +41,18 @@
{% else %}
<td><font
color=
"red"
>
Non
</font></td>
{% endif %}
<td>
{{ panier.date }}
</td>
<td>
{{ panier.date.date }}
</td>
<td>
{{ panier.date.date_modif }}
</td>
<td><div
class=
"dropdown"
>
<button
class=
"btn btn-default dropdown-toggle"
type=
"button"
id=
"editioncredit"
data-toggle=
"dropdown"
aria-haspopup=
"true"
aria-expanded=
"true"
>
Modifi
er
Edit
er
<span
class=
"caret"
></span>
</button>
<ul
class=
"dropdown-menu"
aria-labelledby=
"editionfacture"
>
<li><a
href=
"{% url 'panier:edit-commande' panier.id %}"
><i
class=
"glyphicon glyphicon-bitcoin"
></i>
Editer
</a></li>
<li><a
href=
"{% url 'panier:edit-commande' panier.id %}"
><i
class=
"glyphicon glyphicon-bitcoin"
></i>
Modifier
</a></li>
<li><a
href=
"{% url 'panier:history' 'commande' panier.id %}"
><i
class=
"glyphicon glyphicon-repeat"
></i>
Historique
</a></li>
<li><a
href=
"{% url 'panier:del-commande' panier.id %}"
><i
class=
"glyphicon glyphicon-trash"
></i>
Supprimer
</a></li>
</ul></div></td>
<td><a
class=
"btn btn-info btn-sm"
role=
"button"
href=
"{% url 'panier:history' 'commande' panier.id %}"
><i
class=
"glyphicon glyphicon-repeat"
></i>
Historique
</a></td>
</tr>
{% endfor %}
</table>
...
...
panier/views.py
View file @
3e8a7355
...
...
@@ -18,6 +18,7 @@ from .forms import PaiementForm, CreditForm, CreditFullForm, DelPaiementForm, Li
from
.forms
import
PanierForm
,
DelPanierForm
,
SelectArticleForm
,
BaseEditCommandeForm
,
NewCommandeForm
from
users.views
import
User
from
django.utils
import
timezone
from
amap.settings
import
MINIMUM_LEVEL
,
PAGINATION_NUMBER
...
...
@@ -47,6 +48,9 @@ def new_commande(request, userid):
commande
=
commande_form
.
save
(
commit
=
False
)
prix_unitaire
=
article_form
.
cleaned_data
[
'article'
].
prix
quantite
=
commande
.
quantite
if
timezone
.
now
()
>
commande
.
date
.
date_modif
and
not
request
.
user
.
has_perms
((
'bureau'
,)):
messages
.
error
(
request
,
"Vous ne pouvez plus passer commande, livraison proche"
)
return
redirect
(
"/users/profil/"
+
str
(
request
.
user
.
id
))
if
user
.
solde
()
-
prix_unitaire
*
quantite
<
MINIMUM_LEVEL
:
messages
.
error
(
request
,
"Solde insuffisant pour effectuer l'operation"
)
return
redirect
(
"/users/profil/"
+
userid
)
...
...
@@ -73,6 +77,9 @@ def edit_commande(request, commandeid):
if
request
.
user
.
has_perms
((
'bureau'
,)):
commande
=
BaseEditCommandeForm
(
request
.
POST
or
None
,
instance
=
commande_instance
)
else
:
if
timezone
.
now
()
>
commande_instance
.
date
.
date_modif
:
messages
.
error
(
request
,
"Vous ne pouvez plus modifier la commande, livraison proche"
)
return
redirect
(
"/users/profil/"
+
str
(
request
.
user
.
id
))
commande
=
FullEditCommandeForm
(
request
.
POST
or
None
,
instance
=
commande_instance
)
if
commande
.
is_valid
():
with
transaction
.
atomic
(),
reversion
.
create_revision
():
...
...
@@ -93,6 +100,9 @@ def del_commande(request, commandeid):
if
not
request
.
user
.
has_perms
((
'bureau'
,))
and
commande
.
user
!=
request
.
user
:
messages
.
error
(
request
,
"Vous ne pouvez pas commander pour quelqu'un d'autre !"
)
return
redirect
(
"/users/profil/"
+
str
(
request
.
user
.
id
))
if
timezone
.
now
()
>
commande
.
date
.
date_modif
and
not
request
.
user
.
has_perms
((
'bureau'
,)):
messages
.
error
(
request
,
"Vous ne pouvez plus supprimer la commande, livraison proche"
)
return
redirect
(
"/users/profil/"
+
str
(
request
.
user
.
id
))
if
request
.
method
==
"POST"
:
with
transaction
.
atomic
(),
reversion
.
create_revision
():
commande
.
delete
()
...
...
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