Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AKPlanning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Felix Blanke
AKPlanning
Commits
440709c1
Commit
440709c1
authored
1 year ago
by
Felix Blanke
Browse files
Options
Downloads
Patches
Plain Diff
Introduce availabilits class method is_event_covered
parent
e2884a59
No related branches found
No related tags found
2 merge requests
!4
Draft: Add object import from JSON data
,
!3
Merge into fork's `main` branch
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
AKModel/availability/models.py
+8
-0
8 additions, 0 deletions
AKModel/availability/models.py
AKModel/models.py
+3
-14
3 additions, 14 deletions
AKModel/models.py
with
11 additions
and
14 deletions
AKModel/availability/models.py
+
8
−
0
View file @
440709c1
...
@@ -267,6 +267,14 @@ class Availability(models.Model):
...
@@ -267,6 +267,14 @@ class Availability(models.Model):
return
Availability
(
start
=
timeframe_start
,
end
=
timeframe_end
,
event
=
event
,
person
=
person
,
return
Availability
(
start
=
timeframe_start
,
end
=
timeframe_end
,
event
=
event
,
person
=
person
,
room
=
room
,
ak
=
ak
,
ak_category
=
ak_category
)
room
=
room
,
ak
=
ak
,
ak_category
=
ak_category
)
@classmethod
def
is_event_covered
(
cls
,
event
,
availabilities
:
List
[
'
Availability
'
])
->
bool
:
# NOTE: Cannot use `Availability.with_event_length` as its end is the
# event end + 1 day
full_event
=
Availability
(
event
=
event
,
start
=
event
.
start
,
end
=
event
.
end
)
avail_union
=
Availability
.
union
(
availabilities
)
return
not
avail_union
or
avail_union
[
0
].
contains
(
full_event
)
class
Meta
:
class
Meta
:
verbose_name
=
_
(
'
Availability
'
)
verbose_name
=
_
(
'
Availability
'
)
verbose_name_plural
=
_
(
'
Availabilities
'
)
verbose_name_plural
=
_
(
'
Availabilities
'
)
...
...
This diff is collapsed.
Click to expand it.
AKModel/models.py
+
3
−
14
View file @
440709c1
...
@@ -579,12 +579,7 @@ class Room(models.Model):
...
@@ -579,12 +579,7 @@ class Room(models.Model):
# check if room is available for the whole event
# check if room is available for the whole event
# -> no time constraint needs to be introduced
# -> no time constraint needs to be introduced
if
Availability
.
is_event_covered
(
self
.
event
,
self
.
availabilities
.
all
()):
# NOTE: Cannot use `Availability.with_event_length` as its end is the
# event end + 1 day
full_event
=
Availability
(
event
=
self
.
event
,
start
=
self
.
event
.
start
,
end
=
self
.
event
.
end
)
avail_union
=
Availability
.
union
(
self
.
availabilities
.
all
())
if
not
avail_union
or
avail_union
[
0
].
contains
(
full_event
):
time_constraints
=
[]
time_constraints
=
[]
else
:
else
:
time_constraints
=
[
f
"
availability-room-
{
self
.
pk
}
"
]
time_constraints
=
[
f
"
availability-room-
{
self
.
pk
}
"
]
...
@@ -703,19 +698,13 @@ class AKSlot(models.Model):
...
@@ -703,19 +698,13 @@ class AKSlot(models.Model):
# check if ak resp. owner is available for the whole event
# check if ak resp. owner is available for the whole event
# -> no time constraint needs to be introduced
# -> no time constraint needs to be introduced
# NOTE: Cannot use `Availability.with_event_length` as its end is the
if
Availability
.
is_event_covered
(
self
.
event
,
self
.
ak
.
availabilities
.
all
()):
# event end + 1 day
full_event
=
Availability
(
event
=
self
.
event
,
start
=
self
.
event
.
start
,
end
=
self
.
event
.
end
)
ak_avail_union
=
Availability
.
union
(
self
.
ak
.
availabilities
.
all
())
if
not
ak_avail_union
or
ak_avail_union
[
0
].
contains
(
full_event
):
ak_time_constraints
=
[]
ak_time_constraints
=
[]
else
:
else
:
ak_time_constraints
=
[
f
"
availability-ak-
{
self
.
ak
.
pk
}
"
]
ak_time_constraints
=
[
f
"
availability-ak-
{
self
.
ak
.
pk
}
"
]
def
_owner_time_constraints
(
owner
:
AKOwner
):
def
_owner_time_constraints
(
owner
:
AKOwner
):
owner_avail_union
=
Availability
.
union
(
owner
.
availabilities
.
all
())
if
Availability
.
is_event_covered
(
self
.
event
,
owner
.
availabilities
.
all
()):
if
not
owner_avail_union
or
owner_avail_union
[
0
].
contains
(
full_event
):
return
[]
return
[]
else
:
else
:
return
[
f
"
availability-person-
{
owner
.
pk
}
"
]
return
[
f
"
availability-person-
{
owner
.
pk
}
"
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment