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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Felix Blanke
AKPlanning
Commits
ae5cfae3
Commit
ae5cfae3
authored
9 months ago
by
Felix Blanke
Browse files
Options
Downloads
Patches
Plain Diff
Do not introduce constraints if available for whole event
parent
ce126f70
No related branches found
No related tags found
1 merge request
!3
Merge into fork's `main` branch
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
AKModel/models.py
+34
-4
34 additions, 4 deletions
AKModel/models.py
with
34 additions
and
4 deletions
AKModel/models.py
+
34
−
4
View file @
ae5cfae3
...
...
@@ -575,6 +575,17 @@ class Room(models.Model):
return
self
.
title
def
as_json
(
self
)
->
str
:
from
AKModel.availability.models
import
Availability
# check if room is available for the whole event
# -> no time constraint needs to be introduced
full_event
=
Availability
(
event
=
self
.
event
,
start
=
self
.
event
.
start
,
end
=
self
.
event
.
end
)
avail_union
=
Availability
.
union
(
self
.
availabilities
.
all
())
if
len
(
avail_union
)
==
1
and
avail_union
[
0
].
contains
(
full_event
):
time_constraints
=
[]
else
:
time_constraints
=
[
f
"
availability-room-
{
self
.
pk
}
"
]
data
=
{
"
id
"
:
self
.
pk
,
"
info
"
:
{
...
...
@@ -583,7 +594,7 @@ class Room(models.Model):
"
capacity
"
:
self
.
capacity
,
"
fulfilled_room_constraints
"
:
[
constraint
.
name
for
constraint
in
self
.
properties
.
all
()],
"
time_constraints
"
:
[
f
"
availability-room-
{
self
.
pk
}
"
]
"
time_constraints
"
:
time_constraints
}
return
json
.
dumps
(
data
)
...
...
@@ -684,6 +695,25 @@ class AKSlot(models.Model):
super
().
save
(
force_insert
,
force_update
,
using
,
update_fields
)
def
as_json
(
self
)
->
str
:
from
AKModel.availability.models
import
Availability
# check if ak resp. owner is available for the whole event
# -> no time constraint needs to be introduced
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
=
[]
else
:
ak_time_constraints
=
[
f
"
availability-ak-
{
self
.
ak
.
pk
}
"
]
def
_owner_time_constraints
(
owner
:
AKOwner
):
owner_avail_union
=
Availability
.
union
(
owner
.
availabilities
.
all
())
if
not
owner_avail_union
or
owner_avail_union
[
0
].
contains
(
full_event
):
return
[]
else
:
return
[
f
"
availability-person-
{
owner
.
pk
}
"
]
data
=
{
"
id
"
:
self
.
pk
,
"
duration
"
:
int
(
self
.
duration
*
self
.
slots_in_an_hour
),
...
...
@@ -700,9 +730,9 @@ class AKSlot(models.Model):
},
}
data
[
"
time_constraints
"
].
app
end
(
f
"
availability-ak-
{
self
.
pk
}
"
)
data
[
"
time_constraints
"
]
+=
[
f
"
availability-person-
{
owner
.
pk
}
"
for
owner
in
self
.
ak
.
owners
.
all
()]
data
[
"
time_constraints
"
].
ext
end
(
ak_time_constraints
)
for
owner
in
self
.
ak
.
owners
.
all
():
data
[
"
time_constraints
"
].
extend
(
_owner_time_constraints
(
owner
))
return
json
.
dumps
(
data
)
...
...
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