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
2ce57329
Commit
2ce57329
authored
Mar 14, 2022
by
Thibault Grandjean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update modal and create
parent
b073169b
Pipeline
#1945
passed with stage
in 1 minute 30 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
14 deletions
+69
-14
admin.py
members/admin.py
+22
-7
manage_attached.js
members/static/js/admin/manage_attached.js
+42
-5
manage_attached_create_pair.html
templates/members/admin/manage_attached_create_pair.html
+2
-1
manage_attached_delete_pair.html
templates/members/admin/manage_attached_delete_pair.html
+3
-1
No files found.
members/admin.py
View file @
2ce57329
...
...
@@ -436,13 +436,18 @@ def get_member_info(request, id):
'parent_id'
,
'is_associated_people'
,
'parent_name'
,
"makeups_to_do"
"makeups_to_do"
,
"barcode_base"
]
cond
=
[[
'id'
,
'='
,
id
]]
member
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
if
member
:
res
[
'member'
]
=
member
[
0
]
member
=
member
[
0
]
parent
=
None
if
member
[
'parent_id'
]:
parent
=
api
.
search_read
(
'res.partner'
,
[[
'id'
,
'='
,
int
(
member
[
'parent_id'
][
0
])]],
[
'barcode_base'
])[
0
]
member
[
'parent_barcode_base'
]
=
parent
[
'barcode_base'
]
res
[
'member'
]
=
member
response
=
JsonResponse
(
res
)
else
:
response
=
JsonResponse
({
"message"
:
"Not found"
},
status
=
404
)
...
...
@@ -451,8 +456,6 @@ def get_member_info(request, id):
response
=
JsonResponse
(
res
,
status
=
403
)
return
response
def
create_pair
(
request
):
"""Create pair
...
...
@@ -502,12 +505,14 @@ def create_pair(request):
"current_template_name"
,
"parent_id"
,
"is_associated_people"
,
"makeups_to_do"
]
child
=
api
.
search_read
(
'res.partner'
,
[[
'id'
,
'='
,
child_id
]],
fields
)[
0
]
parent
=
api
.
search_read
(
'res.partner'
,
[[
'id'
,
'='
,
parent_id
]],
[
'commercial_partner_id'
,
'nb_associated_people'
,
'current_template_name'
,
'makeups_to_do'
,
'parent_id'
])[
0
]
errors
=
[]
if
child
[
'nb_associated_people'
]
>
0
:
...
...
@@ -542,17 +547,27 @@ def create_pair(request):
child
[
field
]
=
False
child
[
'is_associated_people'
]
=
True
child
[
'parent_id'
]
=
parent
[
'id'
]
# fusion des rattrapages
if
child
[
"makeups_to_do"
]
<=
2
:
api
.
update
(
"res.partner"
,
[
parent_id
],
{
"makeups_to_do"
:
parent
[
'makeups_to_do'
]
+
child
[
'makeups_to_do'
]})
# remise à zéro du compte suppléant
api
.
update
(
"res.partner"
,
[
child_id
],
{
"makeups_to_do"
:
0
})
else
:
api
.
update
(
"res.partner"
,
[
parent_id
],
{
"makeups_to_do"
:
2
})
# remise à zéro du compte suppléant
api
.
update
(
"res.partner"
,
[
child_id
],
{
"makeups_to_do"
:
0
})
# update child base account state
api
.
execute
(
"res.partner"
,
"set_special_state"
,
{
"id"
:
child_id
,
'state'
:
"associated"
})
# suppression du créneau pour le compte de base
shift_registration
=
api
.
search_read
(
"shift.template.registration"
,
[[
'partner_id'
,
'='
,
child_id
]],
[
'id'
])
api
.
delete
(
"shift.template.registration"
,
[
x
[
'id'
]
for
x
in
shift_registration
])
# suppression des rattrapages ?
# get barcode rule id
bbcode_rule
=
api
.
search_read
(
"barcode.rule"
,
[[
'for_associated_people'
,
"="
,
True
]],
[
'id'
])[
0
]
child
[
'barcode_rule_id'
]
=
bbcode_rule
[
"id"
]
# TODO: le compte rattaché doit être ajouté dans le créneau du titulaire
child
.
pop
(
"makeups_to_do"
)
attached_account
=
api
.
create
(
'res.partner'
,
child
)
# generate_base
api
.
execute
(
'res.partner'
,
'generate_base'
,
[
attached_account
])
...
...
members/static/js/admin/manage_attached.js
View file @
2ce57329
var
parentId
=
null
;
var
childId
=
null
;
var
parentName
=
null
;
var
childName
=
null
;
const
possible_cooperative_state
=
{
suspended
:
"Rattrapage"
,
exempted
:
"Exempté.e"
,
...
...
@@ -8,7 +11,8 @@ const possible_cooperative_state = {
up_to_date
:
"À jour"
,
unsubscribed
:
"Désinscrit.e des créneaux"
,
delay
:
"En délai"
,
gone
:
"Parti.e"
gone
:
"Parti.e"
,
associated
:
"En binôme"
};
/**
...
...
@@ -22,10 +26,13 @@ function load_member_infos(divId, memberId) {
traditional
:
true
,
contentType
:
"application/json; charset=utf-8"
,
success
:
function
(
data
)
{
console
.
log
(
data
.
member
)
if
(
divId
===
'parentInfo'
)
{
parentId
=
data
.
member
.
id
;
parentName
=
data
.
member
.
barcode_base
+
' '
+
data
.
member
.
name
}
else
if
(
divId
===
'childInfo'
)
{
childId
=
data
.
member
.
id
;
childName
=
data
.
member
.
barcode_base
+
' '
+
data
.
member
.
name
}
display_member_infos
(
divId
,
data
.
member
);
},
...
...
@@ -88,7 +95,7 @@ function load_attached_members() {
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
}
report_JS_error
(
err
,
'
ord
ers'
);
report_JS_error
(
err
,
'
memb
ers'
);
closeModal
();
alert
(
'Erreur serveur lors de la récupération des membres en binôme. Ré-essayez plus tard.'
);
...
...
@@ -216,7 +223,13 @@ function delete_pair(childId) {
function
confirmDeletion
(
childId
)
{
var
modalContent
=
$
(
"#confirmModal"
).
html
()
var
modalContent
=
$
(
'#confirmModal'
)
modalContent
.
find
(
"#parentName"
).
text
(
parentName
)
modalContent
.
find
(
"#childName"
).
text
(
childName
)
modalContent
=
modalContent
.
html
();
openModal
(
modalContent
,
()
=>
{
if
(
is_time_to
(
'delete_pair'
))
{
delete_pair
(
childId
)
...
...
@@ -376,7 +389,10 @@ $(document).ready(function() {
"child"
:
{
"id"
:
childId
}
};
var
modalContent
=
$
(
'#confirmModal'
).
html
();
var
modalContent
=
$
(
'#confirmModal'
)
modalContent
.
find
(
"#parentName"
).
text
(
parentName
)
modalContent
.
find
(
"#childName"
).
text
(
childName
)
modalContent
=
modalContent
.
html
();
openModal
(
modalContent
,
()
=>
{
if
(
is_time_to
(
'create_pair'
))
{
create_pair
(
payload
)
...
...
@@ -390,7 +406,28 @@ $(document).ready(function() {
$
(
document
).
on
(
'click'
,
'.delete_pair'
,
function
(
event
)
{
var
childId
=
event
.
target
.
id
.
split
(
'_'
).
slice
(
-
1
)[
0
];
$
.
ajax
({
type
:
'GET'
,
url
:
"/members/get_member_info/"
+
childId
,
dataType
:
"json"
,
traditional
:
true
,
contentType
:
"application/json; charset=utf-8"
,
success
:
function
(
data
)
{
console
.
log
(
data
.
member
)
parentName
=
data
.
member
.
parent_barcode_base
+
' - '
+
data
.
member
.
parent_name
childName
=
data
.
member
.
barcode_base
+
' - '
+
data
.
member
.
name
confirmDeletion
(
childId
);
},
error
:
function
(
data
)
{
err
=
{
msg
:
"erreur serveur lors de la récupération des infos du membre"
,
ctx
:
'load_member_infos'
};
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
}
report_JS_error
(
err
,
'members.admin'
);
closeModal
();
alert
(
'Erreur lors de la récupération des infos du membre.'
);
}
});
});
});
templates/members/admin/manage_attached_create_pair.html
View file @
2ce57329
...
...
@@ -18,7 +18,8 @@
<div
id=
"confirmModal"
>
<h3>
Le binôme est sur le point d'être créé
</h3>
<br/>
<p>
Êtes-vous sur de vouloir continuer
</p>
<p>
Voulez-vous vraiment créer le binôme avec comme titulaire
<b><span
id=
"parentName"
></span></b>
et comme suppléant
<b><span
id=
"childName"
></span></b>
<p>
Êtes-vous sur de vouloir continuer ?
</p>
<hr/>
</div>
</div>
...
...
templates/members/admin/manage_attached_delete_pair.html
View file @
2ce57329
...
...
@@ -19,7 +19,9 @@
<div
class=
"mconfirm"
>
<h3>
Le binôme est sur le point d'être désolidarisé
</h3>
<br
/>
<p>
Êtes-vous sur de vouloir continuer
</p>
<p>
Êtes-vous sur de vouloir désolidariser
<b><span
id=
"parentName"
></span></b>
et
<b><span
id=
"childName"
></span></b>
</p>
<hr/>
</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