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
f2da7d5a
Commit
f2da7d5a
authored
Jan 13, 2025
by
Yvon Kerdoncuff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#7319 : prevent adding makeup to an exempted person
parent
47d81479
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
5 deletions
+15
-5
admin.py
members/admin.py
+6
-1
fonctions.py
shifts/fonctions.py
+8
-0
models.py
shifts/models.py
+1
-4
No files found.
members/admin.py
View file @
f2da7d5a
...
...
@@ -10,6 +10,7 @@ from shifts.models import CagetteShift
from
members_space.models
import
CagetteMembersSpace
from
outils.common
import
MConfig
from
datetime
import
datetime
,
date
import
shifts.fonctions
default_msettings
=
{
'msg_accueil'
:
{
'title'
:
'Message borne accueil'
,
'type'
:
'textarea'
,
...
...
@@ -397,6 +398,7 @@ def update_members_makeups(request):
# Perform checks and compute some data in a loop on members.
cs
=
CagetteShift
()
unsubscription_limit
=
api
.
get_system_param
(
'lacagette_membership.points_limit_to_get_unsubscribed'
)
error
=
[]
for
member_data
in
members_data
:
cm
=
CagetteMember
(
int
(
member_data
[
"member_id"
]))
target_makeups_nb
=
int
(
member_data
[
"target_makeups_nb"
])
...
...
@@ -404,7 +406,6 @@ def update_members_makeups(request):
# Prevent setting a negative number of makeups_to_do https://redmine.coopdev.fr/issues/6090
# This could happen when bdm has two screens open and clicks on minus btn on a coop line
# with exactly 1 makeup_to_do on both screens
error
=
[]
error
[
"error"
]
=
"L'opération de rattrapage a été annulée car le nombre de rattrapage cible est négatif."
return
JsonResponse
(
error
,
status
=
400
)
makeup_change_count
=
target_makeups_nb
-
cs
.
get_member_makeups_to_do
(
cm
.
id
)
...
...
@@ -414,6 +415,10 @@ def update_members_makeups(request):
error
[
"error"
]
\
=
"L'ajout de rattrapage a été annulé car il provoquerait la désinscription d'un membre."
return
JsonResponse
(
error
,
status
=
400
)
res_exempted
=
shifts
.
fonctions
.
get_exempted_ids_from
(
api
,
[
member_data
[
"member_id"
]])
if
res_exempted
:
error
[
"error"
]
=
"L'opération de rattrapage a été annulée car le membre ciblé est exempté."
return
JsonResponse
(
error
,
status
=
400
)
# Save computed data in member_data. It will be useful to update makeups and points.
members_data
[
member_data
[
"member_id"
]][
"points_diff"
]
=
-
makeup_change_count
...
...
shifts/fonctions.py
View file @
f2da7d5a
...
...
@@ -41,3 +41,10 @@ def get_shift_partner(api, id, start_date=None, end_date=None):
else
:
is_ftop
=
True
return
[
shifts
,
is_ftop
]
def
get_exempted_ids_from
(
api
,
partner_ids
):
cond
=
[[
'id'
,
'in'
,
partner_ids
],
[
'cooperative_state'
,
'in'
,
[
'exempted'
]]]
fields
=
[
'id'
]
return
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
\ No newline at end of file
shifts/models.py
View file @
f2da7d5a
...
...
@@ -836,10 +836,7 @@ class CagetteServices(models.Model):
ids
=
[]
excluded_partner
=
[]
canceled_reg_ids
=
[]
# for exempted people
cond
=
[[
'id'
,
'in'
,
partner_ids
],
[
'cooperative_state'
,
'in'
,
[
'exempted'
]]]
fields
=
[
'id'
]
res_exempted
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
res_exempted
=
shifts
.
fonctions
.
get_exempted_ids_from
(
api
,
partner_ids
)
for
r
in
res_exempted
:
excluded_partner
.
append
(
int
(
r
[
'id'
]))
for
r
in
res
:
...
...
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