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
38dee935
Commit
38dee935
authored
Mar 09, 2022
by
Thibault Grandjean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update pair create
parent
5cd5e736
Pipeline
#1896
failed with stage
in 1 minute 26 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
25 deletions
+54
-25
admin.py
members/admin.py
+28
-6
manage_attached.js
members/static/js/admin/manage_attached.js
+26
-19
No files found.
members/admin.py
View file @
38dee935
...
@@ -415,7 +415,7 @@ def delete_shift_registration(request):
...
@@ -415,7 +415,7 @@ def delete_shift_registration(request):
# Gestion des binômes
# Gestion des binômes
def
get_member_info
(
request
,
coop_
id
):
def
get_member_info
(
request
,
id
):
"""Retrieve information about a member."""
"""Retrieve information about a member."""
res
=
{}
res
=
{}
is_connected_user
=
CagetteUser
.
are_credentials_ok
(
request
)
is_connected_user
=
CagetteUser
.
are_credentials_ok
(
request
)
...
@@ -438,7 +438,8 @@ def get_member_info(request,coop_id):
...
@@ -438,7 +438,8 @@ def get_member_info(request,coop_id):
'parent_name'
,
'parent_name'
,
"makeups_to_do"
"makeups_to_do"
]
]
member
=
api
.
search_read
(
'res.partner'
,
[[
'barcode_base'
,
'='
,
coop_id
]],
fields
)
cond
=
[[
'id'
,
'='
,
id
]]
member
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
if
member
:
if
member
:
res
[
'member'
]
=
member
[
0
]
res
[
'member'
]
=
member
[
0
]
...
@@ -448,7 +449,6 @@ def get_member_info(request,coop_id):
...
@@ -448,7 +449,6 @@ def get_member_info(request,coop_id):
else
:
else
:
res
[
'message'
]
=
"Unauthorized"
res
[
'message'
]
=
"Unauthorized"
response
=
JsonResponse
(
res
,
status
=
403
)
response
=
JsonResponse
(
res
,
status
=
403
)
print
(
response
.
content
)
return
response
return
response
...
@@ -476,7 +476,7 @@ def create_pair(request):
...
@@ -476,7 +476,7 @@ def create_pair(request):
child_id
=
data
[
'child'
][
'id'
]
child_id
=
data
[
'child'
][
'id'
]
# create attached account for child
# create attached account for child
fields
=
[
fields
=
[
#
"birthdate",
"birthdate"
,
"city"
,
"city"
,
"commercial_partner_id"
,
"commercial_partner_id"
,
"company_id"
,
"company_id"
,
...
@@ -498,10 +498,32 @@ def create_pair(request):
...
@@ -498,10 +498,32 @@ def create_pair(request):
"street"
,
"street"
,
"street2"
,
"street2"
,
"zip"
,
"zip"
,
"nb_associated_people"
"nb_associated_people"
,
"current_template_name"
]
]
child
=
api
.
search_read
(
'res.partner'
,
[[
'id'
,
'='
,
child_id
]],
fields
)[
0
]
child
=
api
.
search_read
(
'res.partner'
,
[[
'id'
,
'='
,
child_id
]],
fields
)[
0
]
parent
=
api
.
search_read
(
'res.partner'
,
[[
'id'
,
'='
,
parent_id
]],
[
'commercial_partner_id'
])[
0
]
parent
=
api
.
search_read
(
'res.partner'
,
[[
'id'
,
'='
,
parent_id
]],
[
'commercial_partner_id'
,
'nb_associated_people'
,
'parent_id'
])[
0
]
errors
=
[]
if
child
[
'nb_associated_people'
]
>
0
:
# le membre est déjà titulaire d'un binôme
errors
.
append
(
"Le membre suppléant sélectionné est titulaire d'un bînome"
)
# 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é"
)
# le membre titulaire a déjà un/des suppléants?
if
parent
[
'nb_associated_people'
]
>=
1
:
# On récupère le/s suppléant(s)
associated_members
=
api
.
search_read
(
'res.partner'
,
[[
'parent_id'
,
'='
,
parent_id
]],
[
'id'
,
'age'
])
# le suppléant est un mineur?
for
m
in
associated_members
:
if
m
[
'age'
]
>
18
:
errors
.
append
(
"Le membre titulaire sélectionné a déjà un suppléant"
)
if
errors
:
return
JsonResponse
({
"errors"
:
errors
},
status
=
409
)
del
child
[
"id"
]
del
child
[
"id"
]
for
field
in
child
.
keys
():
for
field
in
child
.
keys
():
if
field
.
endswith
(
"_id"
):
if
field
.
endswith
(
"_id"
):
...
...
members/static/js/admin/manage_attached.js
View file @
38dee935
...
@@ -15,7 +15,6 @@ const possible_cooperative_state = {
...
@@ -15,7 +15,6 @@ const possible_cooperative_state = {
* Load member infos
* Load member infos
*/
*/
function
load_member_infos
(
divId
,
memberId
)
{
function
load_member_infos
(
divId
,
memberId
)
{
console
.
log
(
memberId
)
$
.
ajax
({
$
.
ajax
({
type
:
'GET'
,
type
:
'GET'
,
url
:
"/members/get_member_info/"
+
memberId
,
url
:
"/members/get_member_info/"
+
memberId
,
...
@@ -23,14 +22,12 @@ function load_member_infos(divId, memberId) {
...
@@ -23,14 +22,12 @@ function load_member_infos(divId, memberId) {
traditional
:
true
,
traditional
:
true
,
contentType
:
"application/json; charset=utf-8"
,
contentType
:
"application/json; charset=utf-8"
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
log
(
data
)
if
(
divId
===
'parentInfo'
)
{
console
.
log
(
divId
)
parentId
=
data
.
member
.
id
if
(
divId
===
'parentInfo'
)
{
}
else
if
(
divId
===
'childInfo'
)
{
parentId
=
data
.
member
.
id
childId
=
data
.
member
.
id
}
else
if
(
divId
===
'childInfo'
)
{
}
childId
=
data
.
member
.
id
display_member_infos
(
divId
,
data
.
member
)
}
display_member_infos
(
divId
,
data
.
member
)
},
},
error
:
function
(
data
)
{
error
:
function
(
data
)
{
err
=
{
msg
:
"erreur serveur lors de la récupération des infos du membre"
,
ctx
:
'load_member_infos'
};
err
=
{
msg
:
"erreur serveur lors de la récupération des infos du membre"
,
ctx
:
'load_member_infos'
};
...
@@ -104,11 +101,14 @@ function display_member_infos(divId, memberData) {
...
@@ -104,11 +101,14 @@ function display_member_infos(divId, memberData) {
* Display table of attached members
* Display table of attached members
*/
*/
function
display_attached_members
()
{
function
display_attached_members
()
{
if
(
attached_members_table
)
{
$
(
'#attached_members_table'
).
off
();
// load_attached_members()
attached_members_table
.
clear
().
destroy
();
// var attached_members_table = $('#attached_members_table')
$
(
'#attached_members_table'
).
empty
();
// if (attached_members_table) {
}
// $('#attached_members_table').off();
// attached_members_table.clear().destroy();
// $('#attached_members_table').empty();
// }
attached_members_table
=
$
(
'#attached_members_table'
).
DataTable
({
attached_members_table
=
$
(
'#attached_members_table'
).
DataTable
({
data
:
attached_members
,
data
:
attached_members
,
...
@@ -208,7 +208,7 @@ $(document).ready(function() {
...
@@ -208,7 +208,7 @@ $(document).ready(function() {
response
(
$
.
map
(
data
.
res
,
function
(
item
)
{
response
(
$
.
map
(
data
.
res
,
function
(
item
)
{
return
{
return
{
label
:
item
.
barcode_base
+
' '
+
item
.
name
,
label
:
item
.
barcode_base
+
' '
+
item
.
name
,
value
:
item
.
barcode_base
value
:
item
.
id
}
}
}))
}))
},
},
...
@@ -229,8 +229,11 @@ $(document).ready(function() {
...
@@ -229,8 +229,11 @@ $(document).ready(function() {
},
},
minLength
:
1
,
minLength
:
1
,
select
:
function
(
event
,
ui
)
{
select
:
function
(
event
,
ui
)
{
event
.
preventDefault
();
if
(
ui
.
item
)
{
if
(
ui
.
item
)
{
load_member_infos
(
"parentInfo"
,
ui
.
item
.
value
)
load_member_infos
(
"parentInfo"
,
ui
.
item
.
value
)
$
(
'#search_member_input'
).
val
(
ui
.
item
.
label
)
return
false
}
}
}
}
})
})
...
@@ -250,7 +253,7 @@ $(document).ready(function() {
...
@@ -250,7 +253,7 @@ $(document).ready(function() {
response
(
$
.
map
(
data
.
res
,
function
(
item
)
{
response
(
$
.
map
(
data
.
res
,
function
(
item
)
{
return
{
return
{
label
:
item
.
barcode_base
+
' '
+
item
.
name
,
label
:
item
.
barcode_base
+
' '
+
item
.
name
,
value
:
item
.
barcode_base
value
:
item
.
id
}
}
}))
}))
},
},
...
@@ -273,6 +276,8 @@ $(document).ready(function() {
...
@@ -273,6 +276,8 @@ $(document).ready(function() {
select
:
function
(
event
,
ui
)
{
select
:
function
(
event
,
ui
)
{
if
(
ui
.
item
)
{
if
(
ui
.
item
)
{
load_member_infos
(
"childInfo"
,
ui
.
item
.
value
)
load_member_infos
(
"childInfo"
,
ui
.
item
.
value
)
$
(
'#search_child_input'
).
val
(
ui
.
item
.
label
)
return
false
}
}
},
},
})
})
...
@@ -295,13 +300,15 @@ $(document).ready(function() {
...
@@ -295,13 +300,15 @@ $(document).ready(function() {
},
},
error
:
function
(
data
)
{
error
:
function
(
data
)
{
err
=
{
msg
:
"erreur serveur"
,
ctx
:
'create pair'
};
err
=
{
msg
:
"erreur serveur"
,
ctx
:
'create pair'
};
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
s
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
s
;
}
}
report_JS_error
(
err
,
'members.admin'
);
report_JS_error
(
err
,
'members.admin'
);
closeModal
();
closeModal
();
alert
(
'Erreur lors de création du binôme.'
);
var
message
=
'Erreur lors de création du binôme.'
data
.
responseJSON
.
errors
.
map
(
function
(
error
){
message
+=
(
'
\
n'
+
error
)})
alert
(
message
);
}
}
})
})
})
})
...
...
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