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
5848c742
Commit
5848c742
authored
May 10, 2023
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#4394 : allow comitee members to add as many points they want
parent
644261a5
Pipeline
#2726
passed with stage
in 2 minutes 16 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
13 deletions
+22
-13
models.py
shifts/models.py
+22
-13
No files found.
shifts/models.py
View file @
5848c742
...
...
@@ -870,27 +870,36 @@ class CagetteServices(models.Model):
if
(
len
(
shift_templ_res
)
>
0
and
shift_templ_res
[
0
][
'shift_template_id'
][
0
]
==
committees_shift_id
):
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
:
mininum_seconds_interval
=
getattr
(
settings
,
'MINIMUM_SECONDS_BETWEEN_TWO_COMITEE_VALIDATION'
,
3600
*
24
)
evt_name
=
getattr
(
settings
,
'ENTRANCE_ADD_PT_EVENT_NAME'
,
'Validation service comité'
)
if
mininum_seconds_interval
>
0
:
# A constraint has been set to prevent from adding more than 1 point during a time period
# Let's find out when was the last time a "special point" has been addes
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
)
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
()
>=
mininum_seconds_interval
:
ok_for_adding_pt
=
True
else
:
ok_for_adding_pt
=
True
else
:
# mininum_seconds_interval is 0 : Point can we added without any condition
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
"
res
[
'error'
]
=
"
Un point a déjà été ajouté il y a trop récemment.
"
else
:
res
[
'error'
]
=
"
Unallowed coop
"
res
[
'error'
]
=
"
Vous n'avez pas le droit d'ajouter un point.
"
else
:
res
[
'error'
]
=
"Unregistred coop"
else
:
...
...
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