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
b7449d7f
Commit
b7449d7f
authored
Feb 04, 2025
by
Yvon Kerdoncuff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
control binom creation both from admin bdm and preinscription + control member is not exempted
parent
00efdbef
Pipeline
#4110
canceled with stage
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
54 deletions
+92
-54
admin.py
members/admin.py
+4
-45
models.py
members/models.py
+69
-0
inscriptions.js
members/static/js/inscriptions.js
+9
-9
urls.py
members/urls.py
+2
-0
views.py
members/views.py
+8
-0
No files found.
members/admin.py
View file @
b7449d7f
...
@@ -757,30 +757,11 @@ def create_pair(request):
...
@@ -757,30 +757,11 @@ def create_pair(request):
'parent_id'
,
'parent_id'
,
'suppleant_member_id'
])[
0
]
'suppleant_member_id'
])[
0
]
case
=
is_partner_involved_in_binom
(
api
,
child
)
errors
=
CagetteMember
.
can_become_suppleant
(
child_id
)
if
errors
:
errors
=
[]
return
JsonResponse
({
"errors"
:
errors
},
status
=
409
)
if
case
==
"MEMBER_SUPPLEANT_OF_BINOM"
:
errors
.
append
(
"Le suppléant sélectionné est déjà suppléant d'un binôme."
)
elif
case
==
"CONTACT_OF_MEMBER_SUPPLEANT_OF_BINOM"
:
errors
.
append
(
"Le suppléant sélectionné est déjà (le contact d'un membre) suppléant d'un binôme."
)
elif
case
==
"TITULAIRE_OF_BINOM"
:
errors
.
append
(
"Le suppléant sélectionné est déjà titulaire d'un binôme."
)
# le membre suppléant fait parti du commité?
if
child
[
'current_template_name'
]
==
"Services des comités"
:
errors
.
append
(
"Le membre suppléant séléctionné fait parti du comité"
)
case
=
is_partner_involved_in_binom
(
api
,
parent
)
errors
=
[]
if
case
==
"MEMBER_SUPPLEANT_OF_BINOM"
:
errors
.
append
(
"Le titulaire sélectionné est déjà suppléant d'un binôme."
)
elif
case
==
"CONTACT_OF_MEMBER_SUPPLEANT_OF_BINOM"
:
errors
.
append
(
"Le titulaire sélectionné est déjà (le contact d'un membre) suppléant d'un binôme."
)
elif
case
==
"TITULAIRE_OF_BINOM"
:
errors
.
append
(
"Le titulaire sélectionné est déjà titulaire d'un binôme."
)
errors
=
CagetteMember
.
can_become_titulaire
(
parent_id
)
if
errors
:
if
errors
:
return
JsonResponse
({
"errors"
:
errors
},
status
=
409
)
return
JsonResponse
({
"errors"
:
errors
},
status
=
409
)
...
@@ -884,28 +865,6 @@ def handle_suppleant_scheduled_makeups_on_pairing(parent_id, child, child_schedu
...
@@ -884,28 +865,6 @@ def handle_suppleant_scheduled_makeups_on_pairing(parent_id, child, child_schedu
cs
.
set_shift
(
data
)
# Automaticaly decrements makeups_to_do to preserve total count.
cs
.
set_shift
(
data
)
# Automaticaly decrements makeups_to_do to preserve total count.
parent_scheduled_makeups_length
=
parent_scheduled_makeups_length
+
1
parent_scheduled_makeups_length
=
parent_scheduled_makeups_length
+
1
def
is_partner_involved_in_binom
(
api
,
partner
):
# First make sure the selected partner "is not already a suppleant"
# Let's be prudent : cover both case of partner being suppleant member,
# and case of partner being the contact of a suppleant member
contact_of_partner_suppleant
=
api
.
search_read
(
'res.partner'
,
[[
'suppleant_member_id'
,
'='
,
partner
[
'id'
]]])
if
contact_of_partner_suppleant
:
# partner has a suppleant contact therefore it is a suppleant member
return
"MEMBER_SUPPLEANT_OF_BINOM"
if
partner
[
'parent_id'
]
and
partner
[
'suppleant_member_id'
]:
# partner is the contact of a suppleant member
return
"CONTACT_OF_MEMBER_SUPPLEANT_OF_BINOM"
# Second make sure the selected partner is not a titulaire
children_of_partner
=
api
.
search_read
(
'res.partner'
,
[[
'parent_id'
,
'='
,
partner
[
'id'
]]])
suppleant_of_partner
=
[
x
for
x
in
children_of_partner
if
x
[
'suppleant_member_id'
]]
if
suppleant_of_partner
:
# partner is titulaire
return
"TITULAIRE_OF_BINOM"
return
None
def
delete_pair
(
request
):
def
delete_pair
(
request
):
"""
"""
Administration des binômes membres
Administration des binômes membres
...
...
members/models.py
View file @
b7449d7f
...
@@ -981,6 +981,75 @@ class CagetteMember(models.Model):
...
@@ -981,6 +981,75 @@ class CagetteMember(models.Model):
return
res
return
res
@staticmethod
@staticmethod
def
is_partner_involved_in_binom
(
partner
):
api
=
OdooAPI
()
# First make sure the selected partner "is not already a suppleant"
# Let's be prudent : cover both case of partner being suppleant member,
# and case of partner being the contact of a suppleant member
contact_of_partner_suppleant
=
api
.
search_read
(
'res.partner'
,
[[
'suppleant_member_id'
,
'='
,
partner
[
'id'
]]])
if
contact_of_partner_suppleant
:
# partner has a suppleant contact therefore it is a suppleant member
return
"MEMBER_SUPPLEANT_OF_BINOM"
if
partner
[
'parent_id'
]
and
partner
[
'suppleant_member_id'
]:
# partner is the contact of a suppleant member
return
"CONTACT_OF_MEMBER_SUPPLEANT_OF_BINOM"
# Second make sure the selected partner is not a titulaire
children_of_partner
=
api
.
search_read
(
'res.partner'
,
[[
'parent_id'
,
'='
,
partner
[
'id'
]]])
suppleant_of_partner
=
[
x
for
x
in
children_of_partner
if
x
[
'suppleant_member_id'
]]
if
suppleant_of_partner
:
# partner is titulaire
return
"TITULAIRE_OF_BINOM"
return
None
@staticmethod
def
can_become_titulaire
(
parent_id
):
api
=
OdooAPI
()
parent
=
api
.
search_read
(
'res.partner'
,
[[
'id'
,
'='
,
parent_id
]],
[
'parent_id'
,
'suppleant_member_id'
,
'cooperative_state'
])[
0
]
parent
[
'id'
]
=
parent_id
# needed ?
case
=
CagetteMember
.
is_partner_involved_in_binom
(
parent
)
errors
=
[]
if
case
==
"MEMBER_SUPPLEANT_OF_BINOM"
:
errors
.
append
(
"Le titulaire sélectionné est déjà suppléant d'un binôme."
)
elif
case
==
"CONTACT_OF_MEMBER_SUPPLEANT_OF_BINOM"
:
errors
.
append
(
"Le titulaire sélectionné est déjà (le contact d'un membre) suppléant d'un binôme."
)
elif
case
==
"TITULAIRE_OF_BINOM"
:
errors
.
append
(
"Le titulaire sélectionné est déjà titulaire d'un binôme."
)
if
parent
[
'cooperative_state'
]
==
"exempted"
:
errors
.
append
(
"Le titulaire séléctionné est exempté."
)
return
errors
@staticmethod
def
can_become_suppleant
(
child_id
):
api
=
OdooAPI
()
child
=
api
.
search_read
(
'res.partner'
,
[[
'id'
,
'='
,
child_id
]],
[
'parent_id'
,
'suppleant_member_id'
,
'cooperative_state'
])[
0
]
child
[
'id'
]
=
child_id
# needed ?
case
=
CagetteMember
.
is_partner_involved_in_binom
(
child
)
errors
=
[]
if
case
==
"MEMBER_SUPPLEANT_OF_BINOM"
:
errors
.
append
(
"Le suppléant sélectionné est déjà suppléant d'un binôme."
)
elif
case
==
"CONTACT_OF_MEMBER_SUPPLEANT_OF_BINOM"
:
errors
.
append
(
"Le suppléant sélectionné est déjà (le contact d'un membre) suppléant d'un binôme."
)
elif
case
==
"TITULAIRE_OF_BINOM"
:
errors
.
append
(
"Le suppléant sélectionné est déjà titulaire d'un binôme."
)
if
child
[
'cooperative_state'
]
==
"exempted"
:
errors
.
append
(
"Le membre suppléant séléctionné est exempté."
)
return
errors
@staticmethod
def
remove_data_from_CouchDB
(
request
):
def
remove_data_from_CouchDB
(
request
):
res
=
{}
res
=
{}
try
:
try
:
...
...
members/static/js/inscriptions.js
View file @
b7449d7f
...
@@ -316,23 +316,23 @@ function store_new_coop(event) {
...
@@ -316,23 +316,23 @@ function store_new_coop(event) {
errors
.
push
(
"Il y a déjà un enregistrement Odoo avec cette adresse mail !"
);
errors
.
push
(
"Il y a déjà un enregistrement Odoo avec cette adresse mail !"
);
}
}
if
(
selected_associate
!=
null
)
{
if
(
selected_associate
!=
null
)
{
$
.
ajax
({
url
:
'/members/
is_associated
/'
+
selected_associate
.
id
,
$
.
ajax
({
url
:
'/members/
can_become_titulaire
/'
+
selected_associate
.
id
,
dataType
:
'json'
dataType
:
'json'
}).
done
(
function
(
rData
)
{
}).
done
(
function
(
rData
)
{
if
(
typeof
(
rData
.
answer
)
==
'boolean'
&&
rData
.
answer
==
true
)
{
if
(
typeof
rData
.
errors
!=
'undefined'
&&
rData
.
errors
.
length
)
{
errors
.
push
(
"Ce membre a déjà un binôme majeur"
);
var
message
=
'Ce membre ne peut pas être choisi comme titulaire.'
;
}
rData
.
errors
.
map
(
function
(
error
)
{
if
(
errors
.
length
==
0
)
{
message
+=
(
'
\
n'
+
error
);
return
null
;
});
alert
(
message
);
}
else
{
_really_save_new_coop
(
_really_save_new_coop
(
email
,
fname
,
lname
,
email
,
fname
,
lname
,
subs_cap
.
val
(),
payment_meaning
.
val
(),
ch_qty
.
val
(),
bc
,
msex
,
mjob
subs_cap
.
val
(),
payment_meaning
.
val
(),
ch_qty
.
val
(),
bc
,
msex
,
mjob
);
);
}
else
{
alert
(
errors
.
join
(
"
\
n"
));
}
}
});
});
}
else
{
}
else
{
if
(
errors
.
length
==
0
)
{
if
(
errors
.
length
==
0
)
{
_really_save_new_coop
(
_really_save_new_coop
(
...
...
members/urls.py
View file @
b7449d7f
...
@@ -32,6 +32,8 @@ urlpatterns = [
...
@@ -32,6 +32,8 @@ urlpatterns = [
url
(
r'^get/([0-9]+)$'
,
views
.
get
),
url
(
r'^get/([0-9]+)$'
,
views
.
get
),
url
(
r'^exists/([a-zA-Z0-9_\-\.\+@]+)$'
,
views
.
exists
),
url
(
r'^exists/([a-zA-Z0-9_\-\.\+@]+)$'
,
views
.
exists
),
url
(
r'^is_associated/([0-9]+)$'
,
views
.
is_associated
),
url
(
r'^is_associated/([0-9]+)$'
,
views
.
is_associated
),
url
(
r'^can_become_suppleant/([0-9]+)$'
,
views
.
can_become_suppleant
),
url
(
r'^can_become_titulaire/([0-9]+)$'
,
views
.
can_become_titulaire
),
url
(
r'^get_couchdb_odoo_markers/(.+)$'
,
views
.
get_couchdb_odoo_markers
),
url
(
r'^get_couchdb_odoo_markers/(.+)$'
,
views
.
get_couchdb_odoo_markers
),
url
(
r'^menu/$'
,
views
.
menu
),
url
(
r'^menu/$'
,
views
.
menu
),
url
(
r'^verify_final_state$'
,
views
.
verify_final_state
),
url
(
r'^verify_final_state$'
,
views
.
verify_final_state
),
...
...
members/views.py
View file @
b7449d7f
...
@@ -77,6 +77,14 @@ def is_associated(request, id_parent):
...
@@ -77,6 +77,14 @@ def is_associated(request, id_parent):
answer
=
CagetteMember
.
is_associated
(
id_parent
)
answer
=
CagetteMember
.
is_associated
(
id_parent
)
return
JsonResponse
({
'answer'
:
answer
})
return
JsonResponse
({
'answer'
:
answer
})
def
can_become_titulaire
(
request
,
id_parent
):
errors
=
CagetteMember
.
can_become_titulaire
(
id_parent
)
return
JsonResponse
({
"errors"
:
errors
})
def
can_become_suppleant
(
request
,
id_child
):
errors
=
CagetteMember
.
can_become_suppleant
(
id_child
)
return
JsonResponse
({
"errors"
:
errors
})
def
getmemberimage
(
request
,
id
):
def
getmemberimage
(
request
,
id
):
m
=
CagetteMember
(
id
)
m
=
CagetteMember
(
id
)
call_res
=
m
.
get_image
()
call_res
=
m
.
get_image
()
...
...
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