Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
32
Issue boards
Milestones
Wiki
Code
Merge requests
6
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BDE
nk20
Commits
c4f54d9d
Commit
c4f54d9d
authored
5 years ago
by
ynerant
Browse files
Options
Downloads
Patches
Plain Diff
Multiple select
parent
cebbe65e
No related branches found
No related tags found
1 merge request
!57
Page de consommations
Pipeline
#7928
passed with stages
in 4 minutes and 2 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
apps/note/models/transactions.py
+1
-0
1 addition, 0 deletions
apps/note/models/transactions.py
apps/note/tables.py
+1
-1
1 addition, 1 deletion
apps/note/tables.py
templates/note/conso_form.html
+57
-26
57 additions, 26 deletions
templates/note/conso_form.html
with
59 additions
and
27 deletions
apps/note/models/transactions.py
+
1
−
0
View file @
c4f54d9d
...
@@ -132,6 +132,7 @@ class Transaction(PolymorphicModel):
...
@@ -132,6 +132,7 @@ class Transaction(PolymorphicModel):
if
self
.
source
.
pk
==
self
.
destination
.
pk
:
if
self
.
source
.
pk
==
self
.
destination
.
pk
:
# When source == destination, no money is transfered
# When source == destination, no money is transfered
super
().
save
(
*
args
,
**
kwargs
)
return
return
created
=
self
.
pk
is
None
created
=
self
.
pk
is
None
...
...
This diff is collapsed.
Click to expand it.
apps/note/tables.py
+
1
−
1
View file @
c4f54d9d
...
@@ -18,7 +18,7 @@ class HistoryTable(tables.Table):
...
@@ -18,7 +18,7 @@ class HistoryTable(tables.Table):
}
}
model
=
Transaction
model
=
Transaction
exclude
=
(
"
polymorphic_ctype
"
,
)
exclude
=
(
"
polymorphic_ctype
"
,
)
order_by
=
(
'
-
created_at
'
,
)
order_by
=
(
'
-
id
'
,
)
template_name
=
'
django_tables2/bootstrap4.html
'
template_name
=
'
django_tables2/bootstrap4.html
'
sequence
=
(
'
...
'
,
'
total
'
,
'
valid
'
)
sequence
=
(
'
...
'
,
'
total
'
,
'
valid
'
)
...
...
This diff is collapsed.
Click to expand it.
templates/note/conso_form.html
+
57
−
26
View file @
c4f54d9d
...
@@ -30,18 +30,15 @@
...
@@ -30,18 +30,15 @@
Sélection des émitteurs
Sélection des émitteurs
</p>
</p>
</div>
</div>
<ul
class=
"list-group list-group-flush"
>
<ul
class=
"list-group list-group-flush"
id=
"note_list"
>
<li
class=
"list-group-item py-1 d-flex justify-content-between align-items-center"
>
Cras justo odio
<span
class=
"badge badge-dark badge-pill"
>
14
</span>
</li>
<li
class=
"list-group-item py-1 d-flex justify-content-between align-items-center"
>
Dapibus ac facilisis in
<span
class=
"badge badge-dark badge-pill"
>
1
</span>
</li>
</ul>
</ul>
<div
class=
"card-body"
>
<div
class=
"card-body"
>
TODO: reimplement select2 here in JS
<select
name=
"source"
data-placeholder=
"Note ..."
data-minimum-input-length=
"1"
required
id=
"note"
data-autocomplete-light-language=
"fr"
data-autocomplete-light-url=
"/note/note-autocomplete/"
data-autocomplete-light-function=
"select2"
>
<option
value=
""
selected
>
---------
</option>
</select>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -83,10 +80,12 @@
...
@@ -83,10 +80,12 @@
<div
class=
"tab-pane"
id=
"{{ category.grouper|slugify }}"
>
<div
class=
"tab-pane"
id=
"{{ category.grouper|slugify }}"
>
<div
class=
"d-inline-flex flex-wrap justify-content-center"
>
<div
class=
"d-inline-flex flex-wrap justify-content-center"
>
{% for button in category.list %}
{% for button in category.list %}
{% if button.display %}
<button
class=
"btn btn-outline-dark rounded-0 flex-fill"
<button
class=
"btn btn-outline-dark rounded-0 flex-fill"
id=
"button{{ button.id }}"
name=
"button"
value=
"{{ button.name }}"
>
id=
"button{{ button.id }}"
name=
"button"
value=
"{{ button.name }}"
>
{{ button.name }} ({{ button.amount | pretty_money }})
{{ button.name }} ({{ button.amount | pretty_money }})
</button>
</button>
{% endif %}
{% endfor %}
{% endfor %}
</div>
</div>
</div>
</div>
...
@@ -131,10 +130,23 @@
...
@@ -131,10 +130,23 @@
min-width
:
100%
;
min-width
:
100%
;
}
}
</style>
</style>
<link
href=
"/static/vendor/select2/dist/css/select2.css"
type=
"text/css"
media=
"screen"
rel=
"stylesheet"
>
<link
href=
"/static/admin/css/autocomplete.css"
type=
"text/css"
media=
"screen"
rel=
"stylesheet"
>
<link
href=
"/static/autocomplete_light/select2.css"
type=
"text/css"
media=
"screen"
rel=
"stylesheet"
>
<script
type=
"text/javascript"
src=
"/static/autocomplete_light/jquery.init.js"
></script>
<script
type=
"text/javascript"
src=
"/static/vendor/select2/dist/js/select2.full.js"
></script>
<script
type=
"text/javascript"
src=
"/static/vendor/select2/dist/js/i18n/fr.js"
></script>
<script
type=
"text/javascript"
src=
"/static/autocomplete_light/autocomplete.init.js"
></script>
<script
type=
"text/javascript"
src=
"/static/autocomplete_light/forward.js"
></script>
<script
type=
"text/javascript"
src=
"/static/autocomplete_light/select2.js"
></script>
<script
type=
"text/javascript"
src=
"/static/autocomplete_light/jquery.post-setup.js"
></script>
{% endblock %}
{% endblock %}
{% block extrajavascript %}
{% block extrajavascript %}
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
var
consos
=
[];
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
// If hash of a category in the URL, then select this category
// If hash of a category in the URL, then select this category
// else select the first one
// else select the first one
...
@@ -149,26 +161,45 @@
...
@@ -149,26 +161,45 @@
location
.
hash
=
this
.
getAttribute
(
"
href
"
);
location
.
hash
=
this
.
getAttribute
(
"
href
"
);
});
});
$
(
"
#note
"
).
change
(
function
(
obj
)
{
let
name
=
$
(
"
#note option:selected
"
).
text
();
note_obj
=
$
(
"
#note
"
);
note
=
note_obj
.
val
();
note_obj
.
val
(
0
);
note_obj
.
text
(
""
);
consos
=
consos
.
concat
([[
name
,
note
]]);
note_list
=
$
(
"
#note_list
"
);
note_list
.
html
(
note_list
.
html
()
+
"
<li class=
\"
list-group-item py-1 d-flex justify-content-between align-items-center
\"
>
\n
"
+
"
"
+
name
+
"
\n
"
+
"
<span class=
\"
badge badge-dark badge-pill
\"
>1</span>
\n
"
+
"
</li>
"
);
});
{
%
for
button
in
transaction_templates
%
}
{
%
for
button
in
transaction_templates
%
}
{
%
if
button
.
display
%
}
$
(
"
#button{{ button.id }}
"
).
click
(
function
()
{
$
(
"
#button{{ button.id }}
"
).
click
(
function
()
{
$
.
post
(
"
/api/note/transaction/transaction/
"
,
consos
.
forEach
(
function
(
conso
)
{
{
console
.
log
(
conso
);
"
csrfmiddlewaretoken
"
:
"
{{ csrf_token }}
"
,
$
.
post
(
"
/api/note/transaction/transaction/
"
,
"
quantity
"
:
1
,
{
"
amount
"
:
{{
button
.
amount
}},
"
csrfmiddlewaretoken
"
:
"
{{
csrf_token
}}
"
,
"
reason
"
:
"
{{ button.name }} ({{ button.category.name }})
"
,
"
quantity
"
:
1
,
"
valid
"
:
true
,
"
amount
"
:
{{
button
.
amount
}}
,
"
polymorphic_ctype
"
:
{{
polymorphic_ctyp
e
}},
"
reason
"
:
"
{{
button.name }} ({{ button.category.nam
e }}
)
"
,
"
resourcetype
"
:
"
TemplateTransaction
"
,
"
valid
"
:
true
,
"
source
"
:
6
,
"
polymorphic_ctype
"
:
{{
polymorphic_ctype
}}
,
"
destina
tion
"
:
7
,
"
resourcetype
"
:
"
TemplateTransac
tion
"
,
"
category
"
:
{{
button
.
category
.
id
}}
,
"
source
"
:
conso
[
1
]
,
"
template
"
:
{{
button
.
id
}}
"
destination
"
:
{{
button
.
destination
.
pk
}}
,
},
"
category
"
:
{{
button
.
category
.
id
}
},
function
(
data
,
status
)
{
"
template
"
:
{{
button
.
id
}}
reloadWithTurbolinks
(
);
},
reloadWithTurbolinks
);
});
});
reloadWithTurbolinks
();
});
});
{
%
endif
%
}
{
%
endfor
%
}
{
%
endfor
%
}
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment