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
717c2f7d
Commit
717c2f7d
authored
Nov 19, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove 1 pt to members to whom we add the first makeup
parent
6a825fc3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
21 deletions
+40
-21
admin.py
members/admin.py
+18
-2
models.py
members/models.py
+14
-16
members_admin.js
members/static/js/members_admin.js
+8
-3
No files found.
members/admin.py
View file @
717c2f7d
...
@@ -345,12 +345,28 @@ def get_makeups_members(request):
...
@@ -345,12 +345,28 @@ def get_makeups_members(request):
return
JsonResponse
({
'res'
:
res
})
return
JsonResponse
({
'res'
:
res
})
def
update_members_makeups
(
request
):
def
update_members_makeups
(
request
):
"""
Décrémente
les rattrapages des membres passés dans la requête """
"""
Met à jour
les rattrapages des membres passés dans la requête """
res
=
{}
res
=
{}
is_connected_user
=
CagetteUser
.
are_credentials_ok
(
request
)
is_connected_user
=
CagetteUser
.
are_credentials_ok
(
request
)
if
is_connected_user
is
True
:
if
is_connected_user
is
True
:
members_data
=
json
.
loads
(
request
.
body
.
decode
())
members_data
=
json
.
loads
(
request
.
body
.
decode
())
res
[
"res"
]
=
CagetteMembers
.
update_members_makeups
(
members_data
)
res
[
"res"
]
=
[]
for
member_data
in
members_data
:
cm
=
CagetteMember
(
int
(
member_data
[
"member_id"
]))
res
[
"res"
]
.
append
(
cm
.
update_member_makeups
(
member_data
))
if
"decrement_pts"
in
member_data
and
member_data
[
"decrement_pts"
]
is
True
:
data
=
{
'name'
:
"Ajout manuel d'un rattrapage depuis l'admin BDM"
,
'shift_id'
:
False
,
'type'
:
member_data
[
"member_shift_type"
],
'partner_id'
:
int
(
member_data
[
"member_id"
]),
'point_qty'
:
-
1
}
cm
.
update_member_points
(
data
)
response
=
JsonResponse
(
res
)
response
=
JsonResponse
(
res
)
else
:
else
:
...
...
members/models.py
View file @
717c2f7d
...
@@ -827,6 +827,19 @@ class CagetteMember(models.Model):
...
@@ -827,6 +827,19 @@ class CagetteMember(models.Model):
except
:
except
:
return
None
return
None
def
update_member_makeups
(
self
,
member_data
):
api
=
OdooAPI
()
res
=
{}
f
=
{
'makeups_to_do'
:
int
(
member_data
[
"target_makeups_nb"
])
}
res_item
=
api
.
update
(
'res.partner'
,
[
self
.
id
],
f
)
res
=
{
'mid'
:
self
.
id
,
'update'
:
res_item
}
return
res
class
CagetteMembers
(
models
.
Model
):
class
CagetteMembers
(
models
.
Model
):
"""Class to manage operations on all members or part of them."""
"""Class to manage operations on all members or part of them."""
...
@@ -1052,25 +1065,10 @@ class CagetteMembers(models.Model):
...
@@ -1052,25 +1065,10 @@ class CagetteMembers(models.Model):
def
get_makeups_members
():
def
get_makeups_members
():
api
=
OdooAPI
()
api
=
OdooAPI
()
cond
=
[[
'makeups_to_do'
,
'>'
,
0
]]
cond
=
[[
'makeups_to_do'
,
'>'
,
0
]]
fields
=
[
'id'
,
'name'
,
'makeups_to_do'
]
fields
=
[
'id'
,
'name'
,
'makeups_to_do'
,
'shift_type'
]
res
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
res
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
return
res
return
res
@staticmethod
def
update_members_makeups
(
members_data
):
api
=
OdooAPI
()
res
=
[]
for
member_data
in
members_data
:
member_id
=
int
(
member_data
[
"member_id"
])
f
=
{
'makeups_to_do'
:
int
(
member_data
[
"target_makeups_nb"
])
}
res_item
=
api
.
update
(
'res.partner'
,
[
member_id
],
f
)
res
.
append
({
'mid'
:
member_id
,
'update'
:
res_item
})
return
res
class
CagetteServices
(
models
.
Model
):
class
CagetteServices
(
models
.
Model
):
"""Class to handle cagette Odoo services."""
"""Class to handle cagette Odoo services."""
...
...
members/static/js/members_admin.js
View file @
717c2f7d
...
@@ -123,7 +123,7 @@ function display_makeups_members() {
...
@@ -123,7 +123,7 @@ function display_makeups_members() {
"Tout"
"Tout"
]
]
],
],
iDisplayLength
:
-
1
,
iDisplayLength
:
25
,
oLanguage
:
{
oLanguage
:
{
"sProcessing"
:
"Traitement en cours..."
,
"sProcessing"
:
"Traitement en cours..."
,
"sSearch"
:
"Rechercher dans le tableau"
,
"sSearch"
:
"Rechercher dans le tableau"
,
...
@@ -280,9 +280,13 @@ function increment_makeups(member_ids) {
...
@@ -280,9 +280,13 @@ function increment_makeups(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
;
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
});
});
}
}
...
@@ -349,7 +353,8 @@ function display_possible_members() {
...
@@ -349,7 +353,8 @@ function display_possible_members() {
makeups_members
.
unshift
({
makeups_members
.
unshift
({
id
:
member
.
id
,
id
:
member
.
id
,
name
:
member
.
name
,
name
:
member
.
name
,
makeups_to_do
:
0
makeups_to_do
:
0
,
shift_type
:
member
.
shift_type
});
});
openModal
(
openModal
(
...
...
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