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
ab49214a
Commit
ab49214a
authored
Mar 08, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent deleting a makeup
parent
23109cf5
Pipeline
#1879
passed with stage
in 1 minute 28 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
10 deletions
+26
-10
members-space-shifts-exchange.js
members_space/static/js/members-space-shifts-exchange.js
+21
-7
models.py
shifts/models.py
+1
-1
index.html
templates/members_space/index.html
+4
-2
No files found.
members_space/static/js/members-space-shifts-exchange.js
View file @
ab49214a
...
@@ -265,6 +265,9 @@ function offer_extra_shift() {
...
@@ -265,6 +265,9 @@ function offer_extra_shift() {
timeout
:
3000
,
timeout
:
3000
,
success
:
function
()
{
success
:
function
()
{
$
(
"#can_delete_future_registrations_area"
).
hide
();
$
(
"#can_delete_future_registrations_area"
).
hide
();
$
(
".delete_registration_button"
).
off
();
$
(
".delete_registration_button"
).
hide
();
closeModal
();
closeModal
();
alert
(
"Don de service effectué"
);
alert
(
"Don de service effectué"
);
},
},
...
@@ -287,17 +290,17 @@ function init_shifts_list() {
...
@@ -287,17 +290,17 @@ function init_shifts_list() {
}
else
{
}
else
{
$
(
"#shifts_list"
).
empty
();
$
(
"#shifts_list"
).
empty
();
for
(
shift
of
incoming_shifts
)
{
for
(
let
shift
of
incoming_shifts
)
{
let
shift_line_template
=
$
(
"#selectable_shift_line_template"
);
let
shift_line_template
=
$
(
"#selectable_shift_line_template"
);
let
datetime_shift_start
=
new
Date
(
shift
.
date_begin
.
replace
(
/
\s
/
,
'T'
));
let
datetime_shift_start
=
new
Date
(
shift
.
date_begin
.
replace
(
/
\s
/
,
'T'
));
let
f_date_shift_start
=
datetime_shift_start
.
toLocaleDateString
(
"fr-fr"
,
date_options
);
let
f_date_shift_start
=
datetime_shift_start
.
toLocaleDateString
(
"fr-fr"
,
date_options
);
f_date_shift_start
=
f_date_shift_start
.
charAt
(
0
).
toUpperCase
()
+
f_date_shift_start
.
slice
(
1
);
f_date_shift_start
=
f_date_shift_start
.
charAt
(
0
).
toUpperCase
()
+
f_date_shift_start
.
slice
(
1
);
shift_line_template
.
find
(
".shift_line_date"
).
text
(
f_date_shift_start
);
shift_line_template
.
find
(
".shift_line_date"
).
text
(
f_date_shift_start
);
shift_line_template
.
find
(
".shift_line_time"
).
text
(
datetime_shift_start
.
toLocaleTimeString
(
"fr-fr"
,
time_options
));
shift_line_template
.
find
(
".shift_line_time"
).
text
(
datetime_shift_start
.
toLocaleTimeString
(
"fr-fr"
,
time_options
));
// Disable or not
if
(
!
can_exchange_shifts
()
&&
block_actions_for_attached_people
===
"True"
)
{
if
(
!
can_exchange_shifts
()
&&
block_actions_for_attached_people
===
"True"
)
{
shift_line_template
.
find
(
".selectable_shift_line"
).
removeClass
(
"btn--primary"
);
shift_line_template
.
find
(
".selectable_shift_line"
).
removeClass
(
"btn--primary"
);
shift_line_template
.
find
(
".selectable_shift_line"
).
addClass
(
"btn"
);
shift_line_template
.
find
(
".selectable_shift_line"
).
addClass
(
"btn"
);
...
@@ -309,6 +312,7 @@ function init_shifts_list() {
...
@@ -309,6 +312,7 @@ function init_shifts_list() {
shift_line_template
.
find
(
".checkbox"
).
prop
(
"value"
,
shift
.
id
);
shift_line_template
.
find
(
".checkbox"
).
prop
(
"value"
,
shift
.
id
);
}
}
// Set assign shift button
if
(
partner_data
.
associated_partner_id
===
"False"
&&
partner_data
.
parent_id
===
"False"
)
{
if
(
partner_data
.
associated_partner_id
===
"False"
&&
partner_data
.
parent_id
===
"False"
)
{
shift_line_template
.
find
(
'.affect_associate_registered'
).
hide
();
shift_line_template
.
find
(
'.affect_associate_registered'
).
hide
();
}
else
{
}
else
{
...
@@ -333,6 +337,16 @@ function init_shifts_list() {
...
@@ -333,6 +337,16 @@ function init_shifts_list() {
}
}
}
}
// Set delete registration button if shift isn't a makeup
if
(
partner_data
.
extra_shift_done
>
0
&&
shift
.
is_makeup
===
false
)
{
if
(
shift_line_template
.
find
(
".delete_registration_button"
).
length
===
0
)
{
let
delete_reg_button_template
=
$
(
"#delete_registration_button_template"
);
shift_line_template
.
find
(
".shift_line_container"
).
append
(
delete_reg_button_template
.
html
());
}
}
else
{
shift_line_template
.
find
(
".delete_registration_button"
).
remove
();
}
$
(
"#shifts_list"
).
append
(
shift_line_template
.
html
());
$
(
"#shifts_list"
).
append
(
shift_line_template
.
html
());
}
}
...
@@ -446,7 +460,7 @@ function init_calendar_page() {
...
@@ -446,7 +460,7 @@ function init_calendar_page() {
$
(
"#offer_extra_shift"
).
on
(
"click"
,
()
=>
{
$
(
"#offer_extra_shift"
).
on
(
"click"
,
()
=>
{
openModal
(
openModal
(
"
Je ne souhaite pas supprimer un service futur.
"
,
"
<p>Je ne souhaite pas supprimer un service futur.</p>
"
,
offer_extra_shift
,
offer_extra_shift
,
"Confirmer"
,
"Confirmer"
,
false
false
...
@@ -681,8 +695,6 @@ function init_read_only_calendar_page() {
...
@@ -681,8 +695,6 @@ function init_read_only_calendar_page() {
}
}
function
init_delete_registration_buttons
()
{
function
init_delete_registration_buttons
()
{
$
(
".delete_registration_button"
).
css
(
'display'
,
'flex'
);
$
(
".delete_registration_button"
).
off
();
$
(
".delete_registration_button"
).
off
();
$
(
".delete_registration_button"
).
on
(
"click"
,
function
()
{
$
(
".delete_registration_button"
).
on
(
"click"
,
function
()
{
let
shift_name
=
$
(
this
).
closest
(
"div"
).
siblings
(
".selectable_shift_line"
).
text
().
trim
();
let
shift_name
=
$
(
this
).
closest
(
"div"
).
siblings
(
".selectable_shift_line"
).
text
().
trim
();
...
@@ -690,14 +702,16 @@ function init_delete_registration_buttons() {
...
@@ -690,14 +702,16 @@ function init_delete_registration_buttons() {
.
split
(
'_'
)[
2
];
.
split
(
'_'
)[
2
];
openModal
(
openModal
(
`
Je m'apprête supprimer ma présence au service du <b>
${
shift_name
}
</b
>`
,
`
<p>Je m'apprête supprimer ma présence au service du <b>
${
shift_name
}
</b></p
>`
,
()
=>
{
()
=>
{
delete_shift_registration
(
shift_id
);
delete_shift_registration
(
shift_id
);
},
},
"Confirmer"
,
"Confirmer"
,
false
false
)
)
;
});
});
$
(
".delete_registration_button"
).
css
(
'display'
,
'flex'
);
}
}
function
init_shifts_exchange
()
{
function
init_shifts_exchange
()
{
...
...
shifts/models.py
View file @
ab49214a
...
@@ -92,7 +92,7 @@ class CagetteShift(models.Model):
...
@@ -92,7 +92,7 @@ class CagetteShift(models.Model):
def
get_shift_partner
(
self
,
id
):
def
get_shift_partner
(
self
,
id
):
"""Récupère les shift du membre"""
"""Récupère les shift du membre"""
fields
=
[
'date_begin'
,
'date_end'
,
'final_standard_point'
,
fields
=
[
'date_begin'
,
'date_end'
,
'final_standard_point'
,
'shift_id'
,
'shift_type'
,
'partner_id'
,
"id"
,
"associate_registered"
]
# res.partner
'shift_id'
,
'shift_type'
,
'partner_id'
,
"id"
,
"associate_registered"
,
"is_makeup"
]
# res.partner
cond
=
[[
'partner_id.id'
,
'='
,
id
],[
'state'
,
'='
,
'open'
],
cond
=
[[
'partner_id.id'
,
'='
,
id
],[
'state'
,
'='
,
'open'
],
[
'date_begin'
,
'>'
,
datetime
.
datetime
.
now
()
.
isoformat
()]]
[
'date_begin'
,
'>'
,
datetime
.
datetime
.
now
()
.
isoformat
()]]
shiftData
=
self
.
o_api
.
search_read
(
'shift.registration'
,
cond
,
fields
,
order
=
"date_begin ASC"
)
shiftData
=
self
.
o_api
.
search_read
(
'shift.registration'
,
cond
,
fields
,
order
=
"date_begin ASC"
)
...
...
templates/members_space/index.html
View file @
ab49214a
...
@@ -44,10 +44,13 @@
...
@@ -44,10 +44,13 @@
</div>
</div>
</div>
</div>
<div
class=
"affect_associate_registered button--warning"
></div>
<div
class=
"affect_associate_registered button--warning"
></div>
<div
class=
"delete_registration_button"
><i
class=
"fas fa-lg fa-trash"
></i></div>
</div>
</div>
</div>
</div>
<div
id=
"delete_registration_button_template"
>
<div
class=
"delete_registration_button"
><i
class=
"fas fa-lg fa-trash"
></i></div>
</div>
<div
id=
"modal_affect_shift"
>
<div
id=
"modal_affect_shift"
>
<div>
Qui sera présent.e ?
</div>
<div>
Qui sera présent.e ?
</div>
<div
id=
"shift_partner"
class=
"btn--primary"
>
<div
id=
"shift_partner"
class=
"btn--primary"
>
...
@@ -57,7 +60,6 @@
...
@@ -57,7 +60,6 @@
<div
id=
"shift_both"
class=
" btn--primary"
>
<div
id=
"shift_both"
class=
" btn--primary"
>
Les deux
Les deux
</div>
</div>
</div>
</div>
<div
id=
"modal_shift_exchange_template"
>
<div
id=
"modal_shift_exchange_template"
>
...
...
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