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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
19 deletions
+48
-19
admin.py
members/admin.py
+28
-6
manage_attached.js
members/static/js/admin/manage_attached.js
+20
-13
No files found.
members/admin.py
View file @
38dee935
...
...
@@ -415,7 +415,7 @@ def delete_shift_registration(request):
# Gestion des binômes
def
get_member_info
(
request
,
coop_
id
):
def
get_member_info
(
request
,
id
):
"""Retrieve information about a member."""
res
=
{}
is_connected_user
=
CagetteUser
.
are_credentials_ok
(
request
)
...
...
@@ -438,7 +438,8 @@ def get_member_info(request,coop_id):
'parent_name'
,
"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
:
res
[
'member'
]
=
member
[
0
]
...
...
@@ -448,7 +449,6 @@ def get_member_info(request,coop_id):
else
:
res
[
'message'
]
=
"Unauthorized"
response
=
JsonResponse
(
res
,
status
=
403
)
print
(
response
.
content
)
return
response
...
...
@@ -476,7 +476,7 @@ def create_pair(request):
child_id
=
data
[
'child'
][
'id'
]
# create attached account for child
fields
=
[
#
"birthdate",
"birthdate"
,
"city"
,
"commercial_partner_id"
,
"company_id"
,
...
...
@@ -498,10 +498,32 @@ def create_pair(request):
"street"
,
"street2"
,
"zip"
,
"nb_associated_people"
"nb_associated_people"
,
"current_template_name"
]
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"
]
for
field
in
child
.
keys
():
if
field
.
endswith
(
"_id"
):
...
...
members/static/js/admin/manage_attached.js
View file @
38dee935
...
...
@@ -15,7 +15,6 @@ const possible_cooperative_state = {
* Load member infos
*/
function
load_member_infos
(
divId
,
memberId
)
{
console
.
log
(
memberId
)
$
.
ajax
({
type
:
'GET'
,
url
:
"/members/get_member_info/"
+
memberId
,
...
...
@@ -23,8 +22,6 @@ function load_member_infos(divId, memberId) {
traditional
:
true
,
contentType
:
"application/json; charset=utf-8"
,
success
:
function
(
data
)
{
console
.
log
(
data
)
console
.
log
(
divId
)
if
(
divId
===
'parentInfo'
)
{
parentId
=
data
.
member
.
id
}
else
if
(
divId
===
'childInfo'
)
{
...
...
@@ -104,11 +101,14 @@ function display_member_infos(divId, memberData) {
* Display table of attached members
*/
function
display_attached_members
()
{
if
(
attached_members_table
)
{
$
(
'#attached_members_table'
).
off
();
attached_members_table
.
clear
().
destroy
();
$
(
'#attached_members_table'
).
empty
();
}
// load_attached_members()
// var attached_members_table = $('#attached_members_table')
// if (attached_members_table) {
// $('#attached_members_table').off();
// attached_members_table.clear().destroy();
// $('#attached_members_table').empty();
// }
attached_members_table
=
$
(
'#attached_members_table'
).
DataTable
({
data
:
attached_members
,
...
...
@@ -208,7 +208,7 @@ $(document).ready(function() {
response
(
$
.
map
(
data
.
res
,
function
(
item
)
{
return
{
label
:
item
.
barcode_base
+
' '
+
item
.
name
,
value
:
item
.
barcode_base
value
:
item
.
id
}
}))
},
...
...
@@ -229,8 +229,11 @@ $(document).ready(function() {
},
minLength
:
1
,
select
:
function
(
event
,
ui
)
{
event
.
preventDefault
();
if
(
ui
.
item
)
{
load_member_infos
(
"parentInfo"
,
ui
.
item
.
value
)
$
(
'#search_member_input'
).
val
(
ui
.
item
.
label
)
return
false
}
}
})
...
...
@@ -250,7 +253,7 @@ $(document).ready(function() {
response
(
$
.
map
(
data
.
res
,
function
(
item
)
{
return
{
label
:
item
.
barcode_base
+
' '
+
item
.
name
,
value
:
item
.
barcode_base
value
:
item
.
id
}
}))
},
...
...
@@ -273,6 +276,8 @@ $(document).ready(function() {
select
:
function
(
event
,
ui
)
{
if
(
ui
.
item
)
{
load_member_infos
(
"childInfo"
,
ui
.
item
.
value
)
$
(
'#search_child_input'
).
val
(
ui
.
item
.
label
)
return
false
}
},
})
...
...
@@ -295,13 +300,15 @@ $(document).ready(function() {
},
error
:
function
(
data
)
{
err
=
{
msg
:
"erreur serveur"
,
ctx
:
'create pair'
};
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
s
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
s
;
}
report_JS_error
(
err
,
'members.admin'
);
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