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
7993a150
Commit
7993a150
authored
Mar 07, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow associated members to choose makeups + fixs
parent
5cfdcae6
Pipeline
#1872
passed with stage
in 1 minute 28 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
75 deletions
+80
-75
models.py
members/models.py
+1
-0
members-space-home.js
members_space/static/js/members-space-home.js
+0
-64
members-space-shifts-exchange.js
members_space/static/js/members-space-shifts-exchange.js
+8
-3
members-space.js
members_space/static/js/members-space.js
+64
-4
views.py
members_space/views.py
+4
-3
models.py
shifts/models.py
+3
-1
No files found.
members/models.py
View file @
7993a150
...
@@ -132,6 +132,7 @@ class CagetteMember(models.Model):
...
@@ -132,6 +132,7 @@ class CagetteMember(models.Model):
fp
=
request
.
POST
.
get
(
'fp'
)
# fingerprint (prevent using stolen cookies)
fp
=
request
.
POST
.
get
(
'fp'
)
# fingerprint (prevent using stolen cookies)
if
login
and
password
:
if
login
and
password
:
api
=
OdooAPI
()
api
=
OdooAPI
()
login
=
login
.
strip
()
cond
=
[[
'email'
,
'='
,
login
]]
cond
=
[[
'email'
,
'='
,
login
]]
if
getattr
(
settings
,
'ALLOW_NON_MEMBER_TO_CONNECT'
,
False
)
is
False
:
if
getattr
(
settings
,
'ALLOW_NON_MEMBER_TO_CONNECT'
,
False
)
is
False
:
cond
.
append
(
'|'
)
cond
.
append
(
'|'
)
...
...
members_space/static/js/members-space-home.js
View file @
7993a150
/**
* Request a 6 month delay
*/
function
request_delay
()
{
return
new
Promise
((
resolve
)
=>
{
let
today
=
new
Date
();
const
delay_start
=
today
.
getFullYear
()
+
'-'
+
(
today
.
getMonth
()
+
1
)
+
'-'
+
today
.
getDate
();
let
today_plus_six_month
=
new
Date
();
today_plus_six_month
.
setMonth
(
today_plus_six_month
.
getMonth
()
+
6
);
const
diff_time
=
Math
.
abs
(
today_plus_six_month
-
today
);
const
diff_days
=
Math
.
ceil
(
diff_time
/
(
1000
*
60
*
60
*
24
));
$
.
ajax
({
type
:
'POST'
,
url
:
"/shifts/request_delay"
,
dataType
:
"json"
,
data
:
{
verif_token
:
partner_data
.
verif_token
,
idPartner
:
partner_data
.
partner_id
,
start_date
:
delay_start
,
duration
:
diff_days
},
success
:
function
()
{
partner_data
.
cooperative_state
=
'delay'
;
partner_data
.
date_delay_stop
=
today_plus_six_month
.
getFullYear
()
+
'-'
+
(
today_plus_six_month
.
getMonth
()
+
1
)
+
'-'
+
today_plus_six_month
.
getDate
();
resolve
();
},
error
:
function
(
data
)
{
if
(
data
.
status
==
403
&&
typeof
data
.
responseJSON
!=
'undefined'
&&
data
.
responseJSON
.
message
===
"delays limit reached"
)
{
closeModal
();
let
msg_template
=
$
(
"#cant_have_delay_msg_template"
);
openModal
(
msg_template
.
html
(),
()
=>
{
window
.
location
=
member_cant_have_delay_form_link
;
},
"J'accède au formulaire"
,
true
,
false
);
}
else
{
err
=
{
msg
:
"erreur serveur lors de la création du délai"
,
ctx
:
'request_delay'
};
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
}
report_JS_error
(
err
,
'members_space.home'
);
closeModal
();
alert
(
'Erreur lors de la création du délai.'
);
}
}
});
});
}
function
init_my_shifts_tile
()
{
function
init_my_shifts_tile
()
{
if
(
incoming_shifts
.
length
===
0
)
{
if
(
incoming_shifts
.
length
===
0
)
{
$
(
"#home_tile_my_services #home_incoming_services"
).
text
(
"Aucun service à venir..."
);
$
(
"#home_tile_my_services #home_incoming_services"
).
text
(
"Aucun service à venir..."
);
...
...
members_space/static/js/members-space-shifts-exchange.js
View file @
7993a150
...
@@ -161,7 +161,7 @@ function init_shifts_list() {
...
@@ -161,7 +161,7 @@ function init_shifts_list() {
shift_line_template
.
find
(
".shift_line_date"
).
text
(
f_date_shift_start
);
shift_line_template
.
find
(
".shift_line_date"
).
text
(
f_date_shift_start
);
shift_line_template
.
find
(
".shift_line_time"
).
text
(
datetime_shift_start
.
toLocaleTimeString
(
"fr-fr"
,
time_options
));
shift_line_template
.
find
(
".shift_line_time"
).
text
(
datetime_shift_start
.
toLocaleTimeString
(
"fr-fr"
,
time_options
));
if
(
!
can_exchange_shifts
()
&&
block_actions_for_attached_people
===
"True"
)
{
if
(
!
can_exchange_shifts
())
{
shift_line_template
.
find
(
".selectable_shift_line"
).
removeClass
(
"btn--primary"
);
shift_line_template
.
find
(
".selectable_shift_line"
).
removeClass
(
"btn--primary"
);
shift_line_template
.
find
(
".selectable_shift_line"
).
addClass
(
"btn"
);
shift_line_template
.
find
(
".selectable_shift_line"
).
addClass
(
"btn"
);
shift_line_template
.
find
(
".checkbox"
).
prop
(
"disabled"
,
"disabled"
);
shift_line_template
.
find
(
".checkbox"
).
prop
(
"disabled"
,
"disabled"
);
...
@@ -175,6 +175,12 @@ function init_shifts_list() {
...
@@ -175,6 +175,12 @@ function init_shifts_list() {
if
(
partner_data
.
associated_partner_id
===
"False"
&&
partner_data
.
parent_id
===
"False"
)
{
if
(
partner_data
.
associated_partner_id
===
"False"
&&
partner_data
.
parent_id
===
"False"
)
{
shift_line_template
.
find
(
'.affect_associate_registered'
).
hide
();
shift_line_template
.
find
(
'.affect_associate_registered'
).
hide
();
}
else
{
}
else
{
if
(
!
can_exchange_shifts
())
{
shift_line_template
.
find
(
'.affect_associate_registered'
).
hide
();
}
else
{
shift_line_template
.
find
(
'.affect_associate_registered'
).
show
();
}
shift_line_template
.
find
(
'.affect_associate_registered'
).
attr
(
'id'
,
'shift_id_'
+
shift
.
id
);
shift_line_template
.
find
(
'.affect_associate_registered'
).
attr
(
'id'
,
'shift_id_'
+
shift
.
id
);
if
(
shift
.
associate_registered
===
"both"
)
{
if
(
shift
.
associate_registered
===
"both"
)
{
shift_line_template
.
find
(
'.affect_associate_registered'
).
text
(
"Les deux"
);
shift_line_template
.
find
(
'.affect_associate_registered'
).
text
(
"Les deux"
);
...
@@ -600,8 +606,7 @@ function init_shifts_exchange() {
...
@@ -600,8 +606,7 @@ function init_shifts_exchange() {
$
(
this
).
removeClass
(
'active'
);
$
(
this
).
removeClass
(
'active'
);
});
});
});
});
}
else
if
(
}
else
if
(
partner_data
.
comite
===
"True"
)
{
partner_data
.
comite
===
"True"
)
{
let
msg_template
=
$
(
"#comite_template"
);
let
msg_template
=
$
(
"#comite_template"
);
$
(
".comite_content_msg"
).
html
(
msg_template
.
html
());
$
(
".comite_content_msg"
).
html
(
msg_template
.
html
());
...
...
members_space/static/js/members-space.js
View file @
7993a150
...
@@ -131,6 +131,70 @@ function update_content() {
...
@@ -131,6 +131,70 @@ function update_content() {
/* - Shifts */
/* - Shifts */
/**
/**
* Request a 6 month delay
*/
function
request_delay
()
{
return
new
Promise
((
resolve
)
=>
{
let
today
=
new
Date
();
const
delay_start
=
today
.
getFullYear
()
+
'-'
+
(
today
.
getMonth
()
+
1
)
+
'-'
+
today
.
getDate
();
let
today_plus_six_month
=
new
Date
();
today_plus_six_month
.
setMonth
(
today_plus_six_month
.
getMonth
()
+
6
);
const
diff_time
=
Math
.
abs
(
today_plus_six_month
-
today
);
const
diff_days
=
Math
.
ceil
(
diff_time
/
(
1000
*
60
*
60
*
24
));
$
.
ajax
({
type
:
'POST'
,
url
:
"/shifts/request_delay"
,
dataType
:
"json"
,
data
:
{
verif_token
:
(
partner_data
.
is_associated_people
===
"True"
)
?
partner_data
.
parent_verif_token
:
partner_data
.
verif_token
,
idPartner
:
partner_data
.
concerned_partner_id
,
start_date
:
delay_start
,
duration
:
diff_days
},
success
:
function
()
{
partner_data
.
cooperative_state
=
'delay'
;
partner_data
.
date_delay_stop
=
today_plus_six_month
.
getFullYear
()
+
'-'
+
(
today_plus_six_month
.
getMonth
()
+
1
)
+
'-'
+
today_plus_six_month
.
getDate
();
resolve
();
},
error
:
function
(
data
)
{
if
(
data
.
status
==
403
&&
typeof
data
.
responseJSON
!=
'undefined'
&&
data
.
responseJSON
.
message
===
"delays limit reached"
)
{
closeModal
();
let
msg_template
=
$
(
"#cant_have_delay_msg_template"
);
openModal
(
msg_template
.
html
(),
()
=>
{
window
.
location
=
member_cant_have_delay_form_link
;
},
"J'accède au formulaire"
,
true
,
false
);
}
else
{
err
=
{
msg
:
"erreur serveur lors de la création du délai"
,
ctx
:
'request_delay'
};
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
}
report_JS_error
(
err
,
'members_space.home'
);
closeModal
();
alert
(
'Erreur lors de la création du délai.'
);
}
}
});
});
}
/**
* Prepare a shift line to insert into the DOM.
* Prepare a shift line to insert into the DOM.
* Is used in: Home - My Shifts tile ; My Shifts - Incoming shifts section
* Is used in: Home - My Shifts tile ; My Shifts - Incoming shifts section
*
*
...
@@ -199,7 +263,6 @@ function init_my_info_data() {
...
@@ -199,7 +263,6 @@ function init_my_info_data() {
if
(
if
(
partner_data
.
makeups_to_do
>
0
partner_data
.
makeups_to_do
>
0
&&
partner_data
.
is_associated_people
===
"False"
&&
partner_data
.
cooperative_state
!==
'unsubscribed'
&&
partner_data
.
cooperative_state
!==
'unsubscribed'
)
{
)
{
$
(
".choose_makeups"
).
show
();
$
(
".choose_makeups"
).
show
();
...
@@ -227,8 +290,6 @@ function init_my_info_data() {
...
@@ -227,8 +290,6 @@ function init_my_info_data() {
}
}
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
// TODO essayer de ne charger les js que au besoin
$
.
ajaxSetup
({
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)
}
});
$
.
ajaxSetup
({
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)
}
});
// If partner is associated (attached), display the pair's main partner shift data
// If partner is associated (attached), display the pair's main partner shift data
...
@@ -242,7 +303,6 @@ $(document).ready(function() {
...
@@ -242,7 +303,6 @@ $(document).ready(function() {
// For associated people, their parent name is attached in their display name
// For associated people, their parent name is attached in their display name
let
partner_name_split
=
partner_data
.
name
.
split
(
', '
);
let
partner_name_split
=
partner_data
.
name
.
split
(
', '
);
partner_data
.
name
=
partner_name_split
[
partner_name_split
.
length
-
1
];
partner_data
.
name
=
partner_name_split
[
partner_name_split
.
length
-
1
];
base_location
=
(
app_env
===
'dev'
)
?
'/members_space/'
:
'/'
;
base_location
=
(
app_env
===
'dev'
)
?
'/members_space/'
:
'/'
;
...
...
members_space/views.py
View file @
7993a150
...
@@ -99,9 +99,12 @@ def index(request, exception=None):
...
@@ -99,9 +99,12 @@ def index(request, exception=None):
partnerData
[
"parent_id"
]
=
partnerData
[
"parent_id"
][
0
]
partnerData
[
"parent_id"
]
=
partnerData
[
"parent_id"
][
0
]
md5_calc
=
hashlib
.
md5
(
partnerData
[
'parent_create_date'
]
.
encode
(
'utf-8'
))
.
hexdigest
()
md5_calc
=
hashlib
.
md5
(
partnerData
[
'parent_create_date'
]
.
encode
(
'utf-8'
))
.
hexdigest
()
partnerData
[
'parent_verif_token'
]
=
md5_calc
partnerData
[
'parent_verif_token'
]
=
md5_calc
partnerData
[
'makeups_to_do'
]
=
partnerData
[
'parent_makeups_to_do'
]
partnerData
[
'date_delay_stop'
]
=
partnerData
[
'parent_date_delay_stop'
]
partnerData
[
'can_have_delay'
]
=
cs
.
member_can_have_delay
(
int
(
partnerData
[
"parent_id"
]))
else
:
else
:
partnerData
[
"parent_name"
]
=
False
partnerData
[
"parent_name"
]
=
False
partnerData
[
'can_have_delay'
]
=
cs
.
member_can_have_delay
(
int
(
partner_id
))
# look for associated partner for parents
# look for associated partner for parents
cm
=
CagetteMember
(
partner_id
)
cm
=
CagetteMember
(
partner_id
)
...
@@ -113,8 +116,6 @@ def index(request, exception=None):
...
@@ -113,8 +116,6 @@ def index(request, exception=None):
if
(
associated_partner
is
not
None
and
partnerData
[
"associated_partner_name"
]
.
find
(
str
(
associated_partner
[
"barcode_base"
]))
==
-
1
):
if
(
associated_partner
is
not
None
and
partnerData
[
"associated_partner_name"
]
.
find
(
str
(
associated_partner
[
"barcode_base"
]))
==
-
1
):
partnerData
[
"associated_partner_name"
]
=
str
(
associated_partner
[
"barcode_base"
])
+
' - '
+
partnerData
[
"associated_partner_name"
]
partnerData
[
"associated_partner_name"
]
=
str
(
associated_partner
[
"barcode_base"
])
+
' - '
+
partnerData
[
"associated_partner_name"
]
partnerData
[
'can_have_delay'
]
=
cs
.
member_can_have_delay
(
int
(
partner_id
))
m
=
CagetteMembersSpace
()
m
=
CagetteMembersSpace
()
context
[
'show_faq'
]
=
getattr
(
settings
,
'MEMBERS_SPACE_FAQ_TEMPLATE'
,
'members_space/faq.html'
)
context
[
'show_faq'
]
=
getattr
(
settings
,
'MEMBERS_SPACE_FAQ_TEMPLATE'
,
'members_space/faq.html'
)
partnerData
[
"comite"
]
=
m
.
is_comite
(
partner_id
)
partnerData
[
"comite"
]
=
m
.
is_comite
(
partner_id
)
...
...
shifts/models.py
View file @
7993a150
...
@@ -45,10 +45,12 @@ class CagetteShift(models.Model):
...
@@ -45,10 +45,12 @@ class CagetteShift(models.Model):
partnerData
=
partnerData
[
0
]
partnerData
=
partnerData
[
0
]
if
partnerData
[
'is_associated_people'
]:
if
partnerData
[
'is_associated_people'
]:
cond
=
[[
'id'
,
'='
,
partnerData
[
'parent_id'
][
0
]]]
cond
=
[[
'id'
,
'='
,
partnerData
[
'parent_id'
][
0
]]]
fields
=
[
'create_date'
]
fields
=
[
'create_date'
,
'makeups_to_do'
,
'date_delay_stop'
]
parentData
=
self
.
o_api
.
search_read
(
'res.partner'
,
cond
,
fields
,
1
)
parentData
=
self
.
o_api
.
search_read
(
'res.partner'
,
cond
,
fields
,
1
)
if
parentData
:
if
parentData
:
partnerData
[
'parent_create_date'
]
=
parentData
[
0
][
'create_date'
]
partnerData
[
'parent_create_date'
]
=
parentData
[
0
][
'create_date'
]
partnerData
[
'parent_makeups_to_do'
]
=
parentData
[
0
][
'makeups_to_do'
]
partnerData
[
'parent_date_delay_stop'
]
=
parentData
[
0
][
'date_delay_stop'
]
if
partnerData
[
'shift_type'
]
==
'standard'
:
if
partnerData
[
'shift_type'
]
==
'standard'
:
partnerData
[
'in_ftop_team'
]
=
False
partnerData
[
'in_ftop_team'
]
=
False
...
...
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