Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
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
cooperatic-foodcoops
third-party
Commits
b0c615b8
Commit
b0c615b8
authored
Nov 23, 2021
by
Félicie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'evolution_bdm' of gl.cooperatic.fr:cooperatic-foodcoops/third-party into ticket_1733
parents
d25e5e1e
e0e7021d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
55 deletions
+46
-55
admin.py
members/admin.py
+21
-3
models.py
members/models.py
+12
-0
members_admin.js
members/static/js/members_admin.js
+13
-52
No files found.
members/admin.py
View file @
b0c615b8
...
@@ -357,13 +357,31 @@ def update_members_makeups(request):
...
@@ -357,13 +357,31 @@ def update_members_makeups(request):
res
[
"res"
]
.
append
(
cm
.
update_member_makeups
(
member_data
))
res
[
"res"
]
.
append
(
cm
.
update_member_makeups
(
member_data
))
if
"decrement_pts"
in
member_data
and
member_data
[
"decrement_pts"
]
is
True
:
# Update member standard points, for standard members only
if
member_data
[
"member_shift_type"
]
==
"standard"
:
# Set points to minus the number of makeups to do (limited to -2)
target_points
=
-
int
(
member_data
[
"target_makeups_nb"
])
if
(
target_points
<
-
2
)
:
target_points
=
-
2
member_points
=
cm
.
get_member_points
(
"standard"
)
points_diff
=
abs
(
member_points
-
target_points
)
# Don't update if no change
if
points_diff
==
0
:
continue
if
member_points
>
target_points
:
points_update
=
-
points_diff
else
:
points_update
=
points_diff
data
=
{
data
=
{
'name'
:
"
Ajout manuel d'un rattrapage
depuis l'admin BDM"
,
'name'
:
"
Modif manuelle des rattrapages
depuis l'admin BDM"
,
'shift_id'
:
False
,
'shift_id'
:
False
,
'type'
:
member_data
[
"member_shift_type"
],
'type'
:
member_data
[
"member_shift_type"
],
'partner_id'
:
int
(
member_data
[
"member_id"
]),
'partner_id'
:
int
(
member_data
[
"member_id"
]),
'point_qty'
:
-
1
'point_qty'
:
points_update
}
}
cm
.
update_member_points
(
data
)
cm
.
update_member_points
(
data
)
...
...
members/models.py
View file @
b0c615b8
...
@@ -61,6 +61,18 @@ class CagetteMember(models.Model):
...
@@ -61,6 +61,18 @@ class CagetteMember(models.Model):
image
=
res
[
0
][
'image_medium'
]
image
=
res
[
0
][
'image_medium'
]
return
image
return
image
def
get_member_points
(
self
,
shift_type
):
points_field
=
'final_standard_point'
if
shift_type
==
"standard"
else
'final_ftop_point'
cond
=
[[
'id'
,
'='
,
self
.
id
]]
fields
=
[
'id'
,
points_field
]
res
=
self
.
o_api
.
search_read
(
'res.partner'
,
cond
,
fields
)
if
res
and
len
(
res
)
==
1
:
return
res
[
0
][
points_field
]
else
:
return
None
def
update_member_points
(
self
,
data
):
def
update_member_points
(
self
,
data
):
"""
"""
ex:
ex:
...
...
members/static/js/members_admin.js
View file @
b0c615b8
...
@@ -165,7 +165,7 @@ function display_makeups_members() {
...
@@ -165,7 +165,7 @@ function display_makeups_members() {
openModal
(
openModal
(
`Enlever un rattrapage à
${
member
.
name
}
?`
,
`Enlever un rattrapage à
${
member
.
name
}
?`
,
()
=>
{
()
=>
{
decrement_makeups
([
member_id
]
);
update_members_makeups
([
member_id
],
"decrement"
);
},
},
"Confirmer"
,
"Confirmer"
,
false
false
...
@@ -182,7 +182,7 @@ function display_makeups_members() {
...
@@ -182,7 +182,7 @@ function display_makeups_members() {
openModal
(
openModal
(
`Ajouter un rattrapage à
${
member
.
name
}
?`
,
`Ajouter un rattrapage à
${
member
.
name
}
?`
,
()
=>
{
()
=>
{
increment_makeups
([
member_id
]
);
update_members_makeups
([
member_id
],
"increment"
);
},
},
"Confirmer"
,
"Confirmer"
,
false
false
...
@@ -212,7 +212,7 @@ function display_makeups_members() {
...
@@ -212,7 +212,7 @@ function display_makeups_members() {
openModal
(
openModal
(
`Enlever un rattrapage aux membres sélectionnés ?`
,
`Enlever un rattrapage aux membres sélectionnés ?`
,
()
=>
{
()
=>
{
decrement_makeups
(
selected_rows
);
update_members_makeups
(
selected_rows
,
"decrement"
);
},
},
"Confirmer"
,
"Confirmer"
,
false
false
...
@@ -228,64 +228,25 @@ function display_makeups_members() {
...
@@ -228,64 +228,25 @@ function display_makeups_members() {
/**
/**
* Send request to update members nb of makeups to do
* Send request to update members nb of makeups to do
*
* @param {Array} member_ids
* @param {Array} member_ids
* @param {String} action increment | decrement
*/
*/
function
decrement_makeups
(
member_ids
)
{
function
update_members_makeups
(
member_ids
,
action
)
{
openModal
();
openModal
();
data
=
[];
data
=
[];
for
(
mid
of
member_ids
)
{
for
(
mid
of
member_ids
)
{
member_index
=
makeups_members
.
findIndex
(
m
=>
m
.
id
==
mid
);
member_index
=
makeups_members
.
findIndex
(
m
=>
m
.
id
==
mid
);
makeups_members
[
member_index
].
makeups_to_do
-=
1
;
if
(
action
===
"increment"
)
{
makeups_members
[
member_index
].
makeups_to_do
+=
1
;
data
.
push
({
}
else
{
member_id
:
mid
,
makeups_members
[
member_index
].
makeups_to_do
-=
1
;
target_makeups_nb
:
makeups_members
[
member_index
].
makeups_to_do
});
}
$
.
ajax
({
type
:
'POST'
,
url
:
"/members/update_members_makeups"
,
data
:
JSON
.
stringify
(
data
),
dataType
:
"json"
,
traditional
:
true
,
contentType
:
"application/json; charset=utf-8"
,
success
:
function
()
{
selected_rows
=
[];
display_makeups_members
();
closeModal
();
},
error
:
function
(
data
)
{
err
=
{
msg
:
"erreur serveur pour décrémenter les rattrapages"
,
ctx
:
'decrement_makeups'
};
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
}
report_JS_error
(
err
,
'members_admin'
);
closeModal
();
alert
(
'Erreur serveur pour décrémenter les rattrapages. Ré-essayez plus tard.'
);
}
}
});
}
/**
* Send request to update members nb of makeups to do
* @param {Array} member_ids
*/
function
increment_makeups
(
member_ids
)
{
openModal
();
data
=
[];
for
(
mid
of
member_ids
)
{
member_index
=
makeups_members
.
findIndex
(
m
=>
m
.
id
==
mid
);
makeups_members
[
member_index
].
makeups_to_do
+=
1
;
console
.
log
(
makeups_members
[
member_index
]);
data
.
push
({
data
.
push
({
member_id
:
mid
,
member_id
:
mid
,
target_makeups_nb
:
makeups_members
[
member_index
].
makeups_to_do
,
target_makeups_nb
:
makeups_members
[
member_index
].
makeups_to_do
,
decrement_pts
:
(
makeups_members
[
member_index
].
makeups_to_do
==
1
),
member_shift_type
:
makeups_members
[
member_index
].
shift_type
member_shift_type
:
makeups_members
[
member_index
].
shift_type
});
});
}
}
...
@@ -303,14 +264,14 @@ function increment_makeups(member_ids) {
...
@@ -303,14 +264,14 @@ function increment_makeups(member_ids) {
closeModal
();
closeModal
();
},
},
error
:
function
(
data
)
{
error
:
function
(
data
)
{
err
=
{
msg
:
"erreur serveur pour
incrémenter les rattrapages"
,
ctx
:
'in
crement_makeups'
};
err
=
{
msg
:
"erreur serveur pour
décrémenter les rattrapages"
,
ctx
:
'de
crement_makeups'
};
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
}
}
report_JS_error
(
err
,
'members_admin'
);
report_JS_error
(
err
,
'members_admin'
);
closeModal
();
closeModal
();
alert
(
'Erreur serveur pour
in
crémenter les rattrapages. Ré-essayez plus tard.'
);
alert
(
'Erreur serveur pour
dé
crémenter les rattrapages. Ré-essayez plus tard.'
);
}
}
});
});
}
}
...
@@ -360,7 +321,7 @@ function display_possible_members() {
...
@@ -360,7 +321,7 @@ function display_possible_members() {
openModal
(
openModal
(
`Ajouter un rattrapage à
${
member
.
name
}
?`
,
`Ajouter un rattrapage à
${
member
.
name
}
?`
,
()
=>
{
()
=>
{
increment_makeups
([
member
.
id
]
);
update_members_makeups
([
member
.
id
],
"increment"
);
members_search_results
=
[];
members_search_results
=
[];
$
(
'#search_member_input'
).
val
(
''
);
$
(
'#search_member_input'
).
val
(
''
);
$
(
'.search_member_results_area'
).
hide
();
$
(
'.search_member_results_area'
).
hide
();
...
...
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