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
041fb5f7
Commit
041fb5f7
authored
Sep 08, 2021
by
François
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_bdm_francois' into evolution_bdm
parents
150ac186
b0350e7d
Pipeline
#1285
passed with stage
in 1 minute 33 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
32 deletions
+58
-32
models.py
members/models.py
+35
-11
member.css
members/static/css/member.css
+3
-2
members.js
members/static/js/members.js
+6
-16
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 @
041fb5f7
...
...
@@ -12,7 +12,7 @@ import sys
from
pytz
import
timezone
import
locale
import
re
import
dateutil.parser
...
...
@@ -1045,28 +1045,42 @@ class CagetteServices(models.Model):
return
shift
@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."""
import
dateutil.parser
# 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
()
now
=
dateutil
.
parser
.
parse
(
time
)
-
datetime
.
timedelta
(
minutes
=
tz_offset
)
start1
=
now
-
datetime
.
timedelta
(
minutes
=
20
)
start2
=
now
+
datetime
.
timedelta
(
minutes
=
25
)
start1
=
now
-
datetime
.
timedelta
(
minutes
=
min_before_shift_starts_delay
)
start2
=
now
+
datetime
.
timedelta
(
minutes
=
min_after_shift_starts_delay
)
cond
=
[[
'date_begin_tz'
,
'>='
,
start1
.
isoformat
()],
[
'date_begin_tz'
,
'<='
,
start2
.
isoformat
()]]
fields
=
[
'name'
,
'week_number'
,
'registration_ids'
,
'standard_registration_ids'
,
'shift_template_id'
,
'shift_ticket_ids'
,
'date_begin_tz'
,
'date_end_tz'
]
# return (start1.isoformat(), start2.isoformat())
services
=
api
.
search_read
(
'shift.shift'
,
cond
,
fields
)
#
#
return (start1.isoformat(), start2.isoformat())
services
=
api
.
search_read
(
'shift.shift'
,
cond
,
fields
,
order
=
"date_begin_tz ASC"
)
for
s
in
services
:
if
(
len
(
s
[
'registration_ids'
])
>
0
):
cond
=
[[
'id'
,
'in'
,
s
[
'registration_ids'
]],
[
'state'
,
'!='
,
'cancel'
]]
fields
=
[
'partner_id'
,
'shift_type'
,
'state'
]
members
=
api
.
search_read
(
'shift.registration'
,
cond
,
fields
)
s
[
'members'
]
=
sorted
(
members
,
key
=
lambda
x
:
x
[
'partner_id'
][
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'
]]
fields
=
[
'partner_id'
,
'shift_type'
,
'state'
]
members
=
api
.
search_read
(
'shift.registration'
,
cond
,
fields
)
s
[
'members'
]
=
sorted
(
members
,
key
=
lambda
x
:
x
[
'partner_id'
][
0
])
return
services
@staticmethod
...
...
@@ -1074,6 +1088,16 @@ class CagetteServices(models.Model):
"""Equivalent to click present in presence form."""
api
=
OdooAPI
()
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
)
@staticmethod
...
...
members/static/css/member.css
View file @
041fb5f7
...
...
@@ -36,14 +36,15 @@ video {max-width:none;}
#barcode_base
{
width
:
50px
;
float
:
left
;}
.coop-info
{
min-width
:
300px
;
padding
:
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
;}
h1
.member_name
{
font-weight
:
bold
;}
#current_shift_title
,
.members_list
{
border
:
1px
solid
#000
;
border-radius
:
5px
;
padding
:
5px
;
margin-bottom
:
15px
;
background
:
#FFF
;}
.members_list
{
list-style
:
none
;}
.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
.explanations
{
margin
:
25px
0
;
font-size
:
18px
;}
...
...
members/static/js/members.js
View file @
041fb5f7
...
...
@@ -264,6 +264,9 @@ function fill_service_entry(s) {
if
(
s
.
members
)
{
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
)
{
var
li_class
=
"btn"
;
var
li_data
=
""
;
...
...
@@ -445,14 +448,15 @@ function record_service_presence() {
var
res
=
rData
.
res
;
var
next
=
(
res
.
update
==
'ok'
)
||
(
res
.
rattrapage
&&
!
isNaN
(
res
.
rattrapage
));
if
(
next
)
{
fill_service_entry_sucess
(
rData
.
res
.
member
);
goto_page
(
pages
.
service_entry_success
);
}
else
if
(
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
();
}
);
...
...
@@ -488,20 +492,6 @@ function fill_rattrapage_2() {
function
init_webcam
()
{
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
({
width
:
320
,
height
:
240
,
...
...
members/views.py
View file @
041fb5f7
...
...
@@ -28,8 +28,10 @@ def index(request):
"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'
,
'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'
,
''
)
msettings
=
MConfig
.
get_settings
(
'members'
)
...
...
outils/config.md
View file @
041fb5f7
...
...
@@ -244,6 +244,14 @@
(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
-
EM_URL = ''
...
...
templates/members/index.html
View file @
041fb5f7
...
...
@@ -8,7 +8,7 @@
<script
type=
"text/javascript"
>
// Prevent back page
// Add actual page to history
history
.
pushState
(
null
,
null
,
location
.
pathname
)
history
.
pushState
(
null
,
null
,
location
.
pathname
)
;
// Register back button click
window
.
onpopstate
=
function
(
e
)
{
...
...
@@ -16,7 +16,8 @@
e
.
preventDefault
()
// Add actual page to history again
history
.
pushState
(
null
,
null
,
location
.
pathname
)
}
};
window
.
late_mode
=
{
%
if
LATE_MODE
%
}
true
{
%
else
%
}
false
{
%
endif
%
};
</script>
<script
src=
"{% static "
js
/
webcam
.
min
.
js
"
%}"
>
</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