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
57c40a50
Commit
57c40a50
authored
2 months ago
by
Felix Blanke
Browse files
Options
Downloads
Patches
Plain Diff
Refactor
parent
7a1c5004
No related branches found
No related tags found
1 merge request
!12
Fix: export of fixed ak slots
Pipeline
#269716
passed
2 months ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
AKModel/models.py
+6
-4
6 additions, 4 deletions
AKModel/models.py
AKModel/views/ak.py
+30
-27
30 additions, 27 deletions
AKModel/views/ak.py
with
36 additions
and
31 deletions
AKModel/models.py
+
6
−
4
View file @
57c40a50
...
...
@@ -943,10 +943,12 @@ class AKSlot(models.Model):
# check if ak resp. owner is available for the whole event
# -> no time constraint needs to be introduced
if
not
self
.
fixed
and
Availability
.
is_event_covered
(
self
.
event
,
self
.
ak
.
availabilities
.
all
())
:
ak_time_constraints
=
[]
el
se
:
if
self
.
fixed
and
self
.
start
is
not
None
:
ak_time_constraints
=
[
f
"
fixed-akslot-
{
self
.
id
}
"
]
el
if
Availability
.
is_event_covered
(
self
.
event
,
self
.
ak
.
availabilities
.
all
())
:
ak_time_constraints
=
[
f
"
availability-ak-
{
self
.
ak
.
pk
}
"
]
else
:
ak_time_constraints
=
[]
def
_owner_time_constraints
(
owner
:
AKOwner
):
if
Availability
.
is_event_covered
(
self
.
event
,
owner
.
availabilities
.
all
()):
...
...
@@ -987,7 +989,7 @@ class AKSlot(models.Model):
category_constraints
=
AKCategory
.
create_category_constraints
([
self
.
ak
.
category
])
data
[
"
time_constraints
"
].
extend
(
category_constraints
)
if
self
.
room
is
not
None
and
self
.
fixed
:
if
self
.
fixed
and
self
.
room
is
not
None
:
data
[
"
room_constraints
"
].
append
(
f
"
availability-room-
{
self
.
room
.
pk
}
"
)
if
not
any
(
constr
.
startswith
(
"
proxy
"
)
for
constr
in
data
[
"
room_constraints
"
]):
...
...
This diff is collapsed.
Click to expand it.
AKModel/views/ak.py
+
30
−
27
View file @
57c40a50
...
...
@@ -59,13 +59,13 @@ class AKJSONExportView(AdminViewMixin, FilterByEventSlugMixin, ListView):
"""
Test if event is not covered by availabilities.
"""
return
not
Availability
.
is_event_covered
(
self
.
event
,
availabilities
)
def
_test_ak_fixed_in_slot
(
self
,
ak_
id
,
slot
:
Availability
,
ak_fixed
:
dict
)
->
bool
:
"""
Test if
AK defined by `ak_id` is fixed to happen during
slot.
"""
if
not
ak_
id
in
ak_fixed
:
def
_test_ak
slot
_fixed_in_
time
slot
(
self
,
ak_
slot
:
AKSlot
,
time
slot
:
Availability
)
->
bool
:
"""
Test if
an AKSlot is fixed to overlap a timeslot
slot.
"""
if
not
ak_
slot
.
fixed
or
ak_slot
.
start
is
None
:
return
False
fixed_
slot
=
Availability
(
self
.
event
,
start
=
ak_
fixed
[
ak_id
]
.
start
,
end
=
ak_
fixed
[
ak_id
]
.
end
)
return
fixed_
slot
.
overlaps
(
slot
,
strict
=
True
)
fixed_
avail
=
Availability
(
event
=
self
.
event
,
start
=
ak_
slot
.
start
,
end
=
ak_
slot
.
end
)
return
fixed_
avail
.
overlaps
(
time
slot
,
strict
=
True
)
def
_test_add_constraint
(
self
,
slot
:
Availability
,
availabilities
:
List
[
Availability
])
->
bool
:
"""
Test if object is not available for whole event and may happen during slot.
"""
...
...
@@ -74,6 +74,19 @@ class AKJSONExportView(AdminViewMixin, FilterByEventSlugMixin, ListView):
and
self
.
_test_slot_contained
(
slot
,
availabilities
)
)
def
_generate_time_constraints
(
self
,
avail_label
:
str
,
avail_dict
:
dict
,
timeslot_avail
:
Availability
,
prefix
:
str
=
"
availability
"
,
)
->
list
[
str
]:
return
[
f
"
{
prefix
}
-
{
avail_label
}
-
{
pk
}
"
for
pk
,
availabilities
in
avail_dict
.
items
()
if
self
.
_test_add_constraint
(
timeslot_avail
,
availabilities
)
]
def
get_queryset
(
self
):
return
super
().
get_queryset
().
order_by
(
"
ak__track
"
)
...
...
@@ -108,12 +121,6 @@ class AKJSONExportView(AdminViewMixin, FilterByEventSlugMixin, ListView):
for
person
in
AKOwner
.
objects
.
filter
(
event
=
self
.
event
)
}
ak_fixed
=
{
ak_id
:
values
.
get
()
for
ak_id
in
ak_availabilities
.
keys
()
if
(
values
:
=
AKSlot
.
objects
.
select_related
().
filter
(
ak__pk
=
ak_id
,
fixed
=
True
)).
exists
()
}
blocks
=
self
.
event
.
discretize_timeslots
(
slots_in_an_hour
=
SLOTS_IN_AN_HOUR
)
for
block
in
blocks
:
...
...
@@ -127,26 +134,22 @@ class AKJSONExportView(AdminViewMixin, FilterByEventSlugMixin, ListView):
time_constraints
.
append
(
"
resolution
"
)
# add fulfilled time constraints for all AKs that cannot happen during full event
time_constraints
.
extend
([
f
"
availability-ak-
{
ak_id
}
"
for
ak_id
,
availabilities
in
ak_availabilities
.
items
()
if
(
self
.
_test_add_constraint
(
timeslot
.
avail
,
availabilities
)
or
self
.
_test_ak_fixed_in_slot
(
ak_id
,
timeslot
.
avail
,
ak_fixed
)
)
])
self
.
_generate_time_constraints
(
"
ak
"
,
ak_availabilities
,
timeslot
.
avail
)
# add fulfilled time constraints for all persons that are not available for full event
time_constraints
.
extend
([
f
"
availability-person-
{
person_id
}
"
for
person_id
,
availabilities
in
person_availabilities
.
items
()
if
self
.
_test_add_constraint
(
timeslot
.
avail
,
availabilities
)
])
self
.
_generate_time_constraints
(
"
person
"
,
person_availabilities
,
timeslot
.
avail
)
# add fulfilled time constraints for all rooms that are not available for full event
self
.
_generate_time_constraints
(
"
room
"
,
room_availabilities
,
timeslot
.
avail
)
# add fulfilled time constraints for all AKSlots fixed to happen during timeslot
time_constraints
.
extend
([
f
"
availability-room-
{
room_id
}
"
for
room_id
,
availabilities
in
room_availabilities
.
items
()
if
self
.
_test_add_constraint
(
timeslot
.
avail
,
availabilities
)
f
"
fixed-akslot-
{
slot
.
id
}
"
for
slot
in
AKSlot
.
objects
.
filter
(
event
=
self
.
event
,
fixed
=
True
)
.
exclude
(
start__isnull
=
True
)
if
self
.
_test_akslot_fixed_in_timeslot
(
slot
,
timeslot
.
avail
)
])
time_constraints
.
extend
(
timeslot
.
constraints
)
current_block
.
append
({
...
...
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