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
bbe687c2
Commit
bbe687c2
authored
Jul 18, 2017
by
David Sinquin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rework facture management to avoid hardcoded check database id in JS.
parent
8515b2b0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
13 deletions
+15
-13
cotisations/forms.py
cotisations/forms.py
+3
-2
cotisations/models.py
cotisations/models.py
+5
-0
cotisations/templates/cotisations/new_facture.html
cotisations/templates/cotisations/new_facture.html
+7
-11
No files found.
cotisations/forms.py
View file @
bbe687c2
...
...
@@ -46,7 +46,7 @@ class NewFactureForm(ModelForm):
banque
=
cleaned_data
.
get
(
"banque"
)
if
not
paiement
:
raise
forms
.
ValidationError
(
"Le moyen de paiement est obligatoire."
)
elif
paiement
.
moyen
.
lower
()
==
"chèque"
or
paiement
.
moyen
.
lower
()
==
"cheque
"
and
not
(
cheque
and
banque
):
elif
paiement
.
type_
==
"check
"
and
not
(
cheque
and
banque
):
raise
forms
.
ValidationError
(
"Le numéro de chèque et la banque sont obligatoires."
)
return
cleaned_data
...
...
@@ -112,11 +112,12 @@ class DelArticleForm(ModelForm):
class
PaiementForm
(
ModelForm
):
class
Meta
:
model
=
Paiement
fields
=
[
'moyen'
]
fields
=
[
'moyen'
,
'type_'
]
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
PaiementForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'moyen'
].
label
=
'Moyen de paiement à ajouter'
self
.
fields
[
'type_'
].
label
=
'Type de paiement à ajouter'
class
DelPaiementForm
(
ModelForm
):
paiements
=
forms
.
ModelMultipleChoiceField
(
queryset
=
Paiement
.
objects
.
all
(),
label
=
"Moyens de paiement actuels"
,
widget
=
forms
.
CheckboxSelectMultiple
)
...
...
cotisations/models.py
View file @
bbe687c2
...
...
@@ -130,8 +130,13 @@ class Banque(models.Model):
class
Paiement
(
models
.
Model
):
PRETTY_NAME
=
"Moyens de paiement"
PAYMENT_TYPES
=
(
(
'check'
,
'Chèque'
),
(
None
,
'Autre'
),
)
moyen
=
models
.
CharField
(
max_length
=
255
)
type_
=
models
.
ChoiceField
(
choices
=
PAYMENT_TYPES
)
def
__str__
(
self
):
return
self
.
moyen
...
...
cotisations/templates/cotisations/new_facture.html
View file @
bbe687c2
...
...
@@ -36,6 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<h3>
Nouvelle facture
</h3>
{% bootstrap_form factureform %}
{{ venteform.management_form }}
<!-- TODO: FIXME to include data-type="check" for right option in id_cheque select -->
<h3>
Articles de la facture
</h3>
<div
id=
"form_set"
>
{% for form in venteform.forms %}
...
...
@@ -57,10 +58,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<script
type=
"text/javascript"
>
// id from database from checks
var
CHECK_ID
=
2
;
var
prices
=
{}
var
prices
=
{};
{
%
for
article
in
articlelist
%
}
prices
[{{
article
.
id
|
escapejs
}}]
=
{{
article
.
prix
}};
{
%
endfor
%
}
...
...
@@ -111,17 +109,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
}
function
set_cheque_info_visibility
(){
// May break in various ways...
// Requires CHECK_ID to be the right one
// and fields to hide to be 2nd and 3rd elements with class form-group
var
visible
=
document
.
getElementById
(
"
id_paiement
"
).
value
==
CHECK_ID
;
var
paiement
=
document
.
getElementById
(
"
id_paiement
"
);
var
visible
=
paiement
.
value
!=
''
&&
paiement
.
children
[
paiement
.
value
].
dataset
[
'
type
'
]
==
'
check
'
;
var
display
=
'
none
'
;
if
(
visible
)
{
display
=
'
block
'
;
}
var
elements
=
document
.
getElementsByClassName
(
'
form-group
'
);
elements
[
1
].
style
.
display
=
display
;
elements
[
2
].
style
.
display
=
display
;
document
.
getElementById
(
"
id_cheque
"
).
parentNode
.
style
.
display
=
display
;
document
.
getElementById
(
"
id_banque
"
).
parentNode
.
style
.
display
=
display
;
}
// Add events manager when DOM is fully loaded
...
...
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