Commit a48e0efe by Damien Moulard

Merge branch 'evolution_bdm' of…

Merge branch 'evolution_bdm' of gl.cooperatic.fr:cooperatic-foodcoops/third-party into evolution_bdm
parents bae41870 64580c4f
Pipeline #1287 failed with stage
in 1 minute 24 seconds
...@@ -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,17 @@ class CagetteServices(models.Model): ...@@ -1074,6 +1088,17 @@ 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:
# Notice : Despite is_late is defined as boolean in Odoo, 0 or 1 is needed for api call
is_late = 0
if services[0]['late'] is True:
is_late = 1
f['is_late'] = is_late
else:
return False
return api.update('shift.registration', [int(registration_id)], f) return api.update('shift.registration', [int(registration_id)], f)
@staticmethod @staticmethod
......
...@@ -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;}
......
...@@ -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,
......
...@@ -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')
......
...@@ -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 = ''
......
...@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment