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
d0fea7ae
Commit
d0fea7ae
authored
Mar 04, 2022
by
Thibault Grandjean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
can select parent
parent
5d9feee1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
63 deletions
+81
-63
admin.py
members/admin.py
+3
-19
manage_attached.js
members/static/js/admin/manage_attached.js
+70
-24
manage_attached_create_pair.html
templates/members/admin/manage_attached_create_pair.html
+8
-20
No files found.
members/admin.py
View file @
d0fea7ae
...
@@ -410,7 +410,7 @@ def delete_shift_registration(request):
...
@@ -410,7 +410,7 @@ def delete_shift_registration(request):
# Gestion des binômes
# Gestion des binômes
def
get_member_info
(
request
,
member
_id
):
def
get_member_info
(
request
,
coop
_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
)
...
@@ -418,6 +418,7 @@ def get_member_info(request, member_id):
...
@@ -418,6 +418,7 @@ def get_member_info(request, member_id):
api
=
OdooAPI
()
api
=
OdooAPI
()
fields
=
[
fields
=
[
'id'
,
'id'
,
'name'
,
'sex'
,
'sex'
,
'cooperative_state'
,
'cooperative_state'
,
'email'
,
'email'
,
...
@@ -430,27 +431,10 @@ def get_member_info(request, member_id):
...
@@ -430,27 +431,10 @@ def get_member_info(request, member_id):
'parent_id'
,
'parent_id'
,
'is_associated_people'
,
'is_associated_people'
,
]
]
member
=
api
.
search_read
(
'res.partner'
,
[[
'
id'
,
'='
,
member
_id
]],
fields
)
member
=
api
.
search_read
(
'res.partner'
,
[[
'
barcode_base'
,
'='
,
coop
_id
]],
fields
)
# get incomming shifts
fields
=
[
"date_begin"
,
"date_end"
,
"final_standard_point"
,
"shift_id"
,
"shift_type"
,
"partner_id"
,
"id"
,
]
cond
=
[
[
"partner_id.id"
,
"="
,
member_id
],
[
"state"
,
"="
,
"open"
],
[
"date_begin"
,
">"
,
datetime
.
datetime
.
now
()
.
isoformat
()],
]
shifts
=
api
.
search_read
(
'shift.registration'
,
cond
,
fields
,
order
=
"date_begin ASC"
)
if
member
:
if
member
:
res
[
'member'
]
=
member
[
0
]
res
[
'member'
]
=
member
[
0
]
res
[
'member'
][
'incoming_shifts'
]
=
shifts
response
=
JsonResponse
(
res
)
response
=
JsonResponse
(
res
)
else
:
else
:
response
=
JsonResponse
({
"message"
:
"Not found"
},
status
=
404
)
response
=
JsonResponse
({
"message"
:
"Not found"
},
status
=
404
)
...
...
members/static/js/admin/manage_attached.js
View file @
d0fea7ae
var
parentId
=
null
;
var
childId
=
null
;
/**
/**
* Load member infos
* Load member infos
*/
*/
function
load_member_infos
()
{
function
load_member_infos
(
divId
,
memberId
)
{
console
.
log
(
memberId
)
$
.
ajax
({
$
.
ajax
({
type
:
'GET'
,
type
:
'GET'
,
url
:
"/members/get_member_info/"
+
selected_member
.
i
d
,
url
:
"/members/get_member_info/"
+
memberI
d
,
dataType
:
"json"
,
dataType
:
"json"
,
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
)
display_member_infos
(
divId
,
data
.
member
)
display_member_infos
(
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'
};
...
@@ -26,18 +29,13 @@ function load_member_infos() {
...
@@ -26,18 +29,13 @@ function load_member_infos() {
}
}
/**
/**
* Display table of member future shifts
* Display member info
*/
function
display_member_shifts
()
{
}
/**
* Display table of member future shifts
*/
*/
function
display_member_infos
(
memberData
)
{
function
display_member_infos
(
divId
,
memberData
)
{
$
(
"#"
+
divId
).
show
()
console
.
log
(
memberData
)
console
.
log
(
memberData
)
shifts
=
memberData
.
incoming_shifts
$
(
"#"
+
divId
).
find
(
"#name"
).
text
(
memberData
.
name
)
}
}
...
@@ -58,23 +56,24 @@ $(document).ready(function() {
...
@@ -58,23 +56,24 @@ $(document).ready(function() {
window
.
location
.
assign
(
base_location
);
window
.
location
.
assign
(
base_location
);
});
});
// Set action to search for the member
$
(
'#search_member_form'
).
submit
(
function
()
{
let
search_str
=
$
(
'#search_member_input'
).
val
();
$
(
"#search_member_input"
).
autocomplete
({
source
:
function
(
request
,
response
)
{
$
.
ajax
({
$
.
ajax
({
url
:
'/members/search/'
+
search_str
,
url
:
'/members/search/'
+
request
.
term
,
dataType
:
'json'
,
dataType
:
'json'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
members_search_results
=
[];
members_search_results
=
[];
for
(
member
of
data
.
res
)
{
for
(
member
of
data
.
res
)
{
if
(
member
.
is_member
||
member
.
is_associated_people
)
{
if
(
member
.
is_member
||
member
.
is_associated_people
)
{
members_search_results
.
push
(
member
);
members_search_results
.
push
(
member
);
}
}
}
}
response
(
$
.
map
(
data
.
res
,
function
(
item
)
{
display_possible_members
();
return
{
label
:
item
.
barcode_base
+
' '
+
item
.
name
,
value
:
item
.
barcode_base
}
}))
},
},
error
:
function
()
{
error
:
function
()
{
err
=
{
err
=
{
...
@@ -87,7 +86,55 @@ $(document).ready(function() {
...
@@ -87,7 +86,55 @@ $(document).ready(function() {
globalPosition
:
"top right"
,
globalPosition
:
"top right"
,
className
:
"error"
className
:
"error"
});
});
},
}
}
)
},
minLength
:
3
,
select
:
function
(
event
,
ui
)
{
if
(
ui
.
item
)
{
load_member_infos
(
"parentInfo"
,
ui
.
item
.
value
)
}
}
})
$
(
"#search_child_input"
).
autocomplete
({
source
:
function
(
request
,
response
)
{
$
.
ajax
({
url
:
'/members/search/'
+
request
.
term
,
dataType
:
'json'
,
success
:
function
(
data
)
{
members_search_results
=
[];
for
(
member
of
data
.
res
)
{
if
(
member
.
is_member
||
member
.
is_associated_people
)
{
members_search_results
.
push
(
member
);
}
}
console
.
log
(
members_search_results
)
response
(
$
.
map
(
data
.
res
,
function
(
item
)
{
return
{
label
:
item
.
barcode_base
+
' '
+
item
.
name
,
value
:
item
.
barcode_base
}
}))
},
error
:
function
()
{
err
=
{
msg
:
"erreur serveur lors de la recherche de membres"
,
ctx
:
'search_member_form.search_members'
};
report_JS_error
(
err
,
'members.admin'
);
$
.
notify
(
"Erreur lors de la recherche de membre, il faut ré-essayer plus tard..."
,
{
globalPosition
:
"top right"
,
className
:
"error"
});
});
});
},
});
}
\ No newline at end of file
)
},
minLength
:
3
,
select
:
function
(
event
,
ui
)
{
return
null
},
})
})
templates/members/admin/manage_attached_create_pair.html
View file @
d0fea7ae
...
@@ -27,38 +27,26 @@
...
@@ -27,38 +27,26 @@
<div
class=
"page_content"
>
<div
class=
"page_content"
>
<div
class=
"tiles_container"
>
<div
class=
"tiles_container"
>
<div
class=
"tile high_tile"
>
<div
class=
"tile high_tile"
>
<div
id=
"search_member_form_area"
>
<div
id=
"search_member_form_area"
>
<h4>
Rechercher le.a coopérateur.ice titulaire
</h4>
<h4>
Rechercher le.a coopérateur.ice titulaire
</h4>
<form
id=
"search_member_form"
action=
"javascript:;"
method=
"post"
>
<form
autocomplete=
"off"
id=
"search_member_form"
action=
"javascript:;"
method=
"post"
>
<input
type=
"text"
id=
"search_member_input"
value=
""
placeholder=
"Nom ou numéro du coop..."
required
>
<input
name=
"searchParent"
type=
"text"
id=
"search_member_input"
value=
""
placeholder=
"Nom ou numéro du coop..."
required
>
<button
type=
"submit"
class=
"btn--primary"
id=
"search_member_button"
>
Recherche
</button>
</form>
</form>
</div>
</div>
<div
class=
"search_member_results_area"
style=
"display:none;"
>
<div
id=
"parentInfo"
style=
"display:none;"
>
<div
class=
"search_results_text"
>
<div>
Nom
</div><div
id=
"name"
></div>
<p><i>
Choisissez parmi les membres trouvés :
</i></p>
</div>
</div>
<div
class=
"search_member_results"
></div>
</div>
</div>
</div>
</div>
<div
class=
"tile "
>
<div
class=
"tiles_container"
>
<div
class=
"tile high_tile"
>
<div
id=
"search_member_form_area"
>
<div
id=
"search_member_form_area"
>
<h4>
Rechercher le.a coopérateur.ice co-titulaire
</h4>
<h4>
Rechercher le.a coopérateur.ice co-titulaire
</h4>
<form
id=
"search_member_form"
action=
"javascript:;"
method=
"post"
>
<form
autocomplete=
"off"
id=
"search_member_form_child"
action=
"javascript:;"
method=
"post"
>
<input
type=
"text"
id=
"search_member_input"
value=
""
placeholder=
"Nom ou numéro du coop..."
required
>
<input
name=
"searchChild"
type=
"text"
id=
"search_child_input"
value=
""
placeholder=
"Nom ou numéro du coop..."
required
>
<button
type=
"submit"
class=
"btn--primary"
id=
"search_member_button"
>
Recherche
</button>
</form>
</form>
</div>
</div>
<div
class=
"search_member_results_area"
style=
"display:none;"
>
<div
class=
"search_results_text"
>
<p><i>
Choisissez parmi les membres trouvés :
</i></p>
</div>
<div
class=
"search_member_results"
></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
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