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
53918063
Commit
53918063
authored
Oct 11, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BDM: WIP increase member delay
parent
5b16ab6e
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
103 additions
and
5 deletions
+103
-5
admin.py
members/admin.py
+13
-0
models.py
members/models.py
+1
-1
manage_makeups.css
members/static/css/admin/manage_makeups.css
+5
-0
manage_makeups.js
members/static/js/admin/manage_makeups.js
+74
-3
urls.py
members/urls.py
+1
-0
manage_makeups.html
templates/members/admin/manage_makeups.html
+9
-1
No files found.
members/admin.py
View file @
53918063
...
...
@@ -415,6 +415,19 @@ def update_members_makeups(request):
response
=
JsonResponse
(
res
,
status
=
403
)
return
response
def
regenerate_member_delay
(
request
):
""" From BDM admin, close existing extension if exists & recreate for 6 months """
res
=
{}
is_connected_user
=
CagetteUser
.
are_credentials_ok
(
request
)
if
is_connected_user
is
True
:
data
=
json
.
loads
(
request
.
body
.
decode
())
print
(
data
[
"member_id"
])
response
=
JsonResponse
(
res
,
safe
=
False
)
else
:
res
[
"message"
]
=
"Unauthorized"
response
=
JsonResponse
(
res
,
status
=
403
)
return
response
# --- Gestion des créneaux
...
...
members/models.py
View file @
53918063
...
...
@@ -1260,7 +1260,7 @@ class CagetteMembers(models.Model):
def
get_makeups_members
():
api
=
OdooAPI
()
cond
=
[[
'makeups_to_do'
,
'>'
,
0
]]
fields
=
[
'id'
,
'name'
,
'display_std_points'
,
'display_ftop_points'
,
'shift_type'
,
'makeups_to_do'
]
fields
=
[
'id'
,
'name'
,
'display_std_points'
,
'display_ftop_points'
,
'shift_type'
,
'makeups_to_do'
,
'date_delay_stop'
]
res
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
return
res
...
...
members/static/css/admin/manage_makeups.css
View file @
53918063
...
...
@@ -68,3 +68,7 @@
.btn_possible_member
{
margin
:
0
1rem
;
}
.member_name
{
font-weight
:
bold
;
}
\ No newline at end of file
members/static/js/admin/manage_makeups.js
View file @
53918063
...
...
@@ -69,10 +69,29 @@ function display_makeups_members() {
title
:
"Nom"
},
{
data
:
"id"
,
title
:
""
,
className
:
"dt-body-center"
,
orderable
:
false
,
width
:
"10%"
,
render
:
function
(
data
,
type
,
row
)
{
return
`<button class="btn--primary extend_delay_button" data-member-id="
${
row
.
id
}
">Augmenter le délai</button>`
;
}
},
{
data
:
"date_delay_stop"
,
title
:
"Limite du délai"
,
className
:
"dt-body-center"
,
width
:
"10%"
,
render
:
function
(
data
)
{
return
(
data
===
false
)
?
"Pas de délai en cours"
:
new
Date
(
data
).
toLocaleDateString
();
}
},
{
data
:
"shift_type"
,
title
:
"Nb de points"
,
className
:
"dt-body-center"
,
width
:
"
10
%"
,
width
:
"
5
%"
,
render
:
function
(
data
,
type
,
row
)
{
if
(
data
==
'ftop'
)
{
return
row
.
display_ftop_points
;
...
...
@@ -212,6 +231,23 @@ function display_makeups_members() {
.
hide
();
}
});
$
(
'#makeups_members_table'
).
on
(
'click'
,
'tbody td .extend_delay_button'
,
function
()
{
const
member_id
=
this
.
dataset
.
memberId
;
const
member
=
makeups_members
.
find
(
m
=>
m
.
id
==
member_id
);
let
modal
=
$
(
"#modal_extend_delay_template"
);
modal
.
find
(
".member_name"
).
text
(
member
.
name
);
openModal
(
modal
.
html
(),
()
=>
{
extend_member_delay
(
member
);
},
"Confirmer"
,
false
);
});
}
/**
...
...
@@ -276,10 +312,45 @@ function update_members_makeups(member_ids, action) {
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
}
report_JS_error
(
err
,
'members_admin'
);
report_JS_error
(
err
,
'members_admin-manage_makeups'
);
closeModal
();
alert
(
'Erreur serveur pour décrémenter les rattrapages. Veuillez contacer le service informatique.'
);
}
});
}
/**
* Send request to extend the member's delay, or create one if none open.
* @param {Object} member
*/
function
extend_member_delay
(
member
)
{
openModal
();
let
data
=
{
member_id
:
member
.
id
};
$
.
ajax
({
type
:
'POST'
,
url
:
"/members/admin/regenerate_member_delay"
,
data
:
JSON
.
stringify
(
data
),
dataType
:
"json"
,
traditional
:
true
,
contentType
:
"application/json; charset=utf-8"
,
success
:
function
()
{
display_makeups_members
();
closeModal
();
},
error
:
function
(
data
)
{
err
=
{
msg
:
"erreur serveur pour créer un délai"
,
ctx
:
'extend_member_delay'
};
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
}
report_JS_error
(
err
,
'members_admin-manage_makeups'
);
closeModal
();
alert
(
'Erreur serveur pour
décrémenter les rattrapages. Ré-essayez plus tard
.'
);
alert
(
'Erreur serveur pour
créer un délai. Veuillez contacer le service informatique
.'
);
}
});
}
...
...
members/urls.py
View file @
53918063
...
...
@@ -66,6 +66,7 @@ urlpatterns = [
url
(
r'^delete_shift_template_registration$'
,
admin
.
delete_shift_template_registration
),
url
(
r'^shift_subscription$'
,
admin
.
shift_subscription
),
url
(
r'^admin/manage_attached$'
,
admin
.
manage_attached
),
url
(
r'^admin/regenerate_member_delay$'
,
admin
.
regenerate_member_delay
),
url
(
r'^admin/manage_attached/create_pair$'
,
admin
.
create_pair
),
url
(
r'^admin/manage_attached/delete_pair$'
,
admin
.
delete_pair
),
url
(
r'^get_makeups_members$'
,
admin
.
get_makeups_members
),
...
...
templates/members/admin/manage_makeups.html
View file @
53918063
...
...
@@ -56,7 +56,15 @@
</div>
<div
id=
"templates"
style=
"display:none;"
></div>
<div
id=
"templates"
style=
"display:none;"
>
<div
id=
"modal_extend_delay_template"
>
<p>
Vous vous apprêtez à rallonger le délai de
<span
class=
"member_name"
></span>
pour une durée de 6 mois à partir d'aujourd'hui.
</p>
</div>
</div>
</div>
<script
src=
'{% static "js/all_common.js" %}?v=1651853225'
></script>
...
...
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