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
8c96561a
Commit
8c96561a
authored
Nov 23, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Plain Diff
update history logic
parents
2bafd38f
c1ebf735
Pipeline
#1540
passed with stage
in 1 minute 32 seconds
Changes
6
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
28 deletions
+82
-28
config_lacagette.py
coops_configurations/config_lacagette.py
+1
-1
models.py
members_space/models.py
+58
-7
members-space-my-shifts.css
members_space/static/css/members-space-my-shifts.css
+4
-6
members-space-my-shifts.js
members_space/static/js/members-space-my-shifts.js
+18
-2
views.py
members_space/views.py
+0
-11
config.md
outils/config.md
+1
-1
No files found.
coops_configurations/config_lacagette.py
View file @
8c96561a
...
...
@@ -125,7 +125,7 @@ RECEPTION_PB = "Ici, vous pouvez signaler toute anomalie lors d'une réception,
Merci d'indiquer un maximum d'informations, le nom du produit et son code barre.
\
Dans le cas de produits déteriorés, merci d'envoyer une photo avec votre téléphone à [Adresse_email]"
AMNISTIE_DATE
=
"2021-11-24"
AMNISTIE_DATE
=
"2021-11-24
00:00:00
"
# display or not column "Autres" in reception process
DISPLAY_COL_AUTRES
=
False
...
...
members_space/models.py
View file @
8c96561a
...
...
@@ -13,7 +13,8 @@ class CagetteMembersSpace(models.Model):
def
get_shifts_history
(
self
,
partner_id
,
limit
,
offset
,
date_from
):
""" Get partner shifts history """
res
=
{}
res
=
[]
paginated_res
=
[]
today
=
str
(
datetime
.
date
.
today
())
try
:
...
...
@@ -27,21 +28,70 @@ class CagetteMembersSpace(models.Model):
[
'state'
,
'!='
,
'replaced'
],
[
'state'
,
'!='
,
'replacing'
],
]
f
=
[
'create_date'
,
'shift_id'
,
'name'
,
'state'
,
'is_late'
,
'is_makeup'
]
f
=
[
'create_date'
,
'
date_begin'
,
'
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
=
'date_begin DESC'
)
res
=
self
.
o_api
.
search_read
(
'shift.registration'
,
cond
,
f
,
order
=
'date_begin DESC'
)
except
Exception
as
e
:
if
not
(
marshal_none_error
in
str
(
e
)):
res
[
'error'
]
=
repr
(
e
)
coop_logger
.
error
(
re
s
[
'error'
]
+
' :
%
s'
,
str
(
payment
_id
))
print
(
str
(
e
)
)
coop_logger
.
error
(
re
pr
(
e
)
+
' :
%
s'
,
str
(
partner
_id
))
else
:
res
=
[]
# Get committees shifts
committees_shifts_name
=
getattr
(
settings
,
'ENTRANCE_ADD_PT_EVENT_NAME'
,
'Validation service comité'
)
cond
=
[
[
'partner_id'
,
'='
,
partner_id
],
[
'name'
,
'='
,
committees_shifts_name
]
]
f
=
[
'create_date'
]
try
:
res_committees_shifts
=
self
.
o_api
.
search_read
(
'shift.counter.event'
,
cond
,
f
,
order
=
'create_date DESC'
)
for
committee_shift
in
res_committees_shifts
:
item
=
{
"create_date"
:
committee_shift
[
"create_date"
],
"date_begin"
:
committee_shift
[
"create_date"
],
"shift_id"
:
False
,
"name"
:
"Services des comités"
,
"state"
:
"done"
,
"is_late"
:
False
,
"is_makeup"
:
False
,
}
res
.
append
(
item
)
except
Exception
as
e
:
if
not
(
marshal_none_error
in
str
(
e
)):
print
(
str
(
e
))
coop_logger
.
error
(
repr
(
e
)
+
' :
%
s'
,
str
(
partner_id
))
else
:
res
=
res
+
[]
# Add amnesty line
is_amnesty
=
getattr
(
settings
,
'AMNISTIE_DATE'
,
'false'
)
company_code
=
getattr
(
settings
,
'COMPANY_CODE'
,
''
)
if
is_amnesty
and
company_code
==
"lacagette"
:
amnesty
=
{}
amnesty
[
'is_amnesty'
]
=
True
amnesty
[
'create_date'
]
=
is_amnesty
amnesty
[
'date_begin'
]
=
is_amnesty
amnesty
[
'shift_name'
]
=
'Amnistie'
amnesty
[
'state'
]
=
''
res
.
append
(
amnesty
)
# ordering
res
.
sort
(
key
=
lambda
x
:
datetime
.
datetime
.
strptime
(
x
[
'date_begin'
],
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
),
reverse
=
True
)
# Paginate
end_index
=
offset
+
limit
paginated_res
=
res
[
offset
:
end_index
]
except
Exception
as
e
:
print
(
str
(
e
))
return
res
return
paginated_
res
\ No newline at end of file
members_space/static/css/members-space-my-shifts.css
View file @
8c96561a
...
...
@@ -84,12 +84,9 @@ table.dataTable.display tbody tr.row_partner_absent {
background-color
:
#ff847b
;
}
table
.dataTable.display
tbody
tr
.row_partner_amnistie
{
background-color
:
black
;
background-color
:
rgb
(
78
,
78
,
78
)
;
color
:
white
;
}
table
.dataTable.display
tbody
tr
.row_partner_ok
td
,
table
.dataTable.display
tbody
tr
.row_partner_late
td
,
table
.dataTable.display
tbody
tr
.row_partner_absent
td
{
border-bottom
:
1px
solid
rgb
(
100
,
99
,
99
);
border-top
:
1px
solid
rgb
(
100
,
99
,
99
);
table
.dataTable.display
tbody
tr
td
{
border-top
:
1px
solid
rgb
(
119
,
119
,
119
);
}
\ No newline at end of file
members_space/static/js/members-space-my-shifts.js
View file @
8c96561a
...
...
@@ -48,6 +48,23 @@ function prepare_server_data(data) {
res
=
[];
for
(
history_item
of
data
)
{
if
(
history_item
.
is_amnesty
!==
undefined
)
{
let
shift_datetime
=
new
Date
(
history_item
.
date_begin
);
let
str_shift_datetime
=
`
${(
"0"
+
shift_datetime
.
getDate
()).
slice
(
-
2
)}
/
${(
"0"
+
(
shift_datetime
.
getMonth
()
+
1
)).
slice
(
-
2
)}
/
${
shift_datetime
.
getFullYear
()}
`
history_item
.
shift_name
=
`
${
history_item
.
shift_name
}
du
${
str_shift_datetime
}
`
}
else
{
history_item
.
shift_name
=
(
history_item
.
shift_id
===
false
)
?
''
:
history_item
.
shift_id
[
1
];
if
(
history_item
.
name
===
"Services des comités"
)
{
let
shift_datetime
=
new
Date
(
history_item
.
date_begin
);
let
str_shift_datetime
=
`
${(
"0"
+
shift_datetime
.
getDate
()).
slice
(
-
2
)}
/
${(
"0"
+
(
shift_datetime
.
getMonth
()
+
1
)).
slice
(
-
2
)}
/
${
shift_datetime
.
getFullYear
()}
`
str_shift_datetime
=
str_shift_datetime
+
" "
+
shift_datetime
.
toLocaleTimeString
(
"fr-fr"
,
time_options
);
history_item
.
shift_name
=
`Services des comités
${
str_shift_datetime
}
`
}
}
history_item
.
details
=
''
;
if
(
history_item
.
state
===
'excused'
||
history_item
.
state
===
'absent'
)
{
history_item
.
details
=
"Absent"
;
...
...
@@ -58,7 +75,6 @@ function prepare_server_data(data) {
}
else
if
(
history_item
.
state
===
'cancel'
)
{
history_item
.
details
=
"Annulé"
;
}
if
(
history_item
.
is_amnesty
==
undefined
)
history_item
.
shift_name
=
(
history_item
.
shift_id
===
false
)
?
''
:
history_item
.
shift_id
[
1
];
}
return
data
;
...
...
@@ -104,7 +120,7 @@ function init_history() {
$
(
row
).
addClass
(
'row_partner_late'
);
}
else
if
(
cell
.
text
()
===
"Absent"
)
{
$
(
row
).
addClass
(
'row_partner_absent'
);
}
else
if
(
cell
.
text
()
===
"Amnistie"
)
{
}
else
if
(
cell
.
text
()
.
includes
(
"Amnistie"
)
)
{
$
(
row
).
addClass
(
'row_partner_amnistie'
);
}
}
...
...
members_space/views.py
View file @
8c96561a
...
...
@@ -222,14 +222,4 @@ def get_shifts_history(request):
date_from
=
getattr
(
settings
,
'START_DATE_FOR_SHIFTS_HISTORY'
,
'2018-01-01'
)
res
[
"data"
]
=
m
.
get_shifts_history
(
partner_id
,
limit
,
offset
,
date_from
)
is_amnesty
=
getattr
(
settings
,
'AMNISTIE_DATE'
,
'false'
)
company_code
=
getattr
(
settings
,
'COMPANY_CODE'
,
''
)
if
is_amnesty
and
company_code
==
"lacagette"
:
amnesty
=
{}
amnesty
[
'is_amnesty'
]
=
True
amnesty
[
'create_date'
]
=
is_amnesty
amnesty
[
'shift_name'
]
=
'Amnistie'
amnesty
[
'state'
]
=
''
res
[
"data"
]
.
append
(
amnesty
)
return
JsonResponse
(
res
)
\ No newline at end of file
outils/config.md
View file @
8c96561a
...
...
@@ -311,7 +311,7 @@
Message shown to people when they connect to the Member Space
-
AMNISTIE_DATE = "2021-11-24"
-
AMNISTIE_DATE = "2021-11-24
00:00:00
"
In members_space history display a special activity about amnistie
### Reception
...
...
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