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
41cf5e75
Commit
41cf5e75
authored
Feb 24, 2022
by
Etienne Freiss
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
develop
parent
47352168
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
152 additions
and
20 deletions
+152
-20
models.py
members_space/models.py
+1
-1
members-space-my-shifts.js
members_space/static/js/members-space-my-shifts.js
+48
-17
members-space-shifts-exchange.js
members_space/static/js/members-space-shifts-exchange.js
+55
-2
models.py
shifts/models.py
+19
-0
urls.py
shifts/urls.py
+1
-0
views.py
shifts/views.py
+28
-0
No files found.
members_space/models.py
View file @
41cf5e75
...
@@ -44,7 +44,7 @@ class CagetteMembersSpace(models.Model):
...
@@ -44,7 +44,7 @@ class CagetteMembersSpace(models.Model):
[
'state'
,
'!='
,
'replaced'
],
[
'state'
,
'!='
,
'replaced'
],
[
'state'
,
'!='
,
'replacing'
],
[
'state'
,
'!='
,
'replacing'
],
]
]
f
=
[
'create_date'
,
'date_begin'
,
'shift_id'
,
'name'
,
'state'
,
'is_late'
,
'is_makeup'
]
f
=
[
'create_date'
,
'date_begin'
,
'shift_id'
,
'name'
,
'state'
,
'is_late'
,
'is_makeup'
,
'associate_registered'
]
marshal_none_error
=
'cannot marshal None unless allow_none is enabled'
marshal_none_error
=
'cannot marshal None unless allow_none is enabled'
try
:
try
:
...
...
members_space/static/js/members-space-my-shifts.js
View file @
41cf5e75
...
@@ -66,6 +66,32 @@ function prepare_server_data(data) {
...
@@ -66,6 +66,32 @@ function prepare_server_data(data) {
}
}
}
}
if
(
history_item
.
associate_registered
==
false
||
history_item
.
associate_registered
==
undefined
){
history_item
.
associate_registered
=
""
}
else
{
if
(
partner_data
.
associated_partner_id
!=
"False"
){
if
(
history_item
.
associate_registered
===
"partner"
){
history_item
.
associate_registered
=
partner_data
.
name
}
else
if
(
history_item
.
associate_registered
===
"associate"
){
history_item
.
associate_registered
=
partner_data
.
associated_partner_name
}
else
if
(
history_item
.
associate_registered
===
"both"
){
history_item
.
associate_registered
=
"Les deux"
}
else
{
history_item
.
associate_registered
=
""
}
}
else
if
(
partner_data
.
parent_id
!=
"False"
){
if
(
history_item
.
associate_registered
===
"partner"
){
history_item
.
associate_registered
=
partner_data
.
parent_name
}
else
if
(
history_item
.
associate_registered
===
"associate"
){
history_item
.
associate_registered
=
partner_data
.
name
}
else
if
(
history_item
.
associate_registered
===
"both"
){
history_item
.
associate_registered
=
"Les deux"
}
else
{
history_item
.
associate_registered
=
""
}
}
}
history_item
.
details
=
''
;
history_item
.
details
=
''
;
if
(
history_item
.
state
===
'excused'
||
history_item
.
state
===
'absent'
)
{
if
(
history_item
.
state
===
'excused'
||
history_item
.
state
===
'absent'
)
{
history_item
.
details
=
"Absent.e"
;
history_item
.
details
=
"Absent.e"
;
...
@@ -87,7 +113,6 @@ function prepare_server_data(data) {
...
@@ -87,7 +113,6 @@ function prepare_server_data(data) {
function
init_history
()
{
function
init_history
()
{
$
(
".loading-history"
).
hide
();
$
(
".loading-history"
).
hide
();
$
(
"#history"
).
show
();
$
(
"#history"
).
show
();
if
(
partner_history
.
length
===
0
)
{
if
(
partner_history
.
length
===
0
)
{
$
(
"#history"
).
empty
()
$
(
"#history"
).
empty
()
.
text
(
"Aucun historique... pour l'instant !"
);
.
text
(
"Aucun historique... pour l'instant !"
);
...
@@ -103,7 +128,7 @@ function init_history() {
...
@@ -103,7 +128,7 @@ function init_history() {
{
{
data
:
"shift_name"
,
data
:
"shift_name"
,
title
:
"<spans class='dt-body-center'>Service</span>"
,
title
:
"<spans class='dt-body-center'>Service</span>"
,
width
:
"
6
0%"
,
width
:
"
5
0%"
,
orderable
:
false
orderable
:
false
},
},
{
{
...
@@ -111,6 +136,11 @@ function init_history() {
...
@@ -111,6 +136,11 @@ function init_history() {
title
:
"Détails"
,
title
:
"Détails"
,
className
:
"tablet-l desktop"
,
className
:
"tablet-l desktop"
,
orderable
:
false
orderable
:
false
},
{
data
:
"associate_registered"
,
title
:
""
,
orderable
:
false
}
}
],
],
iDisplayLength
:
-
1
,
iDisplayLength
:
-
1
,
...
@@ -146,7 +176,6 @@ function init_history() {
...
@@ -146,7 +176,6 @@ function init_history() {
* Init the Incoming shifts section: display them
* Init the Incoming shifts section: display them
*/
*/
function
init_incoming_shifts
()
{
function
init_incoming_shifts
()
{
console
.
log
(
partner_data
)
$
(
".loading-incoming-shifts"
).
hide
();
$
(
".loading-incoming-shifts"
).
hide
();
$
(
"#incoming_shifts"
).
show
();
$
(
"#incoming_shifts"
).
show
();
...
@@ -158,26 +187,28 @@ function init_incoming_shifts() {
...
@@ -158,26 +187,28 @@ function init_incoming_shifts() {
for
(
shift
of
incoming_shifts
)
{
for
(
shift
of
incoming_shifts
)
{
let
shift_line_template
=
prepare_shift_line_template
(
shift
.
date_begin
);
let
shift_line_template
=
prepare_shift_line_template
(
shift
.
date_begin
);
if
(
partner_data
.
associated_partner_id
!=
"False"
&&
shift
.
associate_registered
===
"partner"
){
if
(
partner_data
.
associated_partner_id
!=
"False"
){
if
(
shift
.
associate_registered
===
"partner"
){
shift_line_template
.
find
(
".shift_line_associate"
).
text
(
' - '
+
partner_data
.
name
+
''
)
shift_line_template
.
find
(
".shift_line_associate"
).
text
(
' - '
+
partner_data
.
name
+
''
)
}
else
if
(
shift
.
associate_registered
===
"associate"
){
}
else
if
(
partner_data
.
associated_partner_id
!=
"False"
&&
shift
.
associate_registered
===
"associated"
){
shift_line_template
.
find
(
".shift_line_associate"
).
text
(
' - '
+
partner_data
.
associated_partner_name
+
''
)
shift_line_template
.
find
(
".shift_line_associate"
).
text
(
' - '
+
partner_data
.
associated_partner_name
+
''
)
}
else
if
(
shift
.
associate_registered
===
"both"
){
}
else
if
(
partner_data
.
associated_partner_id
!=
"False"
&&
shift
.
associate_registered
===
"both"
){
shift_line_template
.
find
(
".shift_line_associate"
).
text
(
' - Les deux'
)
shift_line_template
.
find
(
".shift_line_associate"
).
text
(
' - Les deux'
)
}
else
{
shift_line_template
.
find
(
".shift_line_associate"
).
text
(
'A définir'
)
}
}
else
if
(
partner_data
.
parent_id
!=
"False"
&&
shift
.
associate_registered
===
"partner"
){
}
else
if
(
partner_data
.
parent_id
!=
"False"
){
if
(
shift
.
associate_registered
===
"partner"
){
shift_line_template
.
find
(
".shift_line_associate"
).
text
(
' - '
+
partner_data
.
parent_name
+
''
)
shift_line_template
.
find
(
".shift_line_associate"
).
text
(
' - '
+
partner_data
.
parent_name
+
''
)
}
else
if
(
shift
.
associate_registered
===
"associate"
){
}
else
if
(
partner_data
.
parent_id
!=
"False"
&&
shift
.
associate_registered
===
"associated"
){
shift_line_template
.
find
(
".shift_line_associate"
).
text
(
' - '
+
partner_data
.
name
+
''
)
shift_line_template
.
find
(
".shift_line_associate"
).
text
(
' - '
+
partner_data
.
name
+
''
)
}
else
if
(
shift
.
associate_registered
===
"both"
){
}
else
if
(
partner_data
.
parent_id
!=
"False"
&&
shift
.
associate_registered
===
"both"
){
shift_line_template
.
find
(
".shift_line_associate"
).
text
(
' - Les deux'
)
shift_line_template
.
find
(
".shift_line_associate"
).
text
(
' - Les deux'
)
}
else
{
shift_line_template
.
find
(
".shift_line_associate"
).
text
(
'A définir'
)
}
}
}
$
(
"#incoming_shifts"
).
append
(
shift_line_template
.
html
());
$
(
"#incoming_shifts"
).
append
(
shift_line_template
.
html
());
...
...
members_space/static/js/members-space-shifts-exchange.js
View file @
41cf5e75
...
@@ -112,7 +112,6 @@ function add_or_change_shift(new_shift_id) {
...
@@ -112,7 +112,6 @@ function add_or_change_shift(new_shift_id) {
}
}
function
init_shifts_list
()
{
function
init_shifts_list
()
{
console
.
log
(
partner_data
)
$
(
".loading-incoming-shifts"
).
hide
();
$
(
".loading-incoming-shifts"
).
hide
();
$
(
"#shifts_list"
).
show
();
$
(
"#shifts_list"
).
show
();
...
@@ -202,6 +201,7 @@ function init_shifts_list() {
...
@@ -202,6 +201,7 @@ function init_shifts_list() {
$
(
".affect_associate_registered"
).
on
(
"click"
,
function
(
e
)
{
$
(
".affect_associate_registered"
).
on
(
"click"
,
function
(
e
)
{
// Display modal
// Display modal
id
=
$
(
this
).
attr
(
'id'
).
split
(
'_'
)[
2
]
let
modal_template
=
$
(
"#modal_affect_shift"
);
let
modal_template
=
$
(
"#modal_affect_shift"
);
if
(
partner_data
.
associated_partner_id
!=
"False"
)
{
if
(
partner_data
.
associated_partner_id
!=
"False"
)
{
modal_template
.
find
(
"#shift_partner"
).
text
(
partner_data
.
name
);
modal_template
.
find
(
"#shift_partner"
).
text
(
partner_data
.
name
);
...
@@ -219,15 +219,68 @@ function init_shifts_list() {
...
@@ -219,15 +219,68 @@ function init_shifts_list() {
openModal
(
openModal
(
modal_template
.
html
(),
modal_template
.
html
(),
()
=>
{
()
=>
{
// add_or_change_shift(new_shift_id);
},
},
"Valider"
"Valider"
);
);
modal
.
find
(
'#shift_partner'
).
on
(
"click"
,
function
(
e
)
{
affect_shift
(
"partner"
,
id
)
});
modal
.
find
(
'#shift_associate'
).
on
(
"click"
,
function
(
e
)
{
affect_shift
(
"associate"
,
id
)
});
modal
.
find
(
'#shift_both'
).
on
(
"click"
,
function
(
e
)
{
affect_shift
(
"both"
,
id
)
});
modal
.
find
(
".btn-modal-ok"
).
hide
()
modal
.
find
(
".btn-modal-ok"
).
hide
()
});
});
}
}
}
}
/**
* Proceed to shift modification
* @param {string} partner
* @param {string} shift_id
*/
function
affect_shift
(
partner
,
shift_id
)
{
tData
=
'idShiftRegistration='
+
shift_id
+
'&idPartner='
+
partner_data
.
partner_id
+
'&affected_partner='
+
partner
+
'&verif_token='
+
partner_data
.
verif_token
;
tUrl
=
'/shifts/affect_shift'
;
$
.
ajax
({
type
:
'POST'
,
url
:
tUrl
,
dataType
:
"json"
,
data
:
tData
,
timeout
:
3000
,
success
:
function
(
data
)
{
load_partner_shifts
(
partner_data
.
concerned_partner_id
)
.
then
(()
=>
{
init_shifts_list
();
closeModal
();
});
},
error
:
function
(
error
)
{
init_shifts_list
();
closeModal
();
alert
(
`Une erreur est survenue. `
+
`Il est néanmoins possible que la requête ait abouti, `
+
`veuillez patienter quelques secondes puis vérifier vos services enregistrés.`
);
}
});
}
/**
/**
* Inits the page when the calendar is displayed
* Inits the page when the calendar is displayed
*/
*/
...
...
shifts/models.py
View file @
41cf5e75
...
@@ -167,6 +167,25 @@ class CagetteShift(models.Model):
...
@@ -167,6 +167,25 @@ class CagetteShift(models.Model):
st_r_id
=
True
st_r_id
=
True
return
st_r_id
return
st_r_id
def
affect_shift
(
self
,
data
):
"""Affect shift to partner, his associate or both"""
response
=
None
cond
=
[[
'partner_id'
,
'='
,
int
(
data
[
'idPartner'
])],
[
'id'
,
'='
,
int
(
data
[
'idShiftRegistration'
])]]
fields
=
[
'id'
]
try
:
print
(
cond
)
shit_to_affect
=
self
.
o_api
.
search_read
(
'shift.registration'
,
cond
,
fields
,
1
)
print
(
shit_to_affect
)
if
(
len
(
shit_to_affect
)
==
1
):
shift_res
=
shit_to_affect
[
0
]
print
(
shift_res
)
fieldsDatas
=
{
"associate_registered"
:
data
[
'affected_partner'
]}
response
=
self
.
o_api
.
update
(
'shift.registration'
,
[
shift_res
[
'id'
]],
fieldsDatas
)
except
Exception
as
e
:
coop_logger
.
error
(
"Reopen shift :
%
s"
,
str
(
e
))
return
response
def
cancel_shift
(
self
,
idsRegisteur
):
def
cancel_shift
(
self
,
idsRegisteur
):
"""Annule un shift"""
"""Annule un shift"""
fieldsDatas
=
{
"related_shift_state"
:
'cancel'
,
fieldsDatas
=
{
"related_shift_state"
:
'cancel'
,
...
...
shifts/urls.py
View file @
41cf5e75
...
@@ -13,6 +13,7 @@ urlpatterns = [
...
@@ -13,6 +13,7 @@ urlpatterns = [
url
(
r'^get_test'
,
views
.
get_test
),
url
(
r'^get_test'
,
views
.
get_test
),
# url(r'^get_list', views.get_list),
# url(r'^get_list', views.get_list),
url
(
r'^change_shift'
,
views
.
change_shift
),
url
(
r'^change_shift'
,
views
.
change_shift
),
url
(
r'^affect_shift'
,
views
.
affect_shift
),
url
(
r'^add_shift'
,
views
.
add_shift
),
url
(
r'^add_shift'
,
views
.
add_shift
),
url
(
r'^request_delay'
,
views
.
request_delay
),
url
(
r'^request_delay'
,
views
.
request_delay
),
url
(
r'^reset_members_positive_points'
,
views
.
reset_members_positive_points
)
url
(
r'^reset_members_positive_points'
,
views
.
reset_members_positive_points
)
...
...
shifts/views.py
View file @
41cf5e75
...
@@ -232,6 +232,34 @@ def change_shift(request):
...
@@ -232,6 +232,34 @@ def change_shift(request):
else
:
else
:
return
HttpResponseForbidden
()
return
HttpResponseForbidden
()
def
affect_shift
(
request
):
if
'verif_token'
in
request
.
POST
:
if
Verification
.
verif_token
(
request
.
POST
.
get
(
'verif_token'
),
int
(
request
.
POST
.
get
(
'idPartner'
)))
is
True
:
cs
=
CagetteShift
()
if
'idShiftRegistration'
in
request
.
POST
and
'affected_partner'
in
request
.
POST
:
data
=
{
"idPartner"
:
int
(
request
.
POST
[
'idPartner'
]),
"idShiftRegistration"
:
int
(
request
.
POST
[
'idShiftRegistration'
]),
"affected_partner"
:
request
.
POST
[
'affected_partner'
],
}
try
:
st_r_id
=
cs
.
affect_shift
(
data
)
except
Exception
as
e
:
coop_logger
.
error
(
"affect shift :
%
s,
%
s"
,
str
(
e
),
str
(
data
))
if
st_r_id
:
response
=
{
'result'
:
True
}
else
:
response
=
{
'msg'
:
"Internal Error"
}
return
JsonResponse
(
response
,
status
=
500
)
return
(
JsonResponse
({
'result'
:
True
}))
else
:
response
=
{
'msg'
:
"Bad args"
}
return
JsonResponse
(
response
,
status
=
400
)
else
:
return
HttpResponseForbidden
()
else
:
return
HttpResponseForbidden
()
def
add_shift
(
request
):
def
add_shift
(
request
):
if
'verif_token'
in
request
.
POST
:
if
'verif_token'
in
request
.
POST
:
if
Verification
.
verif_token
(
request
.
POST
.
get
(
'verif_token'
),
int
(
request
.
POST
.
get
(
'idPartner'
)))
is
True
:
if
Verification
.
verif_token
(
request
.
POST
.
get
(
'verif_token'
),
int
(
request
.
POST
.
get
(
'idPartner'
)))
is
True
:
...
...
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