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
b0350e7d
Commit
b0350e7d
authored
Sep 08, 2021
by
François
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: Gestion des absences et retards nouvelles règles
parent
7a0149bc
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
27 deletions
+53
-27
models.py
members/models.py
+31
-7
member.css
members/static/css/member.css
+3
-2
members.js
members/static/js/members.js
+5
-15
views.py
members/views.py
+3
-1
config.md
outils/config.md
+8
-0
index.html
templates/members/index.html
+3
-2
No files found.
members/models.py
View file @
b0350e7d
...
@@ -12,7 +12,7 @@ import sys
...
@@ -12,7 +12,7 @@ import sys
from
pytz
import
timezone
from
pytz
import
timezone
import
locale
import
locale
import
re
import
re
import
dateutil.parser
...
@@ -1045,28 +1045,42 @@ class CagetteServices(models.Model):
...
@@ -1045,28 +1045,42 @@ class CagetteServices(models.Model):
return
shift
return
shift
@staticmethod
@staticmethod
def
get_services_at_time
(
time
,
tz_offset
):
def
get_services_at_time
(
time
,
tz_offset
,
with_members
=
True
):
"""Retrieve present services with member linked."""
"""Retrieve present services with member linked."""
import
dateutil.parser
# import operator
# import operator
min_before_shift_starts_delay
=
20
min_after_shift_starts_delay
=
20
late_mode
=
getattr
(
settings
,
'ENTRANCE_WITH_LATE_MODE'
,
False
)
if
late_mode
is
True
:
min_before_shift_starts_delay
=
getattr
(
settings
,
'ENTRANCE_VALIDATION_GRACE_DELAY'
,
60
)
min_after_shift_starts_delay
=
0
api
=
OdooAPI
()
api
=
OdooAPI
()
now
=
dateutil
.
parser
.
parse
(
time
)
-
datetime
.
timedelta
(
minutes
=
tz_offset
)
now
=
dateutil
.
parser
.
parse
(
time
)
-
datetime
.
timedelta
(
minutes
=
tz_offset
)
start1
=
now
-
datetime
.
timedelta
(
minutes
=
20
)
start1
=
now
-
datetime
.
timedelta
(
minutes
=
min_before_shift_starts_delay
)
start2
=
now
+
datetime
.
timedelta
(
minutes
=
25
)
start2
=
now
+
datetime
.
timedelta
(
minutes
=
min_after_shift_starts_delay
)
cond
=
[[
'date_begin_tz'
,
'>='
,
start1
.
isoformat
()],
cond
=
[[
'date_begin_tz'
,
'>='
,
start1
.
isoformat
()],
[
'date_begin_tz'
,
'<='
,
start2
.
isoformat
()]]
[
'date_begin_tz'
,
'<='
,
start2
.
isoformat
()]]
fields
=
[
'name'
,
'week_number'
,
'registration_ids'
,
fields
=
[
'name'
,
'week_number'
,
'registration_ids'
,
'standard_registration_ids'
,
'standard_registration_ids'
,
'shift_template_id'
,
'shift_ticket_ids'
,
'shift_template_id'
,
'shift_ticket_ids'
,
'date_begin_tz'
,
'date_end_tz'
]
'date_begin_tz'
,
'date_end_tz'
]
# return (start1.isoformat(), start2.isoformat())
#
#
return (start1.isoformat(), start2.isoformat())
services
=
api
.
search_read
(
'shift.shift'
,
cond
,
fields
)
services
=
api
.
search_read
(
'shift.shift'
,
cond
,
fields
,
order
=
"date_begin_tz ASC"
)
for
s
in
services
:
for
s
in
services
:
if
(
len
(
s
[
'registration_ids'
])
>
0
):
if
(
len
(
s
[
'registration_ids'
])
>
0
):
if
late_mode
is
True
:
s
[
'late'
]
=
(
now
.
replace
(
tzinfo
=
None
)
-
dateutil
.
parser
.
parse
(
s
[
'date_begin_tz'
])
.
replace
(
tzinfo
=
None
)
)
.
seconds
/
60
>
min_after_shift_starts_delay
if
with_members
is
True
:
cond
=
[[
'id'
,
'in'
,
s
[
'registration_ids'
]],
[
'state'
,
'!='
,
'cancel'
]]
cond
=
[[
'id'
,
'in'
,
s
[
'registration_ids'
]],
[
'state'
,
'!='
,
'cancel'
]]
fields
=
[
'partner_id'
,
'shift_type'
,
'state'
]
fields
=
[
'partner_id'
,
'shift_type'
,
'state'
]
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
])
return
services
return
services
@staticmethod
@staticmethod
...
@@ -1074,6 +1088,16 @@ class CagetteServices(models.Model):
...
@@ -1074,6 +1088,16 @@ class CagetteServices(models.Model):
"""Equivalent to click present in presence form."""
"""Equivalent to click present in presence form."""
api
=
OdooAPI
()
api
=
OdooAPI
()
f
=
{
'state'
:
'done'
}
f
=
{
'state'
:
'done'
}
late_mode
=
getattr
(
settings
,
'ENTRANCE_WITH_LATE_MODE'
,
False
)
if
late_mode
is
True
:
services
=
CagetteServices
.
get_services_at_time
(
'14:28'
,
0
,
with_members
=
False
)
if
len
(
services
)
>
0
:
is_late
=
0
if
services
[
0
][
'late'
]
is
True
:
is_late
=
1
f
[
'is_late'
]
=
1
else
:
return
False
return
api
.
update
(
'shift.registration'
,
[
int
(
registration_id
)],
f
)
return
api
.
update
(
'shift.registration'
,
[
int
(
registration_id
)],
f
)
@staticmethod
@staticmethod
...
...
members/static/css/member.css
View file @
b0350e7d
...
@@ -36,14 +36,15 @@ video {max-width:none;}
...
@@ -36,14 +36,15 @@ video {max-width:none;}
#barcode_base
{
width
:
50px
;
float
:
left
;}
#barcode_base
{
width
:
50px
;
float
:
left
;}
.coop-info
{
min-width
:
300px
;
padding
:
5px
;}
.coop-info
{
min-width
:
300px
;
padding
:
5px
;}
#lat_menu
button
{
margin-bottom
:
5px
;}
#lat_menu
button
{
margin-bottom
:
5px
;}
.col-6.big
{
font-size
:
200%
;
border
:
2px
solid
red
;
padding
:
10px
;
text-align
:
center
;
background
:
#
ffffff
;}
.col-6.big
{
font-size
:
200%
;
border
:
2px
solid
red
;
padding
:
10px
;
text-align
:
center
;
background
:
#
FFF
;}
#cooperative_state
{
font-size
:
150%
;
font-weight
:
bold
;}
#cooperative_state
{
font-size
:
150%
;
font-weight
:
bold
;}
h1
.member_name
{
font-weight
:
bold
;}
h1
.member_name
{
font-weight
:
bold
;}
#current_shift_title
,
.members_list
#current_shift_title
,
.members_list
{
border
:
1px
solid
#000
;
border-radius
:
5px
;
padding
:
5px
;
margin-bottom
:
15px
;
background
:
#FFF
;}
{
border
:
1px
solid
#000
;
border-radius
:
5px
;
padding
:
5px
;
margin-bottom
:
15px
;
background
:
#FFF
;}
.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
!important
;
cursor
:
not-allowed
;}
.members_list.late
li
{
color
:
#de9b00
;}
.members_list
li
.btn--inverse
{
background
:
#449d44
!important
;
cursor
:
not-allowed
;
color
:
#FFF
;
}
#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
;}
...
...
members/static/js/members.js
View file @
b0350e7d
...
@@ -264,6 +264,9 @@ function fill_service_entry(s) {
...
@@ -264,6 +264,9 @@ function fill_service_entry(s) {
if
(
s
.
members
)
{
if
(
s
.
members
)
{
m_list
=
'<ul class="members_list">'
;
m_list
=
'<ul class="members_list">'
;
if
(
typeof
s
.
late
!=
"undefined"
&&
s
.
late
==
true
)
{
m_list
=
'<ul class="members_list late">'
;
}
$
.
each
(
s
.
members
,
function
(
i
,
e
)
{
$
.
each
(
s
.
members
,
function
(
i
,
e
)
{
var
li_class
=
"btn"
;
var
li_class
=
"btn"
;
var
li_data
=
""
;
var
li_data
=
""
;
...
@@ -445,12 +448,13 @@ function record_service_presence() {
...
@@ -445,12 +448,13 @@ function record_service_presence() {
var
res
=
rData
.
res
;
var
res
=
rData
.
res
;
var
next
=
(
res
.
update
==
'ok'
)
var
next
=
(
res
.
update
==
'ok'
)
||
(
res
.
rattrapage
&&
!
isNaN
(
res
.
rattrapage
));
||
(
res
.
rattrapage
&&
!
isNaN
(
res
.
rattrapage
));
if
(
next
)
{
if
(
next
)
{
fill_service_entry_sucess
(
rData
.
res
.
member
);
fill_service_entry_sucess
(
rData
.
res
.
member
);
goto_page
(
pages
.
service_entry_success
);
goto_page
(
pages
.
service_entry_success
);
}
else
if
(
rData
.
res
.
error
)
{
}
else
if
(
rData
.
res
.
error
)
{
alert
(
rData
.
res
.
error
);
alert
(
rData
.
res
.
error
);
}
else
{
alert
(
"Un problème est survenu. S'il persiste merci de le signaler à un responsable du magasin."
)
}
}
}
}
loading2
.
hide
();
loading2
.
hide
();
...
@@ -488,20 +492,6 @@ function fill_rattrapage_2() {
...
@@ -488,20 +492,6 @@ function fill_rattrapage_2() {
function
init_webcam
()
{
function
init_webcam
()
{
try
{
try
{
/*
Webcam.set({
width: $('#img_width').val(),
height: $('#img_height').val(),
dest_width: $('#img_dest_width').val(),
dest_height: $('#img_dest_height').val(),
crop_width: $('#img_crop_width').val(),
crop_height: $('#img_crop_height').val(),
image_format: 'jpeg',
jpeg_quality: 90
});
*/
Webcam
.
set
({
Webcam
.
set
({
width
:
320
,
width
:
320
,
height
:
240
,
height
:
240
,
...
...
members/views.py
View file @
b0350e7d
...
@@ -28,8 +28,10 @@ def index(request):
...
@@ -28,8 +28,10 @@ def index(request):
"La période pendant laquelle il est possible de s'enregistrer est close."
),
"La période pendant laquelle il est possible de s'enregistrer est close."
),
'ENTRANCE_EASY_SHIFT_VALIDATE_MSG'
:
getattr
(
settings
,
'ENTRANCE_EASY_SHIFT_VALIDATE_MSG'
,
'ENTRANCE_EASY_SHIFT_VALIDATE_MSG'
:
getattr
(
settings
,
'ENTRANCE_EASY_SHIFT_VALIDATE_MSG'
,
'Je valide mon service "Comité"'
),
'Je valide mon service "Comité"'
),
'CONFIRME_PRESENT_BTN'
:
getattr
(
settings
,
'CONFIRME_PRESENT_BTN'
,
'Présent.e'
)
'CONFIRME_PRESENT_BTN'
:
getattr
(
settings
,
'CONFIRME_PRESENT_BTN'
,
'Présent.e'
),
'LATE_MODE'
:
getattr
(
settings
,
'ENTRANCE_WITH_LATE_MODE'
,
False
)
}
}
for_shoping_msg
=
getattr
(
settings
,
'ENTRANCE_COME_FOR_SHOPING_MSG'
,
''
)
for_shoping_msg
=
getattr
(
settings
,
'ENTRANCE_COME_FOR_SHOPING_MSG'
,
''
)
msettings
=
MConfig
.
get_settings
(
'members'
)
msettings
=
MConfig
.
get_settings
(
'members'
)
...
...
outils/config.md
View file @
b0350e7d
...
@@ -244,6 +244,14 @@
...
@@ -244,6 +244,14 @@
(makes sens if ENTRANCE_EASY_SHIFT_VALIDATE is True)
(makes sens if ENTRANCE_EASY_SHIFT_VALIDATE is True)
-
ENTRANCE_WITH_LATE_MODE = True
(If member is coming within the grace delay)
-
ENTRANCE_VALIDATION_GRACE_DELAY = 60
(if not set, 60 minutes is the default)
### Member space
### Member space
-
EM_URL = ''
-
EM_URL = ''
...
...
templates/members/index.html
View file @
b0350e7d
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
// Prevent back page
// Prevent back page
// Add actual page to history
// Add actual page to history
history
.
pushState
(
null
,
null
,
location
.
pathname
)
history
.
pushState
(
null
,
null
,
location
.
pathname
)
;
// Register back button click
// Register back button click
window
.
onpopstate
=
function
(
e
)
{
window
.
onpopstate
=
function
(
e
)
{
...
@@ -16,7 +16,8 @@
...
@@ -16,7 +16,8 @@
e
.
preventDefault
()
e
.
preventDefault
()
// Add actual page to history again
// Add actual page to history again
history
.
pushState
(
null
,
null
,
location
.
pathname
)
history
.
pushState
(
null
,
null
,
location
.
pathname
)
}
};
window
.
late_mode
=
{
%
if
LATE_MODE
%
}
true
{
%
else
%
}
false
{
%
endif
%
};
</script>
</script>
<script
src=
"{% static "
js
/
webcam
.
min
.
js
"
%}"
>
<script
src=
"{% static "
js
/
webcam
.
min
.
js
"
%}"
>
</script>
</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