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
0
Merge Requests
0
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
Alexis AOUN
third-party
Commits
d0157c9c
Commit
d0157c9c
authored
Jul 03, 2021
by
François
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow Special FTOP to easy validate shift (and eslint auto fix)
parent
bfbd616f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
124 additions
and
61 deletions
+124
-61
models.py
members/models.py
+38
-0
members.js
members/static/js/members.js
+67
-57
views.py
members/views.py
+14
-1
orders_helper.js
orders/static/js/orders_helper.js
+0
-0
config.md
outils/config.md
+4
-1
all_common.js
outils/static/js/all_common.js
+1
-2
No files found.
members/models.py
View file @
d0157c9c
...
...
@@ -1176,6 +1176,44 @@ class CagetteServices(models.Model):
result
[
'service_found'
]
=
False
return
result
@staticmethod
def
easy_validate_shift_presence
(
coop_id
):
"""Add a presence point if the request is valid."""
res
=
{}
try
:
api
=
OdooAPI
()
# let verify coop_id is corresponding to a ftop subscriber
cond
=
[[
'id'
,
'='
,
coop_id
]]
fields
=
[
'shift_type'
]
coop
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
if
coop
:
if
coop
[
0
][
'shift_type'
]
==
'ftop'
:
evt_name
=
getattr
(
settings
,
'ENTRANCE_ADD_PT_EVENT_NAME'
,
'Validation service comité'
)
c
=
[[
'partner_id'
,
'='
,
coop_id
],
[
'name'
,
'='
,
evt_name
]]
f
=
[
'create_date'
]
last_point_mvts
=
api
.
search_read
(
'shift.counter.event'
,
c
,
f
,
order
=
"create_date DESC"
,
limit
=
1
)
ok_for_adding_pt
=
False
if
len
(
last_point_mvts
):
now
=
datetime
.
datetime
.
now
()
past
=
datetime
.
datetime
.
strptime
(
last_point_mvts
[
0
][
'create_date'
],
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
if
(
now
-
past
)
.
total_seconds
()
>=
3600
*
24
:
ok_for_adding_pt
=
True
else
:
ok_for_adding_pt
=
True
if
ok_for_adding_pt
is
True
:
res
[
'evt_id'
]
=
CagetteMember
(
coop_id
)
.
add_pts
(
'ftop'
,
1
,
evt_name
)
else
:
res
[
'error'
]
=
"One point has been added less then 24 hours ago"
else
:
res
[
'error'
]
=
"Unallowed coop"
else
:
res
[
'error'
]
=
"Invalid coop id"
except
Exception
as
e
:
coop_logger
.
error
(
"easy_validate_shift_presence :
%
s
%
s"
,
str
(
coop_id
),
str
(
e
))
return
res
class
CagetteUser
(
models
.
Model
):
@staticmethod
...
...
members/static/js/members.js
View file @
d0157c9c
...
...
@@ -24,6 +24,8 @@ var current_displayed_member = null,
rattrapage_ou_volant
=
null
,
timeout_counter
=
null
;
var
search_button
=
$
(
'.btn--primary.search'
);
var
sm_search_member_button
=
$
(
'#sm_search_member_button'
),
sm_search_member_input
=
$
(
'#sm_search_member_input'
);
var
loading2
=
$
(
'.loading2'
);
var
search_field
=
$
(
'input[name="search_string"]'
);
var
shift_title
=
$
(
'#current_shift_title'
);
...
...
@@ -163,7 +165,7 @@ function canSearch() {
function
search_member
(
force_search
=
false
)
{
chars
=
[];
// to prevent false "as barcode-reader" input
operator
=
null
operator
=
null
;
if
(
canSearch
()
||
force_search
)
{
html_elts
.
member_slide
.
hide
();
...
...
@@ -281,11 +283,15 @@ function fill_service_entry(s) {
rattrapage_wanted
.
show
();
}
function
clean_se
rvice_entry
()
{
function
clean_se
arch_for_easy_validate_zone
()
{
$
(
'.search_member_results_area'
).
hide
();
$
(
'.search_member_results'
).
empty
();
$
(
'#sm_search_member_input'
).
val
(
''
);
operator
=
null
sm_search_member_input
.
val
(
''
);
operator
=
null
;
}
function
clean_service_entry
()
{
clean_search_for_easy_validate_zone
();
rattrapage_wanted
.
hide
();
shift_title
.
text
(
''
);
shift_members
.
html
(
''
);
...
...
@@ -677,30 +683,30 @@ function ask_for_easy_shift_validation() {
//alert("operator = " + JSON.stringify(operator))
msg
=
"<p>Je suis bien "
+
operator
.
name
+
"<br/> et <br/>je valide mon service 'Comité' </p>"
;
openModal
(
msg
,
function
()
{
try
{
post_form
(
'/members/easy_validate_shift_presence'
,
{
coop_id
:
operator
.
id
,
},
function
(
err
,
result
)
{
console
.
log
(
result
);
if
(
!
err
)
{
if
(
typeof
(
result
.
msg
)
!=
"undefined"
)
{
alert
(
result
.
msg
);
}
else
if
(
result
.
action
===
null
)
{
console
.
log
(
'ok'
)
}
closeModal
();
}
else
{
console
.
log
(
err
)
}
}
);
}
catch
(
e
)
{
console
.
log
(
e
);
try
{
post_form
(
'/members/easy_validate_shift_presence'
,
{
coop_id
:
operator
.
id
},
function
(
err
,
result
)
{
if
(
!
err
)
{
alert
(
"1 point volant vient d'être ajouté."
);
clean_search_for_easy_validate_zone
();
closeModal
();
}
else
{
if
(
typeof
(
err
.
responseJSON
)
!=
"undefined"
&&
typeof
(
err
.
responseJSON
.
error
)
!=
"undefined"
)
{
alert
(
err
.
responseJSON
.
error
);
}
else
{
console
.
log
(
err
);
}
}
}
);
}
catch
(
e
)
{
console
.
log
(
e
);
}
},
'Confirmer'
);
}
// Display the members from the search result (copied from stock_movements)
...
...
@@ -723,13 +729,11 @@ function display_possible_members() {
+
'</button>'
;
$
(
'.search_member_results'
).
append
(
member_button
);
// Set action on click on a member button
$
(
'.btn_member'
).
on
(
'click'
,
function
()
{
for
(
member
of
members_search_results
)
{
if
(
member
.
id
==
$
(
this
).
attr
(
'member_id'
))
{
operator
=
member
;
// Enable validation button when operator is selected
ask_for_easy_shift_validation
();
break
;
...
...
@@ -784,37 +788,43 @@ $(document).ready(function() {
});
$
(
'#sm_search_member_form'
).
submit
(
function
()
{
let
search_str
=
$
(
'#sm_search_member_input'
).
val
();
$
.
ajax
({
url
:
'/members/search/'
+
search_str
,
dataType
:
'json'
,
success
:
function
(
data
)
{
members_search_results
=
[];
for
(
member
of
data
.
res
)
{
console
.
log
(
member
)
if
(
member
.
shift_type
==
'ftop'
)
{
members_search_results
.
push
(
member
);
if
(
is_time_to
(
'search_member'
,
1000
))
{
sm_search_member_button
.
empty
().
append
(
`<i class="fas fa-spinner fa-spin"></i>`
);
let
search_str
=
sm_search_member_input
.
val
();
$
.
ajax
({
url
:
'/members/search/'
+
search_str
,
dataType
:
'json'
,
success
:
function
(
data
)
{
members_search_results
=
[];
for
(
member
of
data
.
res
)
{
if
(
member
.
shift_type
==
'ftop'
)
{
members_search_results
.
push
(
member
);
}
}
display_possible_members
();
},
error
:
function
(
data
)
{
err
=
{
msg
:
"erreur serveur lors de la recherche de membres"
,
ctx
:
'easy_validate.search_members'
};
report_JS_error
(
err
,
'members'
);
$
.
notify
(
"Erreur lors de la recherche de membre, il faut ré-essayer plus tard..."
,
{
globalPosition
:
"top right"
,
className
:
"error"
});
},
complete
:
function
()
{
sm_search_member_button
.
empty
().
append
(
`Recherche`
);
}
});
}
});
display_possible_members
();
},
error
:
function
(
data
)
{
err
=
{
msg
:
"erreur serveur lors de la recherche de membres"
,
ctx
:
'easy_validate.search_members'
};
report_JS_error
(
err
,
'members'
);
$
.
notify
(
"Erreur lors de la recherche de membre, il faut ré-essayer plus tard..."
,
{
globalPosition
:
"top right"
,
className
:
"error"
});
}
});
})
});
Webcam
.
on
(
'live'
,
function
()
{
...
...
members/views.py
View file @
d0157c9c
...
...
@@ -286,7 +286,20 @@ def record_service_presence(request):
return
JsonResponse
({
'res'
:
res
})
def
easy_validate_shift_presence
(
request
):
return
JsonResponse
({})
"""Add a presence point if the request is valid."""
res
=
{}
try
:
coop_id
=
int
(
request
.
POST
.
get
(
"coop_id"
,
"nan"
))
res
=
CagetteServices
.
easy_validate_shift_presence
(
coop_id
)
except
Exception
as
e
:
res
[
'error'
]
=
str
(
e
)
if
'error'
in
res
:
if
res
[
'error'
]
==
"One point has been added less then 24 hours ago"
:
# TODO : use translation (all project wide)
res
[
'error'
]
=
"Vous ne pouvez pas valider plus d'un service par 24h"
return
JsonResponse
(
res
,
status
=
500
)
else
:
return
JsonResponse
(
res
,
safe
=
False
)
def
record_absences
(
request
):
return
JsonResponse
({
'res'
:
CagetteServices
.
record_absences
()})
...
...
orders/static/js/orders_helper.js
View file @
d0157c9c
This diff is collapsed.
Click to expand it.
outils/config.md
View file @
d0157c9c
...
...
@@ -230,8 +230,11 @@
-
ENTRANCE_EXTRA_BUTTONS_DISPLAY = False (no button is shown above shift coop. list) (True if not set)
-
ENTRANCE_EASY_SHIFT_VALIDATE = False (default value)
When set to True allow coop to identify and have 1 point (only if FTOP)
-
ENTRANCE_EASY_SHIFT_VALIDATE = False (default value)
When set to True allow coop to identify and have 1 point (only if FTOP)
-
ENTRANCE_ADD_PT_EVENT_NAME = 'Add 1 point name throught easy validate' (default : 'Validation service comité'')
### Member space
-
EM_URL = ''
...
...
outils/static/js/all_common.js
View file @
d0157c9c
...
...
@@ -59,10 +59,9 @@ function post_form(url, data, callback) {
$
.
post
(
ajax_params
)
.
done
(
function
(
rData
)
{
callback
(
null
,
rData
);
})
.
fail
(
function
(
err
)
{
c
onsole
.
log
(
err
);
c
allback
(
err
,
{}
);
});
}
...
...
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