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
730e964d
Commit
730e964d
authored
Mar 11, 2022
by
Etienne Freiss
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_cooperatic' into 2463-go-to-normal-validation-for-associated-member
parents
756ec12a
3ecb4014
Pipeline
#1934
passed with stage
in 1 minute 28 seconds
Changes
18
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
384 additions
and
143 deletions
+384
-143
admin.py
members/admin.py
+14
-4
models.py
members/models.py
+34
-5
manage_shift_registrations.css
members/static/css/admin/manage_shift_registrations.css
+4
-0
member.css
members/static/css/member.css
+4
-2
manage_makeups.js
members/static/js/admin/manage_makeups.js
+13
-0
manage_shift_registrations.js
members/static/js/admin/manage_shift_registrations.js
+19
-4
inscriptions.js
members/static/js/inscriptions.js
+20
-8
members.js
members/static/js/members.js
+84
-24
views.py
members/views.py
+8
-2
members-space-shifts-exchange.css
members_space/static/css/members-space-shifts-exchange.css
+55
-7
members-space-home.js
members_space/static/js/members-space-home.js
+0
-64
members-space-shifts-exchange.js
members_space/static/js/members-space-shifts-exchange.js
+20
-8
members-space.js
members_space/static/js/members-space.js
+64
-4
views.py
members_space/views.py
+4
-2
common.css
outils/static/css/common.css
+2
-1
models.py
shifts/models.py
+8
-1
index.html
templates/members/index.html
+20
-2
index.html
templates/members_space/index.html
+11
-5
No files found.
members/admin.py
View file @
730e964d
...
@@ -385,14 +385,24 @@ def delete_shift_registration(request):
...
@@ -385,14 +385,24 @@ def delete_shift_registration(request):
is_connected_user
=
CagetteUser
.
are_credentials_ok
(
request
)
is_connected_user
=
CagetteUser
.
are_credentials_ok
(
request
)
if
is_connected_user
is
True
:
if
is_connected_user
is
True
:
data
=
json
.
loads
(
request
.
body
.
decode
())
data
=
json
.
loads
(
request
.
body
.
decode
())
shift_registration_id
=
int
(
data
[
"shift_registration_id"
])
member_id
=
int
(
data
[
"member_id"
])
member_id
=
int
(
data
[
"member_id"
])
shift_registration_id
=
int
(
data
[
"shift_registration_id"
])
m
=
CagetteShift
()
shift_is_makeup
=
data
[
"shift_is_makeup"
]
res
[
"res"
]
=
m
.
cancel_shift
([
shift_registration_id
])
# Note: 'upcoming_registration_count' in res.partner won't change because the _compute method
# Note: 'upcoming_registration_count' in res.partner won't change because the _compute method
# in odoo counts canceled shift registrations.
# in odoo counts canceled shift registrations.
m
=
CagetteShift
()
res
[
"cancel_shift"
]
=
m
.
cancel_shift
([
shift_registration_id
])
if
shift_is_makeup
is
True
:
fields
=
{
'name'
:
"Admin BDM - Suppression d'un rattrapage"
,
'shift_id'
:
False
,
'type'
:
data
[
"member_shift_type"
],
'partner_id'
:
member_id
,
'point_qty'
:
1
}
res
[
"update_counter"
]
=
m
.
update_counter_event
(
fields
)
response
=
JsonResponse
(
res
,
safe
=
False
)
response
=
JsonResponse
(
res
,
safe
=
False
)
else
:
else
:
...
...
members/models.py
View file @
730e964d
...
@@ -133,6 +133,7 @@ class CagetteMember(models.Model):
...
@@ -133,6 +133,7 @@ class CagetteMember(models.Model):
fp
=
request
.
POST
.
get
(
'fp'
)
# fingerprint (prevent using stolen cookies)
fp
=
request
.
POST
.
get
(
'fp'
)
# fingerprint (prevent using stolen cookies)
if
login
and
password
:
if
login
and
password
:
api
=
OdooAPI
()
api
=
OdooAPI
()
login
=
login
.
strip
()
cond
=
[[
'email'
,
'='
,
login
]]
cond
=
[[
'email'
,
'='
,
login
]]
if
getattr
(
settings
,
'ALLOW_NON_MEMBER_TO_CONNECT'
,
False
)
is
False
:
if
getattr
(
settings
,
'ALLOW_NON_MEMBER_TO_CONNECT'
,
False
)
is
False
:
cond
.
append
(
'|'
)
cond
.
append
(
'|'
)
...
@@ -1146,7 +1147,7 @@ class CagetteMembers(models.Model):
...
@@ -1146,7 +1147,7 @@ class CagetteMembers(models.Model):
def
get_makeups_members
():
def
get_makeups_members
():
api
=
OdooAPI
()
api
=
OdooAPI
()
cond
=
[[
'makeups_to_do'
,
'>'
,
0
]]
cond
=
[[
'makeups_to_do'
,
'>'
,
0
]]
fields
=
[
'id'
,
'name'
,
'
makeups_to_do'
,
'shift_type
'
]
fields
=
[
'id'
,
'name'
,
'
display_std_points'
,
'display_ftop_points'
,
'shift_type'
,
'makeups_to_do
'
]
res
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
res
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
return
res
return
res
...
@@ -1255,7 +1256,7 @@ class CagetteServices(models.Model):
...
@@ -1255,7 +1256,7 @@ class CagetteServices(models.Model):
)
.
total_seconds
()
/
60
>
default_acceptable_minutes_after_shift_begins
)
.
total_seconds
()
/
60
>
default_acceptable_minutes_after_shift_begins
if
with_members
is
True
:
if
with_members
is
True
:
cond
=
[[
'id'
,
'in'
,
s
[
'registration_ids'
]],
[
'state'
,
'not in'
,
[
'cancel'
,
'waiting'
,
'draft'
]]]
cond
=
[[
'id'
,
'in'
,
s
[
'registration_ids'
]],
[
'state'
,
'not in'
,
[
'cancel'
,
'waiting'
,
'draft'
]]]
fields
=
[
'partner_id'
,
'shift_type'
,
'state'
,
'is_late'
]
fields
=
[
'partner_id'
,
'shift_type'
,
'state'
,
'is_late'
,
'associate_registered'
]
members
=
api
.
search_read
(
'shift.registration'
,
cond
,
fields
)
members
=
api
.
search_read
(
'shift.registration'
,
cond
,
fields
)
s
[
'members'
]
=
sorted
(
members
,
key
=
lambda
x
:
x
[
'partner_id'
][
0
])
s
[
'members'
]
=
sorted
(
members
,
key
=
lambda
x
:
x
[
'partner_id'
][
0
])
if
len
(
s
[
'members'
])
>
0
:
if
len
(
s
[
'members'
])
>
0
:
...
@@ -1264,22 +1265,27 @@ class CagetteServices(models.Model):
...
@@ -1264,22 +1265,27 @@ class CagetteServices(models.Model):
for
m
in
s
[
'members'
]:
for
m
in
s
[
'members'
]:
mids
.
append
(
m
[
'partner_id'
][
0
])
mids
.
append
(
m
[
'partner_id'
][
0
])
cond
=
[[
'parent_id'
,
'in'
,
mids
]]
cond
=
[[
'parent_id'
,
'in'
,
mids
]]
fields
=
[
'
parent_id'
,
'nam
e'
]
fields
=
[
'
id'
,
'parent_id'
,
'name'
,
'barcode_bas
e'
]
associated
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
associated
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
if
len
(
associated
)
>
0
:
if
len
(
associated
)
>
0
:
for
m
in
s
[
'members'
]:
for
m
in
s
[
'members'
]:
for
a
in
associated
:
for
a
in
associated
:
if
int
(
a
[
'parent_id'
][
0
])
==
int
(
m
[
'partner_id'
][
0
]):
if
int
(
a
[
'parent_id'
][
0
])
==
int
(
m
[
'partner_id'
][
0
]):
m
[
'partner_name'
]
=
m
[
'partner_id'
][
1
]
m
[
'partner_id'
][
1
]
+=
' en binôme avec '
+
a
[
'name'
]
m
[
'partner_id'
][
1
]
+=
' en binôme avec '
+
a
[
'name'
]
m
[
'associate_name'
]
=
str
(
a
[
'barcode_base'
])
+
' - '
+
a
[
'name'
]
return
services
return
services
@staticmethod
@staticmethod
def
registration_done
(
registration_id
,
overrided_date
=
""
):
def
registration_done
(
registration_id
,
overrided_date
=
""
,
typeAction
=
""
):
"""Equivalent to click present in presence form."""
"""Equivalent to click present in presence form."""
api
=
OdooAPI
()
api
=
OdooAPI
()
f
=
{
'state'
:
'done'
}
f
=
{
'state'
:
'done'
}
if
(
typeAction
!=
"normal"
and
typeAction
!=
""
):
f
[
'associate_registered'
]
=
typeAction
late_mode
=
getattr
(
settings
,
'ENTRANCE_WITH_LATE_MODE'
,
False
)
late_mode
=
getattr
(
settings
,
'ENTRANCE_WITH_LATE_MODE'
,
False
)
if
late_mode
is
True
:
if
late_mode
is
True
:
# services = CagetteServices.get_services_at_time('14:28',0, with_members=False)
# services = CagetteServices.get_services_at_time('14:28',0, with_members=False)
...
@@ -1301,7 +1307,14 @@ class CagetteServices(models.Model):
...
@@ -1301,7 +1307,14 @@ class CagetteServices(models.Model):
return
api
.
update
(
'shift.registration'
,
[
int
(
registration_id
)],
f
)
return
api
.
update
(
'shift.registration'
,
[
int
(
registration_id
)],
f
)
@staticmethod
@staticmethod
def
record_rattrapage
(
mid
,
sid
,
stid
):
def
reopen_registration
(
registration_id
,
overrided_date
=
""
):
api
=
OdooAPI
()
f
=
{
'state'
:
'open'
}
return
api
.
update
(
'shift.registration'
,
[
int
(
registration_id
)],
f
)
@staticmethod
def
record_rattrapage
(
mid
,
sid
,
stid
,
typeAction
):
"""Add a shift registration for member mid.
"""Add a shift registration for member mid.
(shift sid, shift ticket stid)
(shift sid, shift ticket stid)
...
@@ -1317,6 +1330,8 @@ class CagetteServices(models.Model):
...
@@ -1317,6 +1330,8 @@ class CagetteServices(models.Model):
"state"
:
'open'
}
"state"
:
'open'
}
reg_id
=
api
.
create
(
'shift.registration'
,
fields
)
reg_id
=
api
.
create
(
'shift.registration'
,
fields
)
f
=
{
'state'
:
'done'
}
f
=
{
'state'
:
'done'
}
if
(
typeAction
!=
"normal"
and
typeAction
!=
""
):
f
[
'associate_registered'
]
=
typeAction
return
api
.
update
(
'shift.registration'
,
[
int
(
reg_id
)],
f
)
return
api
.
update
(
'shift.registration'
,
[
int
(
reg_id
)],
f
)
@staticmethod
@staticmethod
...
@@ -1332,6 +1347,20 @@ class CagetteServices(models.Model):
...
@@ -1332,6 +1347,20 @@ class CagetteServices(models.Model):
# let authorized people time to set presence for those who came in late
# let authorized people time to set presence for those who came in late
end_date
=
now
-
datetime
.
timedelta
(
hours
=
2
)
end_date
=
now
-
datetime
.
timedelta
(
hours
=
2
)
api
=
OdooAPI
()
api
=
OdooAPI
()
# Let's start by adding an extra shift to associated member who came together
cond
=
[[
'date_begin'
,
'>='
,
date_24h_before
.
isoformat
()],
[
'date_begin'
,
'<='
,
end_date
.
isoformat
()],
[
'state'
,
'='
,
'done'
],
[
'associate_registered'
,
'='
,
'both'
]]
fields
=
[
'state'
,
'partner_id'
,
'date_begin'
]
res
=
api
.
search_read
(
'shift.registration'
,
cond
,
fields
)
for
r
in
res
:
cond
=
[[
'id'
,
'='
,
r
[
'partner_id'
][
0
]]]
fields
=
[
'id'
,
'extra_shift_done'
]
res
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
f
=
{
'extra_shift_done'
:
res
[
0
][
'extra_shift_done'
]
+
1
}
api
.
update
(
'res.partner'
,
[
r
[
'partner_id'
][
0
]],
f
)
absence_status
=
'excused'
absence_status
=
'excused'
res_c
=
api
.
search_read
(
'ir.config_parameter'
,
res_c
=
api
.
search_read
(
'ir.config_parameter'
,
[[
'key'
,
'='
,
'lacagette_membership.absence_status'
]],
[[
'key'
,
'='
,
'lacagette_membership.absence_status'
]],
...
...
members/static/css/admin/manage_shift_registrations.css
View file @
730e964d
...
@@ -38,6 +38,10 @@
...
@@ -38,6 +38,10 @@
padding-top
:
0.755em
;
padding-top
:
0.755em
;
}
}
.makeup_row
{
background-color
:
#ffc854
!important
;
}
/* Search membres area */
/* Search membres area */
#search_member_area
{
#search_member_area
{
margin-top
:
30px
;
margin-top
:
30px
;
...
...
members/static/css/member.css
View file @
730e964d
...
@@ -44,8 +44,10 @@ h1 .member_name {font-weight: bold;}
...
@@ -44,8 +44,10 @@ h1 .member_name {font-weight: bold;}
.members_list
{
list-style
:
none
;}
.members_list
{
list-style
:
none
;}
.members_list
li
{
display
:
block
;
margin-bottom
:
5px
;}
.members_list
li
{
display
:
block
;
margin-bottom
:
5px
;}
.members_list
li
.btn--inverse
{
background
:
#449d44
;
cursor
:
not-allowed
;
color
:
#FFF
;
}
.members_list
li
.btn--inverse
{
background
:
#449d44
;
color
:
#FFF
;
}
.members_list
li
.btn--inverse.not_connected
{
cursor
:
not-allowed
}
.members_list
li
.btn--inverse.late
{
background-color
:
#de9b00
;
color
:
white
}
.members_list
li
.btn--inverse.late
{
background-color
:
#de9b00
;
color
:
white
}
.members_list
li
.btn--inverse.both
{
background-color
:
#0275d8
;
color
:
white
}
#service_entry_success
{
font-size
:
x-large
;}
#service_entry_success
{
font-size
:
x-large
;}
#service_entry_success
.explanations
{
margin
:
25px
0
;
font-size
:
18px
;}
#service_entry_success
.explanations
{
margin
:
25px
0
;
font-size
:
18px
;}
...
@@ -64,7 +66,7 @@ h1 .member_name {font-weight: bold;}
...
@@ -64,7 +66,7 @@ h1 .member_name {font-weight: bold;}
#service_en_cours
.info
a
{
line-height
:
24px
;
font-size
:
14px
;
margin-top
:
15px
;}
#service_en_cours
.info
a
{
line-height
:
24px
;
font-size
:
14px
;
margin-top
:
15px
;}
.outside_list
a
{
margin-left
:
15px
;}
.outside_list
a
{
margin-left
:
15px
;}
#rattrapage_1
.advice
{
margin-top
:
15px
;}
#rattrapage_1
.advice
{
margin-top
:
15px
;}
.btn.present
{
background
:
#50C878
;}
.btn.present
{
background
:
#50C878
;
color
:
white
!important
;
font-weight
:
bold
;
}
.btn.return
{
background
:
#ff3333
;
color
:
#FFF
!important
;
margin-top
:
25px
;}
.btn.return
{
background
:
#ff3333
;
color
:
#FFF
!important
;
margin-top
:
25px
;}
.msg-big
{
font-size
:
xx-large
;
background
:
#fff
;
padding
:
25px
;
text-align
:
center
;}
.msg-big
{
font-size
:
xx-large
;
background
:
#fff
;
padding
:
25px
;
text-align
:
center
;}
...
...
members/static/js/admin/manage_makeups.js
View file @
730e964d
...
@@ -69,6 +69,19 @@ function display_makeups_members() {
...
@@ -69,6 +69,19 @@ function display_makeups_members() {
title
:
"Nom"
title
:
"Nom"
},
},
{
{
data
:
"shift_type"
,
title
:
"Nb de points"
,
className
:
"dt-body-center"
,
width
:
"10%"
,
render
:
function
(
data
,
type
,
row
)
{
if
(
data
==
'ftop'
)
{
return
row
.
display_ftop_points
}
else
if
(
data
==
'standard'
)
{
return
row
.
display_std_points
}
}
},
{
data
:
"makeups_to_do"
,
data
:
"makeups_to_do"
,
title
:
"Nb rattrapages"
,
title
:
"Nb rattrapages"
,
className
:
"dt-body-center"
,
className
:
"dt-body-center"
,
...
...
members/static/js/admin/manage_shift_registrations.js
View file @
730e964d
...
@@ -88,17 +88,29 @@ function display_member_shifts() {
...
@@ -88,17 +88,29 @@ function display_member_shifts() {
"sLoadingRecords"
:
"Chargement en cours..."
,
"sLoadingRecords"
:
"Chargement en cours..."
,
"sZeroRecords"
:
"Aucun élément à afficher"
,
"sZeroRecords"
:
"Aucun élément à afficher"
,
"sEmptyTable"
:
"Aucun futur service pour ce.tte membre"
"sEmptyTable"
:
"Aucun futur service pour ce.tte membre"
},
createdRow
:
function
(
row
,
rdata
)
{
if
(
rdata
.
is_makeup
===
true
)
{
$
(
row
).
addClass
(
"makeup_row"
);
$
(
row
).
prop
(
'title'
,
'Ce service est un rattrapage'
);
}
}
},
});
});
$
(
'#member_shifts_table'
).
on
(
'click'
,
'tbody td .delete_shift_registration'
,
function
()
{
$
(
'#member_shifts_table'
).
on
(
'click'
,
'tbody td .delete_shift_registration'
,
function
()
{
const
row_data
=
member_shifts_table
.
row
(
$
(
this
).
parents
(
'tr'
)).
data
();
const
row_data
=
member_shifts_table
.
row
(
$
(
this
).
parents
(
'tr'
)).
data
();
const
shift_reg_id
=
row_data
.
id
;
const
shift_reg_id
=
row_data
.
id
;
const
shift_is_makeup
=
row_data
.
is_makeup
;
let
msg
=
`<p>Enlever la présence de <b>
${
member
.
name
}
</b> au service du <b>
${
row_data
.
shift_id
[
1
]}
</b> ?</p>`
;
if
(
shift_is_makeup
===
true
)
{
msg
+=
`<p><i class="fas fa-exclamation-triangle"></i> Ce service est un rattrapage. Le supprimer ajoutera un point au compteur de ce.tte membre.</p>`
;
}
openModal
(
openModal
(
`Enlever la présence de
${
member
.
name
}
au service du
${
row_data
.
shift_id
[
1
]}
?`
,
msg
,
()
=>
{
()
=>
{
delete_shift_registration
(
shift_reg_id
);
delete_shift_registration
(
shift_reg_id
,
shift_is_makeup
);
},
},
"Confirmer"
,
"Confirmer"
,
false
false
...
@@ -109,13 +121,16 @@ function display_member_shifts() {
...
@@ -109,13 +121,16 @@ function display_member_shifts() {
/**
/**
* Send request to delete shift registration
* Send request to delete shift registration
* @param {Int} shift_reg_id Id of the shift_registration to delete
* @param {Int} shift_reg_id Id of the shift_registration to delete
* @param {Boolean} shift_is_makeup Is the shift a makeup?
*/
*/
function
delete_shift_registration
(
shift_reg_id
)
{
function
delete_shift_registration
(
shift_reg_id
,
shift_is_makeup
)
{
openModal
();
openModal
();
data
=
{
data
=
{
member_id
:
selected_member
.
id
,
member_id
:
selected_member
.
id
,
shift_registration_id
:
shift_reg_id
member_shift_type
:
selected_member
.
shift_type
,
shift_registration_id
:
shift_reg_id
,
shift_is_makeup
:
shift_is_makeup
};
};
$
.
ajax
({
$
.
ajax
({
...
...
members/static/js/inscriptions.js
View file @
730e964d
...
@@ -588,8 +588,7 @@ $('#add_binome').click(function() {
...
@@ -588,8 +588,7 @@ $('#add_binome').click(function() {
delete
current_coop
.
is_associated_people
;
delete
current_coop
.
is_associated_people
;
delete
current_coop
.
shift_template
;
delete
current_coop
.
shift_template
;
}
}
}
}
else
{
else
{
$
(
'#associate_area'
).
show
();
$
(
'#associate_area'
).
show
();
$
(
'.member_choice'
).
removeClass
(
'choice_active'
);
$
(
'.member_choice'
).
removeClass
(
'choice_active'
);
$
(
'#existing_member_choice_action'
).
hide
();
$
(
'#existing_member_choice_action'
).
hide
();
...
@@ -614,6 +613,12 @@ $('.member_choice').on('click', function() {
...
@@ -614,6 +613,12 @@ $('.member_choice').on('click', function() {
});
});
$
(
'#shift_calendar'
).
click
(
show_shift_calendar
);
$
(
'#shift_calendar'
).
click
(
show_shift_calendar
);
$
(
'#search_member_input'
).
keypress
((
event
)
=>
{
if
(
event
.
keyCode
==
13
)
{
event
.
preventDefault
();
searchMembersForAssociate
();
}
});
//get_latest_odoo_coop_bb();
//get_latest_odoo_coop_bb();
update_self_records
();
update_self_records
();
...
@@ -688,10 +693,10 @@ function display_possible_members() {
...
@@ -688,10 +693,10 @@ function display_possible_members() {
}
}
$
(
document
).
ready
(
function
()
{
/**
retrieve_and_draw_shift_tempates
();
* Search for members to associate a new member with an old one.
// Set action to search for the member
*/
$
(
'#search_member_button'
).
on
(
'click'
,
function
()
{
function
searchMembersForAssociate
()
{
let
search_str
=
$
(
'#search_member_input'
).
val
();
let
search_str
=
$
(
'#search_member_input'
).
val
();
if
(
search_str
)
{
if
(
search_str
)
{
...
@@ -722,11 +727,18 @@ $(document).ready(function() {
...
@@ -722,11 +727,18 @@ $(document).ready(function() {
});
});
}
}
});
});
}
}
else
{
else
{
members_search_results
=
[];
members_search_results
=
[];
display_possible_members
();
display_possible_members
();
}
}
}
$
(
document
).
ready
(
function
()
{
retrieve_and_draw_shift_tempates
();
// Set action to search for the member
$
(
'#search_member_button'
).
on
(
'click'
,
function
()
{
searchMembersForAssociate
();
});
});
});
});
members/static/js/members.js
View file @
730e964d
...
@@ -31,12 +31,14 @@ var search_field = $('input[name="search_string"]');
...
@@ -31,12 +31,14 @@ var search_field = $('input[name="search_string"]');
var
shift_title
=
$
(
'#current_shift_title'
);
var
shift_title
=
$
(
'#current_shift_title'
);
var
shift_members
=
$
(
'#current_shift_members'
);
var
shift_members
=
$
(
'#current_shift_members'
);
var
service_validation
=
$
(
'#service_validation'
);
var
service_validation
=
$
(
'#service_validation'
);
var
associated_service_validation
=
$
(
'#associated_service_validation'
);
var
validation_last_call
=
0
;
var
validation_last_call
=
0
;
var
rattrapage_wanted
=
$
(
'[data-next="rattrapage_1"]'
);
var
rattrapage_wanted
=
$
(
'[data-next="rattrapage_1"]'
);
var
webcam_is_attached
=
false
;
var
webcam_is_attached
=
false
;
var
photo_advice
=
$
(
'#photo_advice'
);
var
photo_advice
=
$
(
'#photo_advice'
);
var
photo_studio
=
$
(
'#photo_studio'
);
var
photo_studio
=
$
(
'#photo_studio'
);
var
coop_info
=
$
(
'.coop-info'
);
var
coop_info
=
$
(
'.coop-info'
);
var
service_data
=
null
;
const
missed_begin_msg
=
$
(
'#missed_begin_msg'
).
html
();
const
missed_begin_msg
=
$
(
'#missed_begin_msg'
).
html
();
...
@@ -264,7 +266,7 @@ function get_simple_service_name(s) {
...
@@ -264,7 +266,7 @@ function get_simple_service_name(s) {
}
}
function
move_service_validation_to
(
page
)
{
function
move_service_validation_to
(
page
)
{
service_
validation
.
find
(
'.btn'
).
data
(
'stid'
,
'0'
)
;
service_
data
.
stid
=
0
;
page
.
find
(
'.validation_wrapper'
)
page
.
find
(
'.validation_wrapper'
)
.
append
(
service_validation
.
detach
());
.
append
(
service_validation
.
detach
());
}
}
...
@@ -284,11 +286,21 @@ function fill_service_entry(s) {
...
@@ -284,11 +286,21 @@ function fill_service_entry(s) {
var
li_class
=
"btn"
;
var
li_class
=
"btn"
;
var
li_data
=
""
;
var
li_data
=
""
;
if
(
e
.
state
==
"done"
)
{
if
(
e
.
state
==
"done"
&&
coop_is_connected
())
{
li_data
=
' data-rid="'
+
e
.
id
+
'" data-mid="'
+
e
.
partner_id
[
0
]
+
'"'
;
li_class
+=
"--inverse"
;
li_class
+=
"--inverse"
;
if
(
e
.
is_late
==
true
)
{
if
(
e
.
is_late
==
true
)
{
li_class
+=
" late"
;
li_class
+=
" late"
;
}
}
if
(
e
.
associate_registered
==
'both'
)
{
li_class
+=
" both"
;
}
}
else
if
(
e
.
state
==
"done"
&&
!
coop_is_connected
())
{
li_data
=
' data-rid="'
+
e
.
id
+
'" data-mid="'
+
e
.
partner_id
[
0
]
+
'"'
;
li_class
+=
"--inverse not_connected"
;
if
(
e
.
is_late
==
true
)
{
li_class
+=
" late"
;
}
}
else
{
}
else
{
li_data
=
' data-rid="'
+
e
.
id
+
'" data-mid="'
+
e
.
partner_id
[
0
]
+
'"'
;
li_data
=
' data-rid="'
+
e
.
id
+
'" data-mid="'
+
e
.
partner_id
[
0
]
+
'"'
;
}
}
...
@@ -321,13 +333,29 @@ function clean_service_entry() {
...
@@ -321,13 +333,29 @@ function clean_service_entry() {
function
fill_service_validation
(
rid
,
coop_num_name
,
coop_id
)
{
function
fill_service_validation
(
rid
,
coop_num_name
,
coop_id
)
{
var
coop_name_elts
=
coop_num_name
.
split
(
' - '
);
var
coop_name_elts
=
coop_num_name
.
split
(
' - '
);
for
(
member
of
loaded_services
[
0
].
members
)
{
if
(
member
.
id
==
rid
)
{
if
(
member
.
associate_name
)
{
pages
.
service_entry_validation
.
find
(
'#service_validation'
).
hide
();
pages
.
service_entry_validation
.
find
(
'#associated_service_validation'
).
show
();
pages
.
service_entry_validation
.
find
(
'#associated_btn'
).
text
(
member
.
associate_name
);
pages
.
service_entry_validation
.
find
(
'#partner_btn'
).
text
(
member
.
partner_name
);
}
else
{
pages
.
service_entry_validation
.
find
(
'#associated_service_validation'
).
hide
();
pages
.
service_entry_validation
.
find
(
'#service_validation'
).
show
();
}
}
}
service_data
=
{
rid
:
rid
,
sid
:
selected_service
.
id
,
mid
:
coop_id
};
pages
.
service_entry_validation
.
find
(
'span.member_name'
).
text
(
coop_name_elts
[
1
]);
pages
.
service_entry_validation
.
find
(
'span.member_name'
).
text
(
coop_name_elts
[
1
]);
move_service_validation_to
(
pages
.
service_entry_validation
);
move_service_validation_to
(
pages
.
service_entry_validation
);
service_validation
.
find
(
'.btn'
)
.
data
(
'rid'
,
rid
)
.
data
(
'sid'
,
selected_service
.
id
)
.
data
(
'mid'
,
coop_id
);
}
}
function
select_possible_service
()
{
function
select_possible_service
()
{
...
@@ -372,7 +400,6 @@ function get_service_entry_data() {
...
@@ -372,7 +400,6 @@ function get_service_entry_data() {
dataType
:
'json'
dataType
:
'json'
})
})
.
done
(
function
(
rData
)
{
.
done
(
function
(
rData
)
{
//console.log(rData);
info_place
.
text
(
''
);
info_place
.
text
(
''
);
var
page_title
=
pages
.
service_entry
.
find
(
'h1'
);
var
page_title
=
pages
.
service_entry
.
find
(
'h1'
);
...
@@ -397,6 +424,7 @@ function get_service_entry_data() {
...
@@ -397,6 +424,7 @@ function get_service_entry_data() {
page_title
.
text
(
'Quel est ton service ?'
);
page_title
.
text
(
'Quel est ton service ?'
);
}
else
{
}
else
{
loaded_services
=
rData
.
res
;
fill_service_entry
(
rData
.
res
[
0
]);
fill_service_entry
(
rData
.
res
[
0
]);
}
}
}
}
...
@@ -443,22 +471,21 @@ function fill_service_entry_sucess(member) {
...
@@ -443,22 +471,21 @@ function fill_service_entry_sucess(member) {
}
}
function
record_service_presence
()
{
function
record_service_presence
(
e
)
{
var
d
=
new
Date
();
var
d
=
new
Date
();
var
elapsed_since_last_call
=
d
.
getTime
()
-
validation_last_call
;
var
elapsed_since_last_call
=
d
.
getTime
()
-
validation_last_call
;
if
(
elapsed_since_last_call
>
1000
0
)
{
if
(
elapsed_since_last_call
>
1000
)
{
loading2
.
show
();
loading2
.
show
();
validation_last_call
=
d
.
getTime
();
validation_last_call
=
d
.
getTime
();
var
clicked
=
service_validation
.
find
(
'.btn'
);
var
rid
=
service_data
.
rid
;
var
rid
=
clicked
.
data
(
'rid'
);
var
mid
=
service_data
.
mid
;
var
mid
=
clicked
.
data
(
'mid'
);
var
sid
=
service_data
.
sid
;
var
sid
=
clicked
.
data
(
'sid'
);
var
stid
=
service_data
.
stid
;
var
stid
=
clicked
.
data
(
'stid'
);
post_form
(
post_form
(
'/members/service_presence/'
,
'/members/service_presence/'
,
{
'mid'
:
mid
,
'rid'
:
rid
,
'sid'
:
sid
,
'stid'
:
stid
},
{
'mid'
:
mid
,
'rid'
:
rid
,
'sid'
:
sid
,
'stid'
:
stid
,
'cancel'
:
false
,
'type'
:
e
.
data
.
type
},
function
(
err
,
rData
)
{
function
(
err
,
rData
)
{
if
(
!
err
)
{
if
(
!
err
)
{
var
res
=
rData
.
res
;
var
res
=
rData
.
res
;
...
@@ -480,6 +507,28 @@ function record_service_presence() {
...
@@ -480,6 +507,28 @@ function record_service_presence() {
}
}
}
}
function
cancel_service_presence
(
mid
,
rid
)
{
var
d
=
new
Date
();
var
elapsed_since_last_call
=
d
.
getTime
()
-
validation_last_call
;
if
(
elapsed_since_last_call
>
1000
)
{
loading2
.
show
();
validation_last_call
=
d
.
getTime
();
var
sid
=
selected_service
.
id
;
post_form
(
'/members/service_presence/'
,
{
'mid'
:
mid
,
'rid'
:
rid
,
'sid'
:
sid
,
'stid'
:
0
,
'cancel'
:
true
},
function
(
err
)
{
if
(
!
err
)
{
get_service_entry_data
();
}
loading2
.
hide
();
}
);
}
}
function
fill_rattrapage_2
()
{
function
fill_rattrapage_2
()
{
pages
.
rattrapage_2
.
find
(
'span.member_name'
).
text
(
current_displayed_member
.
name
);
pages
.
rattrapage_2
.
find
(
'span.member_name'
).
text
(
current_displayed_member
.
name
);
var
msg
=
"Bienvenue pour ton rattrapage !"
;
var
msg
=
"Bienvenue pour ton rattrapage !"
;
...
@@ -494,13 +543,11 @@ function fill_rattrapage_2() {
...
@@ -494,13 +543,11 @@ function fill_rattrapage_2() {
msg
=
"Tu es en désincrit.e ... La situation doit être réglée avez le Bureau des Membres"
;
msg
=
"Tu es en désincrit.e ... La situation doit être réglée avez le Bureau des Membres"
;
}
else
{
}
else
{
move_service_validation_to
(
pages
.
rattrapage_2
);
move_service_validation_to
(
pages
.
rattrapage_2
);
service_data
=
{
rid
:
0
,
service_validation
.
find
(
'.btn'
)
sid
:
selected_service
.
id
,
.
data
(
'rid'
,
0
)
stid
:
shift_ticket_id
,
.
data
(
'sid'
,
selected_service
.
id
)
mid
:
current_displayed_member
.
id
};
.
data
(
'stid'
,
shift_ticket_id
)
.
data
(
'mid'
,
current_displayed_member
.
id
);
}
}
pages
.
rattrapage_2
.
find
(
'h2'
).
text
(
msg
);
pages
.
rattrapage_2
.
find
(
'h2'
).
text
(
msg
);
...
@@ -641,7 +688,10 @@ $('.btn[data-next]').click(function() {
...
@@ -641,7 +688,10 @@ $('.btn[data-next]').click(function() {
});
});
service_validation
.
on
(
"click"
,
".btn"
,
record_service_presence
);
service_validation
.
on
(
"click"
,
".btn"
,
{
type
:
'normal'
},
record_service_presence
);
associated_service_validation
.
on
(
"click"
,
"#associated_btn"
,
{
type
:
'associate'
},
record_service_presence
);
associated_service_validation
.
on
(
"click"
,
"#partner_btn"
,
{
type
:
'partner'
},
record_service_presence
);
associated_service_validation
.
on
(
"click"
,
"#both_btn"
,
{
type
:
'both'
},
record_service_presence
);
shift_members
.
on
(
"click"
,
'.btn[data-rid]'
,
function
()
{
shift_members
.
on
(
"click"
,
'.btn[data-rid]'
,
function
()
{
var
clicked
=
$
(
this
);
var
clicked
=
$
(
this
);
...
@@ -653,6 +703,16 @@ shift_members.on("click", '.btn[data-rid]', function() {
...
@@ -653,6 +703,16 @@ shift_members.on("click", '.btn[data-rid]', function() {
});
});
shift_members
.
on
(
"click"
,
'.btn--inverse'
,
function
()
{
if
(
coop_is_connected
())
{
var
clicked
=
$
(
this
);
var
rid
=
clicked
.
data
(
'rid'
);
var
mid
=
clicked
.
data
(
'mid'
);
cancel_service_presence
(
mid
,
rid
);
}
});
pages
.
shopping_entry
.
on
(
'css'
,
function
()
{
pages
.
shopping_entry
.
on
(
'css'
,
function
()
{
photo_advice
.
hide
();
photo_advice
.
hide
();
photo_studio
.
hide
();
photo_studio
.
hide
();
...
...
members/views.py
View file @
730e964d
...
@@ -283,6 +283,9 @@ def record_service_presence(request):
...
@@ -283,6 +283,9 @@ def record_service_presence(request):
mid
=
int
(
request
.
POST
.
get
(
"mid"
,
0
))
# member id
mid
=
int
(
request
.
POST
.
get
(
"mid"
,
0
))
# member id
sid
=
int
(
request
.
POST
.
get
(
"sid"
,
0
))
# shift id
sid
=
int
(
request
.
POST
.
get
(
"sid"
,
0
))
# shift id
stid
=
int
(
request
.
POST
.
get
(
"stid"
,
0
))
# shift_ticket_id
stid
=
int
(
request
.
POST
.
get
(
"stid"
,
0
))
# shift_ticket_id
cancel
=
request
.
POST
.
get
(
"cancel"
)
==
'true'
typeAction
=
str
(
request
.
POST
.
get
(
"type"
))
app_env
=
getattr
(
settings
,
'APP_ENV'
,
"prod"
)
app_env
=
getattr
(
settings
,
'APP_ENV'
,
"prod"
)
if
(
rid
>
-
1
and
mid
>
0
):
if
(
rid
>
-
1
and
mid
>
0
):
overrided_date
=
""
overrided_date
=
""
...
@@ -292,14 +295,15 @@ def record_service_presence(request):
...
@@ -292,14 +295,15 @@ def record_service_presence(request):
if
o_date
:
if
o_date
:
overrided_date
=
re
.
sub
(
r'(
%20
)'
,
' '
,
o_date
.
group
(
1
))
overrided_date
=
re
.
sub
(
r'(
%20
)'
,
' '
,
o_date
.
group
(
1
))
if
(
not
cancel
):
# rid = 0 => C'est un rattrapage, sur le service
# rid = 0 => C'est un rattrapage, sur le service
if
sid
>
0
and
stid
>
0
:
if
sid
>
0
and
stid
>
0
:
# Add member to service and take presence into account
# Add member to service and take presence into account
res
[
'rattrapage'
]
=
CagetteServices
.
record_rattrapage
(
mid
,
sid
,
stid
)
res
[
'rattrapage'
]
=
CagetteServices
.
record_rattrapage
(
mid
,
sid
,
stid
,
typeAction
)
if
res
[
'rattrapage'
]
is
True
:
if
res
[
'rattrapage'
]
is
True
:
res
[
'update'
]
=
'ok'
res
[
'update'
]
=
'ok'
else
:
else
:
if
(
CagetteServices
.
registration_done
(
rid
,
overrided_date
)
is
True
):
if
(
CagetteServices
.
registration_done
(
rid
,
overrided_date
,
typeAction
)
is
True
):
res
[
'update'
]
=
'ok'
res
[
'update'
]
=
'ok'
else
:
else
:
res
[
'update'
]
=
'ko'
res
[
'update'
]
=
'ko'
...
@@ -314,6 +318,8 @@ def record_service_presence(request):
...
@@ -314,6 +318,8 @@ def record_service_presence(request):
del
m
[
'shifts'
]
del
m
[
'shifts'
]
m
[
'next_shift'
]
=
next_shift
m
[
'next_shift'
]
=
next_shift
res
[
'member'
]
=
m
res
[
'member'
]
=
m
else
:
CagetteServices
.
reopen_registration
(
rid
,
overrided_date
)
except
Exception
as
e
:
except
Exception
as
e
:
res
[
'error'
]
=
str
(
e
)
res
[
'error'
]
=
str
(
e
)
return
JsonResponse
({
'res'
:
res
})
return
JsonResponse
({
'res'
:
res
})
...
...
members_space/static/css/members-space-shifts-exchange.css
View file @
730e964d
...
@@ -64,14 +64,39 @@
...
@@ -64,14 +64,39 @@
}
}
}
}
.shift_line_container
{
display
:
flex
;
flex-direction
:
row
;
align-items
:
center
;
flex-wrap
:
wrap
;
}
.shift_line_extra_actions
{
display
:
flex
;
justify-content
:
flex-start
;
flex-wrap
:
nowrap
;
}
@media
screen
and
(
max-width
:
768px
)
{
.shift_line_container
{
flex-direction
:
column
;
}
.shift_line_extra_actions
{
width
:
100%
;
}
.affect_associate_registered
{
margin
:
0.5rem
0
;
}
}
.selectable_shift_line
{
.selectable_shift_line
{
min-width
:
325px
;
min-width
:
325px
;
display
:
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
margin-left
:
15px
;
margin
:
0.75rem
0
;
border-radius
:
5px
;
border-radius
:
5px
;
margin-right
:
15px
;
}
}
.selectable_shift_line
.checkbox
{
.selectable_shift_line
.checkbox
{
...
@@ -85,11 +110,23 @@
...
@@ -85,11 +110,23 @@
.affect_associate_registered
{
.affect_associate_registered
{
display
:
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
margin-left
:
15px
;
margin
:
0.75rem
0
;
border-radius
:
5px
;
border-radius
:
5px
;
}
}
@media
screen
and
(
min-width
:
768px
)
{
.selectable_shift_line
{
margin
:
0
15px
;
}
.affect_associate_registered
{
margin-left
:
15px
;
}
}
.selectable_shift
{
margin
:
1rem
0
;
}
.delete_registration_button
{
.delete_registration_button
{
justify-content
:
center
;
justify-content
:
center
;
align-items
:
center
;
align-items
:
center
;
...
@@ -125,9 +162,9 @@
...
@@ -125,9 +162,9 @@
#can_delete_future_registrations_area
{
#can_delete_future_registrations_area
{
display
:
none
;
display
:
none
;
align-self
:
center
;
justify-content
:
center
;
align-items
:
center
;
margin
:
0
1rem
1rem
1rem
;
margin
:
0
1rem
1rem
1rem
;
padding
:
1rem
1.25rem
;
}
}
#can_delete_future_registrations_area
button
{
#can_delete_future_registrations_area
button
{
...
@@ -241,3 +278,13 @@ td{
...
@@ -241,3 +278,13 @@ td{
max-width
:
60%
;
max-width
:
60%
;
margin
:
2rem
auto
0.5rem
auto
;
margin
:
2rem
auto
0.5rem
auto
;
}
}
/* -- Assign shift modal */
.modal_affect_shift_buttons
{
margin
:
1rem
0
;
}
.assign_shift_button
{
margin
:
0.25rem
;
}
\ No newline at end of file
members_space/static/js/members-space-home.js
View file @
730e964d
/**
* Request a 6 month delay
*/
function
request_delay
()
{
return
new
Promise
((
resolve
)
=>
{
let
today
=
new
Date
();
const
delay_start
=
today
.
getFullYear
()
+
'-'
+
(
today
.
getMonth
()
+
1
)
+
'-'
+
today
.
getDate
();
let
today_plus_six_month
=
new
Date
();
today_plus_six_month
.
setMonth
(
today_plus_six_month
.
getMonth
()
+
6
);
const
diff_time
=
Math
.
abs
(
today_plus_six_month
-
today
);
const
diff_days
=
Math
.
ceil
(
diff_time
/
(
1000
*
60
*
60
*
24
));
$
.
ajax
({
type
:
'POST'
,
url
:
"/shifts/request_delay"
,
dataType
:
"json"
,
data
:
{
verif_token
:
partner_data
.
verif_token
,
idPartner
:
partner_data
.
partner_id
,
start_date
:
delay_start
,
duration
:
diff_days
},
success
:
function
()
{
partner_data
.
cooperative_state
=
'delay'
;
partner_data
.
date_delay_stop
=
today_plus_six_month
.
getFullYear
()
+
'-'
+
(
today_plus_six_month
.
getMonth
()
+
1
)
+
'-'
+
today_plus_six_month
.
getDate
();
resolve
();
},
error
:
function
(
data
)
{
if
(
data
.
status
==
403
&&
typeof
data
.
responseJSON
!=
'undefined'
&&
data
.
responseJSON
.
message
===
"delays limit reached"
)
{
closeModal
();
let
msg_template
=
$
(
"#cant_have_delay_msg_template"
);
openModal
(
msg_template
.
html
(),
()
=>
{
window
.
location
=
member_cant_have_delay_form_link
;
},
"J'accède au formulaire"
,
true
,
false
);
}
else
{
err
=
{
msg
:
"erreur serveur lors de la création du délai"
,
ctx
:
'request_delay'
};
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
}
report_JS_error
(
err
,
'members_space.home'
);
closeModal
();
alert
(
'Erreur lors de la création du délai.'
);
}
}
});
});
}
function
init_my_shifts_tile
()
{
function
init_my_shifts_tile
()
{
if
(
incoming_shifts
.
length
===
0
)
{
if
(
incoming_shifts
.
length
===
0
)
{
$
(
"#home_tile_my_services #home_incoming_services"
).
text
(
"Aucun service à venir..."
);
$
(
"#home_tile_my_services #home_incoming_services"
).
text
(
"Aucun service à venir..."
);
...
...
members_space/static/js/members-space-shifts-exchange.js
View file @
730e964d
...
@@ -217,7 +217,7 @@ function delete_shift_registration(shift_registration_id) {
...
@@ -217,7 +217,7 @@ function delete_shift_registration(shift_registration_id) {
* @param {string} shift_id
* @param {string} shift_id
*/
*/
function
affect_shift
(
partner
,
shift_id
)
{
function
affect_shift
(
partner
,
shift_id
)
{
if
(
is_time_to
(
'affect_shift'
))
{
if
(
is_time_to
(
'affect_shift'
,
1000
))
{
tData
=
'idShiftRegistration='
+
shift_id
tData
=
'idShiftRegistration='
+
shift_id
+
'&idPartner='
+
partner_data
.
partner_id
+
'&idPartner='
+
partner_data
.
partner_id
+
'&affected_partner='
+
partner
+
'&affected_partner='
+
partner
...
@@ -309,7 +309,8 @@ function init_shifts_list() {
...
@@ -309,7 +309,8 @@ function init_shifts_list() {
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"
).
removeClass
(
"btn"
);
shift_line_template
.
find
(
".selectable_shift_line"
).
removeClass
(
"btn"
);
shift_line_template
.
find
(
".selectable_shift_line"
).
removeClass
(
"btn--warning"
);
shift_line_template
.
find
(
".selectable_shift_line"
).
removeClass
(
"btn--warning"
);
if
(
!
can_exchange_shifts
()
&&
block_actions_for_attached_people
===
"True"
)
{
if
(
!
can_exchange_shifts
())
{
shift_line_template
.
find
(
".selectable_shift_line"
).
addClass
(
"btn"
);
shift_line_template
.
find
(
".selectable_shift_line"
).
addClass
(
"btn"
);
shift_line_template
.
find
(
".checkbox"
).
prop
(
"disabled"
,
"disabled"
);
shift_line_template
.
find
(
".checkbox"
).
prop
(
"disabled"
,
"disabled"
);
}
else
{
}
else
{
...
@@ -327,11 +328,19 @@ function init_shifts_list() {
...
@@ -327,11 +328,19 @@ function init_shifts_list() {
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
{
if
(
!
can_exchange_shifts
())
{
shift_line_template
.
find
(
'.affect_associate_registered'
).
hide
();
}
else
{
shift_line_template
.
find
(
'.affect_associate_registered'
).
show
();
}
shift_line_template
.
find
(
'.affect_associate_registered'
).
closest
(
".shift_line_container"
)
shift_line_template
.
find
(
'.affect_associate_registered'
).
closest
(
".shift_line_container"
)
.
attr
(
'id'
,
'shift_id_'
+
shift
.
id
);
.
attr
(
'id'
,
'shift_id_'
+
shift
.
id
);
if
(
shift
.
associate_registered
===
"both"
)
{
if
(
shift
.
associate_registered
===
"both"
)
{
shift_line_template
.
find
(
'.affect_associate_registered'
).
text
(
"Les deux"
);
shift_line_template
.
find
(
'.affect_associate_registered'
).
text
(
"Les deux"
);
shift_line_template
.
find
(
'.affect_associate_registered'
).
addClass
(
'btn--success'
);
}
else
if
(
shift
.
associate_registered
===
"partner"
)
{
}
else
if
(
shift
.
associate_registered
===
"partner"
)
{
shift_line_template
.
find
(
'.affect_associate_registered'
).
addClass
(
'btn--success'
);
if
(
partner_data
.
associated_partner_id
!==
"False"
)
{
if
(
partner_data
.
associated_partner_id
!==
"False"
)
{
shift_line_template
.
find
(
'.affect_associate_registered'
).
text
(
partner_data
.
name
);
shift_line_template
.
find
(
'.affect_associate_registered'
).
text
(
partner_data
.
name
);
}
else
{
}
else
{
...
@@ -339,6 +348,7 @@ function init_shifts_list() {
...
@@ -339,6 +348,7 @@ function init_shifts_list() {
}
}
}
else
if
(
shift
.
associate_registered
===
"associate"
)
{
}
else
if
(
shift
.
associate_registered
===
"associate"
)
{
shift_line_template
.
find
(
'.affect_associate_registered'
).
addClass
(
'btn--success'
);
if
(
partner_data
.
associated_partner_id
!==
"False"
)
{
if
(
partner_data
.
associated_partner_id
!==
"False"
)
{
shift_line_template
.
find
(
'.affect_associate_registered'
).
text
(
partner_data
.
associated_partner_name
);
shift_line_template
.
find
(
'.affect_associate_registered'
).
text
(
partner_data
.
associated_partner_name
);
}
else
{
}
else
{
...
@@ -346,6 +356,7 @@ function init_shifts_list() {
...
@@ -346,6 +356,7 @@ function init_shifts_list() {
}
}
}
else
{
}
else
{
shift_line_template
.
find
(
'.affect_associate_registered'
).
text
(
"A déterminer"
);
shift_line_template
.
find
(
'.affect_associate_registered'
).
text
(
"A déterminer"
);
shift_line_template
.
find
(
'.affect_associate_registered'
).
addClass
(
'btn--danger'
);
}
}
}
}
...
@@ -354,13 +365,15 @@ function init_shifts_list() {
...
@@ -354,13 +365,15 @@ function init_shifts_list() {
if
(
shift_line_template
.
find
(
".delete_registration_button"
).
length
===
0
)
{
if
(
shift_line_template
.
find
(
".delete_registration_button"
).
length
===
0
)
{
let
delete_reg_button_template
=
$
(
"#delete_registration_button_template"
);
let
delete_reg_button_template
=
$
(
"#delete_registration_button_template"
);
shift_line_template
.
find
(
".shift_line_
container
"
).
append
(
delete_reg_button_template
.
html
());
shift_line_template
.
find
(
".shift_line_
extra_actions
"
).
append
(
delete_reg_button_template
.
html
());
}
}
}
else
{
}
else
{
shift_line_template
.
find
(
".delete_registration_button"
).
remove
();
shift_line_template
.
find
(
".delete_registration_button"
).
remove
();
}
}
$
(
"#shifts_list"
).
append
(
shift_line_template
.
html
());
$
(
"#shifts_list"
).
append
(
shift_line_template
.
html
());
shift_line_template
.
find
(
'.affect_associate_registered'
).
removeClass
(
'btn--danger'
);
shift_line_template
.
find
(
'.affect_associate_registered'
).
removeClass
(
'btn--success'
);
}
}
$
(
".selectable_shift_line"
).
on
(
"click"
,
function
(
e
)
{
$
(
".selectable_shift_line"
).
on
(
"click"
,
function
(
e
)
{
...
@@ -402,8 +415,8 @@ function init_shifts_list() {
...
@@ -402,8 +415,8 @@ function init_shifts_list() {
modal_template
.
find
(
"#shift_associate"
).
text
(
partner_data
.
associated_partner_name
);
modal_template
.
find
(
"#shift_associate"
).
text
(
partner_data
.
associated_partner_name
);
}
else
{
}
else
{
modal_template
.
find
(
"#shift_partner"
).
text
(
partner_data
.
name
);
modal_template
.
find
(
"#shift_partner"
).
text
(
partner_data
.
parent_
name
);
modal_template
.
find
(
"#shift_associate"
).
text
(
partner_data
.
parent_
name
);
modal_template
.
find
(
"#shift_associate"
).
text
(
partner_data
.
name
);
}
}
openModal
(
openModal
(
...
@@ -470,7 +483,7 @@ function init_calendar_page() {
...
@@ -470,7 +483,7 @@ function init_calendar_page() {
if
(
partner_data
.
extra_shift_done
>
0
)
{
if
(
partner_data
.
extra_shift_done
>
0
)
{
$
(
".extra_shift_done"
).
text
(
partner_data
.
extra_shift_done
);
$
(
".extra_shift_done"
).
text
(
partner_data
.
extra_shift_done
);
$
(
"#can_delete_future_registrations_area"
).
show
(
);
$
(
"#can_delete_future_registrations_area"
).
css
(
'display'
,
'flex'
);
$
(
"#offer_extra_shift"
).
on
(
"click"
,
()
=>
{
$
(
"#offer_extra_shift"
).
on
(
"click"
,
()
=>
{
openModal
(
openModal
(
...
@@ -763,8 +776,7 @@ function init_shifts_exchange() {
...
@@ -763,8 +776,7 @@ function init_shifts_exchange() {
$
(
this
).
removeClass
(
'active'
);
$
(
this
).
removeClass
(
'active'
);
});
});
});
});
}
else
if
(
}
else
if
(
partner_data
.
comite
===
"True"
)
{
partner_data
.
comite
===
"True"
)
{
let
msg_template
=
$
(
"#comite_template"
);
let
msg_template
=
$
(
"#comite_template"
);
$
(
".comite_content_msg"
).
html
(
msg_template
.
html
());
$
(
".comite_content_msg"
).
html
(
msg_template
.
html
());
...
...
members_space/static/js/members-space.js
View file @
730e964d
...
@@ -131,6 +131,70 @@ function update_content() {
...
@@ -131,6 +131,70 @@ function update_content() {
/* - Shifts */
/* - Shifts */
/**
/**
* Request a 6 month delay
*/
function
request_delay
()
{
return
new
Promise
((
resolve
)
=>
{
let
today
=
new
Date
();
const
delay_start
=
today
.
getFullYear
()
+
'-'
+
(
today
.
getMonth
()
+
1
)
+
'-'
+
today
.
getDate
();
let
today_plus_six_month
=
new
Date
();
today_plus_six_month
.
setMonth
(
today_plus_six_month
.
getMonth
()
+
6
);
const
diff_time
=
Math
.
abs
(
today_plus_six_month
-
today
);
const
diff_days
=
Math
.
ceil
(
diff_time
/
(
1000
*
60
*
60
*
24
));
$
.
ajax
({
type
:
'POST'
,
url
:
"/shifts/request_delay"
,
dataType
:
"json"
,
data
:
{
verif_token
:
(
partner_data
.
is_associated_people
===
"True"
)
?
partner_data
.
parent_verif_token
:
partner_data
.
verif_token
,
idPartner
:
partner_data
.
concerned_partner_id
,
start_date
:
delay_start
,
duration
:
diff_days
},
success
:
function
()
{
partner_data
.
cooperative_state
=
'delay'
;
partner_data
.
date_delay_stop
=
today_plus_six_month
.
getFullYear
()
+
'-'
+
(
today_plus_six_month
.
getMonth
()
+
1
)
+
'-'
+
today_plus_six_month
.
getDate
();
resolve
();
},
error
:
function
(
data
)
{
if
(
data
.
status
==
403
&&
typeof
data
.
responseJSON
!=
'undefined'
&&
data
.
responseJSON
.
message
===
"delays limit reached"
)
{
closeModal
();
let
msg_template
=
$
(
"#cant_have_delay_msg_template"
);
openModal
(
msg_template
.
html
(),
()
=>
{
window
.
location
=
member_cant_have_delay_form_link
;
},
"J'accède au formulaire"
,
true
,
false
);
}
else
{
err
=
{
msg
:
"erreur serveur lors de la création du délai"
,
ctx
:
'request_delay'
};
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
}
report_JS_error
(
err
,
'members_space.home'
);
closeModal
();
alert
(
'Erreur lors de la création du délai.'
);
}
}
});
});
}
/**
* Prepare a shift line to insert into the DOM.
* Prepare a shift line to insert into the DOM.
* Is used in: Home - My Shifts tile ; My Shifts - Incoming shifts section
* Is used in: Home - My Shifts tile ; My Shifts - Incoming shifts section
*
*
...
@@ -200,7 +264,6 @@ function init_my_info_data() {
...
@@ -200,7 +264,6 @@ function init_my_info_data() {
if
(
if
(
partner_data
.
makeups_to_do
>
0
partner_data
.
makeups_to_do
>
0
&&
partner_data
.
is_associated_people
===
"False"
&&
partner_data
.
cooperative_state
!==
'unsubscribed'
&&
partner_data
.
cooperative_state
!==
'unsubscribed'
)
{
)
{
$
(
".choose_makeups"
).
show
();
$
(
".choose_makeups"
).
show
();
...
@@ -235,8 +298,6 @@ function init_my_info_data() {
...
@@ -235,8 +298,6 @@ function init_my_info_data() {
}
}
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
// TODO essayer de ne charger les js que au besoin
$
.
ajaxSetup
({
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)
}
});
$
.
ajaxSetup
({
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)
}
});
// If partner is associated (attached), display the pair's main partner shift data
// If partner is associated (attached), display the pair's main partner shift data
...
@@ -250,7 +311,6 @@ $(document).ready(function() {
...
@@ -250,7 +311,6 @@ $(document).ready(function() {
// For associated people, their parent name is attached in their display name
// For associated people, their parent name is attached in their display name
let
partner_name_split
=
partner_data
.
name
.
split
(
', '
);
let
partner_name_split
=
partner_data
.
name
.
split
(
', '
);
partner_data
.
name
=
partner_name_split
[
partner_name_split
.
length
-
1
];
partner_data
.
name
=
partner_name_split
[
partner_name_split
.
length
-
1
];
base_location
=
(
app_env
===
'dev'
)
?
'/members_space/'
:
'/'
;
base_location
=
(
app_env
===
'dev'
)
?
'/members_space/'
:
'/'
;
...
...
members_space/views.py
View file @
730e964d
...
@@ -99,10 +99,14 @@ def index(request, exception=None):
...
@@ -99,10 +99,14 @@ def index(request, exception=None):
partnerData
[
"parent_id"
]
=
partnerData
[
"parent_id"
][
0
]
partnerData
[
"parent_id"
]
=
partnerData
[
"parent_id"
][
0
]
md5_calc
=
hashlib
.
md5
(
partnerData
[
'parent_create_date'
]
.
encode
(
'utf-8'
))
.
hexdigest
()
md5_calc
=
hashlib
.
md5
(
partnerData
[
'parent_create_date'
]
.
encode
(
'utf-8'
))
.
hexdigest
()
partnerData
[
'parent_verif_token'
]
=
md5_calc
partnerData
[
'parent_verif_token'
]
=
md5_calc
partnerData
[
'makeups_to_do'
]
=
partnerData
[
'parent_makeups_to_do'
]
partnerData
[
'date_delay_stop'
]
=
partnerData
[
'parent_date_delay_stop'
]
partnerData
[
'can_have_delay'
]
=
cs
.
member_can_have_delay
(
int
(
partnerData
[
"parent_id"
]))
partnerData
[
'extra_shift_done'
]
=
partnerData
[
"parent_extra_shift_done"
]
partnerData
[
'extra_shift_done'
]
=
partnerData
[
"parent_extra_shift_done"
]
else
:
else
:
partnerData
[
"parent_name"
]
=
False
partnerData
[
"parent_name"
]
=
False
partnerData
[
'can_have_delay'
]
=
cs
.
member_can_have_delay
(
int
(
partner_id
))
# look for associated partner for parents
# look for associated partner for parents
cm
=
CagetteMember
(
partner_id
)
cm
=
CagetteMember
(
partner_id
)
...
@@ -114,8 +118,6 @@ def index(request, exception=None):
...
@@ -114,8 +118,6 @@ def index(request, exception=None):
if
(
associated_partner
is
not
None
and
partnerData
[
"associated_partner_name"
]
.
find
(
str
(
associated_partner
[
"barcode_base"
]))
==
-
1
):
if
(
associated_partner
is
not
None
and
partnerData
[
"associated_partner_name"
]
.
find
(
str
(
associated_partner
[
"barcode_base"
]))
==
-
1
):
partnerData
[
"associated_partner_name"
]
=
str
(
associated_partner
[
"barcode_base"
])
+
' - '
+
partnerData
[
"associated_partner_name"
]
partnerData
[
"associated_partner_name"
]
=
str
(
associated_partner
[
"barcode_base"
])
+
' - '
+
partnerData
[
"associated_partner_name"
]
partnerData
[
'can_have_delay'
]
=
cs
.
member_can_have_delay
(
int
(
partner_id
))
m
=
CagetteMembersSpace
()
m
=
CagetteMembersSpace
()
context
[
'show_faq'
]
=
getattr
(
settings
,
'MEMBERS_SPACE_FAQ_TEMPLATE'
,
'members_space/faq.html'
)
context
[
'show_faq'
]
=
getattr
(
settings
,
'MEMBERS_SPACE_FAQ_TEMPLATE'
,
'members_space/faq.html'
)
partnerData
[
"comite"
]
=
m
.
is_comite
(
partner_id
)
partnerData
[
"comite"
]
=
m
.
is_comite
(
partner_id
)
...
...
outils/static/css/common.css
View file @
730e964d
...
@@ -7,7 +7,8 @@
...
@@ -7,7 +7,8 @@
.red
{
color
:
#FF0000
;}
.red
{
color
:
#FF0000
;}
.b_red
,
.b_less_than_25pc
{
background
:
#ff3333
!important
;}
.b_red
,
.b_less_than_25pc
{
background
:
#ff3333
!important
;}
.loading
{
background-image
:
url("/static/img/ajax-loader.gif")
;
background-repeat
:
no-repeat
;}
.loading
{
background-image
:
url("/static/img/ajax-loader.gif")
;
background-repeat
:
no-repeat
;}
.loading2
{
display
:
none
;}
.loading2
{
display
:
none
;
position
:
absolute
;
top
:
-20px
;}
.loading2-container
{
position
:
relative
;}
body
{
background
:
#fff
;
margin
:
5px
;}
body
{
background
:
#fff
;
margin
:
5px
;}
a
,
a
:active
,
a
:focus
,
a
,
a
:active
,
a
:focus
,
...
...
shifts/models.py
View file @
730e964d
...
@@ -45,10 +45,12 @@ class CagetteShift(models.Model):
...
@@ -45,10 +45,12 @@ class CagetteShift(models.Model):
partnerData
=
partnerData
[
0
]
partnerData
=
partnerData
[
0
]
if
partnerData
[
'is_associated_people'
]:
if
partnerData
[
'is_associated_people'
]:
cond
=
[[
'id'
,
'='
,
partnerData
[
'parent_id'
][
0
]]]
cond
=
[[
'id'
,
'='
,
partnerData
[
'parent_id'
][
0
]]]
fields
=
[
'create_date'
,
'extra_shift_done'
]
fields
=
[
'create_date'
,
'
makeups_to_do'
,
'date_delay_stop'
,
'
extra_shift_done'
]
parentData
=
self
.
o_api
.
search_read
(
'res.partner'
,
cond
,
fields
,
1
)
parentData
=
self
.
o_api
.
search_read
(
'res.partner'
,
cond
,
fields
,
1
)
if
parentData
:
if
parentData
:
partnerData
[
'parent_create_date'
]
=
parentData
[
0
][
'create_date'
]
partnerData
[
'parent_create_date'
]
=
parentData
[
0
][
'create_date'
]
partnerData
[
'parent_makeups_to_do'
]
=
parentData
[
0
][
'makeups_to_do'
]
partnerData
[
'parent_date_delay_stop'
]
=
parentData
[
0
][
'date_delay_stop'
]
partnerData
[
'parent_extra_shift_done'
]
=
parentData
[
0
][
'extra_shift_done'
]
partnerData
[
'parent_extra_shift_done'
]
=
parentData
[
0
][
'extra_shift_done'
]
if
partnerData
[
'shift_type'
]
==
'standard'
:
if
partnerData
[
'shift_type'
]
==
'standard'
:
...
@@ -368,3 +370,7 @@ class CagetteShift(models.Model):
...
@@ -368,3 +370,7 @@ class CagetteShift(models.Model):
def
member_can_have_delay
(
self
,
partner_id
):
def
member_can_have_delay
(
self
,
partner_id
):
""" Can a member have a delay? """
""" Can a member have a delay? """
return
self
.
o_api
.
execute
(
'res.partner'
,
'can_have_extension'
,
[
partner_id
])
return
self
.
o_api
.
execute
(
'res.partner'
,
'can_have_extension'
,
[
partner_id
])
def
update_counter_event
(
self
,
fields
):
""" Add/remove points """
return
self
.
o_api
.
create
(
'shift.counter.event'
,
fields
)
\ No newline at end of file
templates/members/index.html
View file @
730e964d
...
@@ -138,9 +138,13 @@
...
@@ -138,9 +138,13 @@
</section>
</section>
</section>
</section>
<section
class=
"grid-6 has-gutter"
id=
"service_entry"
>
<section
class=
"grid-6 has-gutter"
id=
"service_entry"
>
<div
class=
"col-
6
row-2"
>
<div
class=
"col-
2
row-2"
>
<a
class=
"btn btn--primary"
data-next=
"first_page"
>
Retour accueil
</a>
<a
class=
"btn btn--primary"
data-next=
"first_page"
>
Retour accueil
</a>
</div>
</div>
<div
class=
"col-2 row-2"
></div>
<div
class=
"col-2 row-2 login_area"
>
{% include "common/conn_admin.html" %}
</div>
<div
class=
"col-1"
></div>
<div
class=
"col-1"
></div>
<div
class=
"col-4"
>
<div
class=
"col-4"
>
<h1
class=
"col-4 txtcenter"
>
Qui es-tu ?
</h1>
<h1
class=
"col-4 txtcenter"
>
Qui es-tu ?
</h1>
...
@@ -178,10 +182,24 @@
...
@@ -178,10 +182,24 @@
<section
id=
"service_validation"
class=
"col-6 grid-6 has-gutter"
>
<section
id=
"service_validation"
class=
"col-6 grid-6 has-gutter"
>
<div
class=
"col-2"
></div>
<div
class=
"col-2"
></div>
<a
class=
"col-2 btn present"
>
{{CONFIRME_PRESENT_BTN|safe}}
</a>
<a
class=
"col-2 btn present"
>
{{CONFIRME_PRESENT_BTN|safe}}
</a>
<div
class=
"col-2 loading2-container"
>
<span
class=
"loading2"
><img
width=
"75"
src=
"/static/img/Pedro_luis_romani_ruiz.gif"
alt=
"Chargement en cours...."
/></span>
<span
class=
"loading2"
><img
width=
"75"
src=
"/static/img/Pedro_luis_romani_ruiz.gif"
alt=
"Chargement en cours...."
/></span>
<div
class=
"col-2"
></div>
</div>
</section>
<div
id=
"associated_service_validation"
>
<p
class=
"col-6 txtcenter"
>
Qui est présent à ce service ?
</p>
<section
class=
"col-6 grid-5 has-gutter"
>
<div
class=
"col-1"
></div>
<a
id=
"associated_btn"
class=
" btn present"
>
Membre
</a>
<a
id=
"partner_btn"
class=
" btn present"
>
Associé
</a>
<a
id=
"both_btn"
class=
" btn present"
>
Les deux
</a>
<div
class=
"col-1 loading2-container"
>
<span
class=
"loading2"
><img
width=
"75"
src=
"/static/img/Pedro_luis_romani_ruiz.gif"
alt=
"Chargement en cours...."
/></span>
</div>
</section>
</section>
</div>
</div>
</div>
<div
class=
"col-2"
></div>
<div
class=
"col-2"
></div>
<a
class=
"btn col-2 return"
data-next=
"service_entry"
>
Retour
</a>
<a
class=
"btn col-2 return"
data-next=
"service_entry"
>
Retour
</a>
<div
class=
"col-2"
></div>
<div
class=
"col-2"
></div>
...
...
templates/members_space/index.html
View file @
730e964d
...
@@ -36,14 +36,18 @@
...
@@ -36,14 +36,18 @@
</div>
</div>
<div
id=
"selectable_shift_line_template"
>
<div
id=
"selectable_shift_line_template"
>
<div
class=
"d-flex shift_line_container"
>
<div
class=
"d-flex shift_line_container
selectable_shift
"
>
<div
class=
"selectable_shift_line btn--primary"
>
<div
class=
"selectable_shift_line btn--primary"
>
<input
type=
"checkbox"
class=
"checkbox"
>
<input
type=
"checkbox"
class=
"checkbox"
>
<div
class=
"selectable_shift_line_text"
>
<div
class=
"selectable_shift_line_text"
>
<span
class=
"shift_line_date"
></span>
-
<span
class=
"shift_line_time"
></span>
<span
class=
"shift_line_date"
></span>
-
<span
class=
"shift_line_time"
></span>
</div>
</div>
</div>
</div>
<div
class=
"affect_associate_registered button--warning"
></div>
<div
class=
"shift_line_extra_actions"
>
<div
class=
"affect_associate_registered"
>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -53,14 +57,16 @@
...
@@ -53,14 +57,16 @@
<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
class=
"modal_affect_shift_buttons"
>
<div
id=
"shift_partner"
class=
"btn--primary assign_shift_button"
>
</div>
</div>
<div
id=
"shift_associate"
class=
" btn--primary
"
>
<div
id=
"shift_associate"
class=
" btn--primary assign_shift_button
"
>
</div>
</div>
<div
id=
"shift_both"
class=
" btn--primary
"
>
<div
id=
"shift_both"
class=
" btn--primary assign_shift_button
"
>
Les deux
Les deux
</div>
</div>
</div>
</div>
</div>
<div
id=
"modal_shift_exchange_template"
>
<div
id=
"modal_shift_exchange_template"
>
<div>
Je suis sur le point d'échanger le service du :
</div>
<div>
Je suis sur le point d'échanger le service du :
</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