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
e41b046c
Commit
e41b046c
authored
Nov 17, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shifts history instead of points history
parent
b5c9d742
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
67 additions
and
79 deletions
+67
-79
config_lacagette.py
coops_configurations/config_lacagette.py
+1
-1
models.py
members_space/models.py
+32
-32
members-space-my-shifts.css
members_space/static/css/members-space-my-shifts.css
+12
-2
members-space-shifts-exchange.css
members_space/static/css/members-space-shifts-exchange.css
+1
-0
members-space-my-shifts.js
members_space/static/js/members-space-my-shifts.js
+15
-38
urls.py
members_space/urls.py
+1
-1
views.py
members_space/views.py
+4
-4
config.md
outils/config.md
+1
-1
No files found.
coops_configurations/config_lacagette.py
View file @
e41b046c
...
...
@@ -134,5 +134,5 @@ BLOCK_SERVICE_EXCHANGE_24H_BEFORE = True
ORDERS_HELPER_METABASE_URL
=
"url_meta_base"
# New members space
USE_NEW_MEMBERS_SPACE
=
True
START_DATE_FOR_
POIN
TS_HISTORY
=
"2018-01-01"
START_DATE_FOR_
SHIF
TS_HISTORY
=
"2018-01-01"
members_space/models.py
View file @
e41b046c
...
...
@@ -11,38 +11,37 @@ class CagetteMembersSpace(models.Model):
"""Init with odoo id."""
self
.
o_api
=
OdooAPI
()
def
get_points_history
(
self
,
partner_id
,
limit
,
offset
,
date_from
,
shift_type
):
""" Get partner points history with related shift registration if needed """
cond
=
[
[
'partner_id'
,
'='
,
partner_id
],
[
'type'
,
'='
,
shift_type
],
[
'create_date'
,
'>'
,
date_from
],
[
'point_qty'
,
'!='
,
0
]
]
f
=
[
'create_date'
,
'create_uid'
,
'shift_id'
,
'name'
,
'point_qty'
]
res
=
self
.
o_api
.
search_read
(
'shift.counter.event'
,
cond
,
f
,
limit
=
limit
,
offset
=
offset
,
order
=
'create_date DESC'
)
# Get related data from shift.registration
shift_ids
=
[]
for
item
in
res
:
item
[
'is_late'
]
=
False
# So every item has the attribute
if
item
[
'shift_id'
]
is
not
False
:
shift_ids
.
append
(
item
[
'shift_id'
][
0
])
cond
=
[[
'shift_id'
,
'in'
,
shift_ids
]]
f
=
[
'is_late'
,
'shift_id'
]
res_shift_registration
=
self
.
o_api
.
search_read
(
'shift.registration'
,
cond
,
f
)
for
registration_item
in
res_shift_registration
:
for
shift_counter_item
in
res
:
if
(
shift_counter_item
[
'shift_id'
]
is
not
False
and
shift_counter_item
[
'shift_id'
]
==
registration_item
[
'shift_id'
]):
shift_counter_item
[
'is_late'
]
=
registration_item
[
'is_late'
]
break
def
get_shifts_history
(
self
,
partner_id
,
limit
,
offset
,
date_from
):
""" Get partner shifts history """
res
=
{}
today
=
str
(
datetime
.
date
.
today
())
try
:
cond
=
[
[
'partner_id'
,
'='
,
partner_id
],
[
'create_date'
,
'>'
,
date_from
],
[
'date_begin'
,
'<'
,
today
],
[
'state'
,
'!='
,
'draft'
],
[
'state'
,
'!='
,
'open'
],
[
'state'
,
'!='
,
'waiting'
],
[
'state'
,
'!='
,
'replaced'
],
[
'state'
,
'!='
,
'replacing'
],
]
f
=
[
'create_date'
,
'shift_id'
,
'name'
,
'state'
,
'is_late'
,
'is_makeup'
]
marshal_none_error
=
'cannot marshal None unless allow_none is enabled'
try
:
res
=
self
.
o_api
.
search_read
(
'shift.registration'
,
cond
,
f
,
limit
=
limit
,
offset
=
offset
,
order
=
'create_date DESC'
)
except
Exception
as
e
:
if
not
(
marshal_none_error
in
str
(
e
)):
res
[
'error'
]
=
repr
(
e
)
coop_logger
.
error
(
res
[
'error'
]
+
' :
%
s'
,
str
(
payment_id
))
else
:
res
=
[]
except
Exception
as
e
:
print
(
str
(
e
))
return
res
\ No newline at end of file
members_space/static/css/members-space-my-shifts.css
View file @
e41b046c
...
...
@@ -35,7 +35,14 @@ table.dataTable.dtr-inline.collapsed>tbody>tr>th:first-child:before {
background-color
:
white
;
font-weight
:
bold
;
border
:
none
;
font-size
:
2rem
;
font-size
:
1.6rem
;
height
:
16px
;
width
:
16px
;
border-radius
:
2em
;
}
@media
screen
{
}
table
.dataTable.dtr-inline.collapsed
>
tbody
>
tr
.parent
>
td
:first-child:before
,
table
.dataTable.dtr-inline.collapsed
>
tbody
>
tr
.parent
>
th
:first-child:before
{
...
...
@@ -43,7 +50,10 @@ table.dataTable.dtr-inline.collapsed>tbody>tr.parent>th:first-child:before {
background-color
:
white
;
font-weight
:
bold
;
border
:
none
;
font-size
:
2rem
;
;
font-size
:
1.6rem
;
height
:
16px
;
width
:
16px
;
border-radius
:
2em
;
}
.loading-more-history
{
...
...
members_space/static/css/members-space-shifts-exchange.css
View file @
e41b046c
...
...
@@ -54,6 +54,7 @@
display
:
none
;
width
:
min-content
;
max-width
:
100%
;
white-space
:
nowrap
;
}
@media
screen
and
(
max-width
:
768px
)
{
...
...
members_space/static/js/members-space-my-shifts.js
View file @
e41b046c
...
...
@@ -9,13 +9,12 @@ function load_partner_history(offset = 0) {
return
new
Promise
((
resolve
)
=>
{
$
.
ajax
({
type
:
'GET'
,
url
:
"/members_space/get_
poin
ts_history"
,
url
:
"/members_space/get_
shif
ts_history"
,
data
:
{
partner_id
:
partner_data
.
concerned_partner_id
,
verif_token
:
partner_data
.
verif_token
,
limit
:
history_items_limit
,
offset
:
offset
,
shift_type
:
(
partner_data
.
in_ftop_team
===
"True"
)
?
"ftop"
:
"standard"
},
dataType
:
"json"
,
traditional
:
true
,
...
...
@@ -49,36 +48,18 @@ function prepare_server_data(data) {
res
=
[];
for
(
history_item
of
data
)
{
// Date formating
let
datetime_shift_start
=
new
Date
(
history_item
.
create_date
);
let
f_date_shift_start
=
datetime_shift_start
.
toLocaleDateString
(
"fr-fr"
,
date_options
);
f_date_shift_start
=
f_date_shift_start
.
charAt
(
0
).
toUpperCase
()
+
f_date_shift_start
.
slice
(
1
);
history_item
.
movement_date
=
f_date_shift_start
+
" - "
+
datetime_shift_start
.
toLocaleTimeString
(
"fr-fr"
,
time_options
);
// Text replacements
history_item
.
name
=
(
history_item
.
name
===
"Clôturer le service"
)
?
"Décompte 28j"
:
history_item
.
name
;
//Clôlturer le service
history_item
.
name
=
(
history_item
.
name
===
"Rattrapage"
)
?
"Absence"
:
history_item
.
name
;
if
(
history_item
.
name
===
"Clôturer le service"
||
history_item
.
name
===
"Clôlturer le service"
)
{
history_item
.
name
=
"Décompte 28j"
;
}
else
if
(
history_item
.
name
===
"Rattrapage"
)
{
history_item
.
name
=
"Absence"
;
}
else
if
(
history_item
.
name
===
"Présent"
&&
history_item
.
is_late
!=
false
)
{
history_item
.
name
=
"Retard"
;
}
history_item
.
created_by
=
history_item
.
create_uid
[
1
];
if
(
history_item
.
created_by
===
"Administrator"
)
{
history_item
.
created_by
=
"Administrateur"
;
}
else
if
(
history_item
.
created_by
===
"api"
)
{
history_item
.
created_by
=
"Système"
;
history_item
.
details
=
''
;
if
(
history_item
.
state
===
'excused'
||
history_item
.
state
===
'absent'
)
{
history_item
.
details
=
"Absent"
;
}
else
if
(
history_item
.
state
===
'done'
&&
history_item
.
is_late
!=
false
)
{
history_item
.
details
=
"Présent (En Retard)"
;
}
else
if
(
history_item
.
state
===
'done'
)
{
history_item
.
details
=
"Présent"
;
}
else
if
(
history_item
.
state
===
'cancel'
)
{
history_item
.
details
=
"Annulé"
;
}
history_item
.
shift_name
=
(
history_item
.
shift_id
===
false
)
?
''
:
history_item
.
shift_id
[
1
];
// if Present && is_late -> Absent
}
return
data
;
...
...
@@ -99,18 +80,14 @@ function init_history() {
data
:
partner_history
,
columns
:
[
{
data
:
"movement_date"
,
title
:
`Date`
,
responsivePriority
:
1
},
{
data
:
"shift_name"
,
title
:
"Service"
title
:
"<spans class='dt-body-center'>Service</span>"
,
width
:
"60%"
,
},
{
data
:
"
name
"
,
data
:
"
details
"
,
title
:
"Détails"
,
responsivePriority
:
3
className
:
"tablet-l desktop"
}
],
iDisplayLength
:
-
1
,
...
...
@@ -126,7 +103,7 @@ function init_history() {
$
(
row
).
addClass
(
'row_partner_ok'
);
}
else
if
(
cell
.
text
()
===
"Retard"
)
{
$
(
row
).
addClass
(
'row_partner_late'
);
}
else
if
(
cell
.
text
()
===
"Absen
ce
"
)
{
}
else
if
(
cell
.
text
()
===
"Absen
t
"
)
{
$
(
row
).
addClass
(
'row_partner_absent'
);
}
}
...
...
members_space/urls.py
View file @
e41b046c
...
...
@@ -10,6 +10,6 @@ urlpatterns = [
url
(
r'^my_shifts$'
,
views
.
my_shifts
),
url
(
r'^shifts_exchange$'
,
views
.
shifts_exchange
),
url
(
r'^no_content$'
,
views
.
no_content
),
url
(
r'^get_
points_history$'
,
views
.
get_poin
ts_history
),
url
(
r'^get_
shifts_history$'
,
views
.
get_shif
ts_history
),
url
(
'/*$'
,
views
.
index
),
]
members_space/views.py
View file @
e41b046c
...
...
@@ -165,7 +165,7 @@ def no_content(request):
}
return
HttpResponse
(
template
.
render
(
context
,
request
))
def
get_
poin
ts_history
(
request
):
def
get_
shif
ts_history
(
request
):
res
=
{}
partner_id
=
int
(
request
.
GET
.
get
(
'partner_id'
))
...
...
@@ -173,8 +173,7 @@ def get_points_history(request):
limit
=
int
(
request
.
GET
.
get
(
'limit'
))
offset
=
int
(
request
.
GET
.
get
(
'offset'
))
shift_type
=
request
.
GET
.
get
(
'shift_type'
)
date_from
=
getattr
(
settings
,
'START_DATE_FOR_POINTS_HISTORY'
,
'2018-01-01'
)
res
[
"data"
]
=
m
.
get_points_history
(
partner_id
,
limit
,
offset
,
date_from
,
shift_type
)
date_from
=
getattr
(
settings
,
'START_DATE_FOR_SHIFTS_HISTORY'
,
'2018-01-01'
)
res
[
"data"
]
=
m
.
get_shifts_history
(
partner_id
,
limit
,
offset
,
date_from
)
return
JsonResponse
(
res
)
\ No newline at end of file
outils/config.md
View file @
e41b046c
...
...
@@ -352,7 +352,7 @@
Should be set to False by default if parameter not set
-
START_DATE_FOR_
POIN
TS_HISTORY = "2018-01-01"
-
START_DATE_FOR_
SHIF
TS_HISTORY = "2018-01-01"
...
...
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