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
2bafd38f
Commit
2bafd38f
authored
Nov 23, 2021
by
Etienne Freiss
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'evolution_bdm' into ticket_1738
parents
2f953b53
e0e7021d
Pipeline
#1527
passed with stage
in 1 minute 31 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
55 deletions
+58
-55
admin.py
members/admin.py
+21
-3
models.py
members/models.py
+12
-0
members_admin.js
members/static/js/members_admin.js
+12
-51
members-space-shifts-exchange.css
members_space/static/css/members-space-shifts-exchange.css
+12
-0
my_info.html
templates/members_space/my_info.html
+1
-1
No files found.
members/admin.py
View file @
2bafd38f
...
...
@@ -357,13 +357,31 @@ def update_members_makeups(request):
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
=
{
'name'
:
"
Ajout manuel d'un rattrapage
depuis l'admin BDM"
,
'name'
:
"
Modif manuelle des rattrapages
depuis l'admin BDM"
,
'shift_id'
:
False
,
'type'
:
member_data
[
"member_shift_type"
],
'partner_id'
:
int
(
member_data
[
"member_id"
]),
'point_qty'
:
-
1
'point_qty'
:
points_update
}
cm
.
update_member_points
(
data
)
...
...
members/models.py
View file @
2bafd38f
...
...
@@ -61,6 +61,18 @@ class CagetteMember(models.Model):
image
=
res
[
0
][
'image_medium'
]
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
):
"""
ex:
...
...
members/static/js/members_admin.js
View file @
2bafd38f
...
...
@@ -165,7 +165,7 @@ function display_makeups_members() {
openModal
(
`Enlever un rattrapage à
${
member
.
name
}
?`
,
()
=>
{
decrement_makeups
([
member_id
]
);
update_members_makeups
([
member_id
],
"decrement"
);
},
"Confirmer"
,
false
...
...
@@ -182,7 +182,7 @@ function display_makeups_members() {
openModal
(
`Ajouter un rattrapage à
${
member
.
name
}
?`
,
()
=>
{
increment_makeups
([
member_id
]
);
update_members_makeups
([
member_id
],
"increment"
);
},
"Confirmer"
,
false
...
...
@@ -212,7 +212,7 @@ function display_makeups_members() {
openModal
(
`Enlever un rattrapage aux membres sélectionnés ?`
,
()
=>
{
decrement_makeups
(
selected_rows
);
update_members_makeups
(
selected_rows
,
"decrement"
);
},
"Confirmer"
,
false
...
...
@@ -228,64 +228,25 @@ function display_makeups_members() {
/**
* Send request to update members nb of makeups to do
*
* @param {Array} member_ids
* @param {String} action increment | decrement
*/
function
decrement_makeups
(
member_ids
)
{
function
update_members_makeups
(
member_ids
,
action
)
{
openModal
();
data
=
[];
for
(
mid
of
member_ids
)
{
member_index
=
makeups_members
.
findIndex
(
m
=>
m
.
id
==
mid
);
if
(
action
===
"increment"
)
{
makeups_members
[
member_index
].
makeups_to_do
+=
1
;
}
else
{
makeups_members
[
member_index
].
makeups_to_do
-=
1
;
data
.
push
({
member_id
:
mid
,
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
({
member_id
:
mid
,
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
});
}
...
...
@@ -303,14 +264,14 @@ function increment_makeups(member_ids) {
closeModal
();
},
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'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
}
report_JS_error
(
err
,
'members_admin'
);
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() {
openModal
(
`Ajouter un rattrapage à
${
member
.
name
}
?`
,
()
=>
{
increment_makeups
([
member
.
id
]
);
update_members_makeups
([
member
.
id
],
"increment"
);
members_search_results
=
[];
$
(
'#search_member_input'
).
val
(
''
);
$
(
'.search_member_results_area'
).
hide
();
...
...
members_space/static/css/members-space-shifts-exchange.css
View file @
2bafd38f
...
...
@@ -125,11 +125,23 @@
margin
:
1px
10px
!important
;
}
.fc-event
{
background-color
:
#008AD9
;
border-color
:
#008AD9
;
color
:
white
;
}
td
{
--fc-list-event-hover-bg-color
:
#005BA6
;
}
.fc-event.shift_booked
{
background-color
:
#585858
;
cursor
:
auto
;
border-color
:
#585858
;
}
.fc-event.shift_booked
td
{
--fc-list-event-hover-bg-color
:
#585858
;
}
.fc-list-event.shift_booked
{
color
:
white
;
...
...
templates/members_space/my_info.html
View file @
2bafd38f
<div
id=
"my_info"
>
<div
class=
"page_title txtcenter"
>
<h1>
Mes Infos
Perso
</h1>
<h1>
Mes Infos
</h1>
</div>
<div
class=
"tiles_container"
>
<div
class=
"tile full_width_tile"
id=
"my_info_area"
>
...
...
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