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
Iterations
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
KIF
AKPlanning
Commits
a82c6093
Commit
a82c6093
authored
2 months ago
by
Felix Blanke
Browse files
Options
Downloads
Patches
Plain Diff
Address linter findings
parent
43457e5d
No related branches found
No related tags found
1 merge request
!285
[Tmp] JSON export filtering
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
AKSolverInterface/forms.py
+5
-6
5 additions, 6 deletions
AKSolverInterface/forms.py
AKSolverInterface/serializers.py
+8
-0
8 additions, 0 deletions
AKSolverInterface/serializers.py
AKSolverInterface/views.py
+6
-4
6 additions, 4 deletions
AKSolverInterface/views.py
with
19 additions
and
10 deletions
AKSolverInterface/forms.py
+
5
−
6
View file @
a82c6093
...
@@ -5,9 +5,6 @@ from django.core.exceptions import ValidationError
...
@@ -5,9 +5,6 @@ from django.core.exceptions import ValidationError
from
django.utils.translation
import
gettext_lazy
as
_
from
django.utils.translation
import
gettext_lazy
as
_
from
jsonschema.exceptions
import
best_match
from
jsonschema.exceptions
import
best_match
from
AKModel.availability.forms
import
AvailabilitiesFormMixin
from
AKModel.availability.models
import
Availability
from
AKModel.availability.serializers
import
AvailabilityFormSerializer
from
AKModel.forms
import
AdminIntermediateForm
from
AKModel.forms
import
AdminIntermediateForm
from
AKModel.models
import
AKCategory
,
AKTrack
,
AKType
,
Event
from
AKModel.models
import
AKCategory
,
AKTrack
,
AKType
,
Event
from
AKSolverInterface.utils
import
construct_schema_validator
from
AKSolverInterface.utils
import
construct_schema_validator
...
@@ -16,13 +13,15 @@ from AKSolverInterface.utils import construct_schema_validator
...
@@ -16,13 +13,15 @@ from AKSolverInterface.utils import construct_schema_validator
class
JSONExportControlForm
(
forms
.
Form
):
class
JSONExportControlForm
(
forms
.
Form
):
"""
Form to control what objects are exported to the solver.
"""
"""
Form to control what objects are exported to the solver.
"""
# TODO: Add checkbox whether wishes should be exported?
# TODO: Filter rooms out by property?
# TODO: Filter rooms out by property?
# TODO: Add room availability filter?
# TODO: Add room availability filter?
export_scheduled_aks_as_fixed
=
forms
.
BooleanField
(
export_scheduled_aks_as_fixed
=
forms
.
BooleanField
(
label
=
_
(
"
Fixate all scheduled slots for the solver
"
),
label
=
_
(
"
Fixate all scheduled slots for the solver
"
),
help_text
=
_
(
"
In the solver export, all assigned times and room to slots are handled as if the slot were fixed.
"
),
help_text
=
_
(
"
In the solver export, all assigned times and room to slots are handled
"
"
as if the slot were fixed.
"
),
required
=
False
,
required
=
False
,
)
)
export_categories
=
forms
.
ModelMultipleChoiceField
(
export_categories
=
forms
.
ModelMultipleChoiceField
(
...
@@ -71,7 +70,7 @@ class JSONExportControlForm(forms.Form):
...
@@ -71,7 +70,7 @@ class JSONExportControlForm(forms.Form):
if
not
self
.
fields
[
field_name
].
queryset
.
exists
():
if
not
self
.
fields
[
field_name
].
queryset
.
exists
():
self
.
fields
.
pop
(
field_name
)
self
.
fields
.
pop
(
field_name
)
for
field_name
in
{
"
export_categories
"
,
"
export_tracks
"
,
"
export_types
"
}
:
for
field_name
in
[
"
export_categories
"
,
"
export_tracks
"
,
"
export_types
"
]
:
_set_queryset
(
field_name
)
_set_queryset
(
field_name
)
...
...
This diff is collapsed.
Click to expand it.
AKSolverInterface/serializers.py
+
8
−
0
View file @
a82c6093
...
@@ -143,11 +143,19 @@ class ExportAKSlotSerializer(serializers.ModelSerializer):
...
@@ -143,11 +143,19 @@ class ExportAKSlotSerializer(serializers.ModelSerializer):
self
.
export_scheduled_aks_as_fixed
=
export_scheduled_aks_as_fixed
self
.
export_scheduled_aks_as_fixed
=
export_scheduled_aks_as_fixed
def
get_room_constraints
(
self
,
slot
:
AKSlot
):
def
get_room_constraints
(
self
,
slot
:
AKSlot
):
"""
Get serialized representation for room_constraints.
Used to pass `export_scheduled_aks_as_fixed` to AKSlot
'
s function.
"""
return
slot
.
get_room_constraints
(
return
slot
.
get_room_constraints
(
export_scheduled_aks_as_fixed
=
self
.
export_scheduled_aks_as_fixed
,
export_scheduled_aks_as_fixed
=
self
.
export_scheduled_aks_as_fixed
,
)
)
def
get_time_constraints
(
self
,
slot
:
AKSlot
):
def
get_time_constraints
(
self
,
slot
:
AKSlot
):
"""
Get serialized representation for time_constraints.
Used to pass `export_scheduled_aks_as_fixed` to AKSlot
'
s function.
"""
return
slot
.
get_time_constraints
(
return
slot
.
get_time_constraints
(
export_scheduled_aks_as_fixed
=
self
.
export_scheduled_aks_as_fixed
,
export_scheduled_aks_as_fixed
=
self
.
export_scheduled_aks_as_fixed
,
)
)
...
...
This diff is collapsed.
Click to expand it.
AKSolverInterface/views.py
+
6
−
4
View file @
a82c6093
...
@@ -5,7 +5,7 @@ from django.db.models import Q
...
@@ -5,7 +5,7 @@ from django.db.models import Q
from
django.db.models.query
import
QuerySet
from
django.db.models.query
import
QuerySet
from
django.shortcuts
import
redirect
from
django.shortcuts
import
redirect
from
django.utils.translation
import
gettext_lazy
as
_
from
django.utils.translation
import
gettext_lazy
as
_
from
django.views.generic
import
DetailView
,
FormView
from
django.views.generic
import
FormView
from
AKModel.metaviews.admin
import
(
from
AKModel.metaviews.admin
import
(
AdminViewMixin
,
AdminViewMixin
,
...
@@ -30,7 +30,6 @@ class AKJSONExportView(EventSlugMixin, AdminViewMixin, FormView):
...
@@ -30,7 +30,6 @@ class AKJSONExportView(EventSlugMixin, AdminViewMixin, FormView):
def
get_template_names
(
self
):
def
get_template_names
(
self
):
if
self
.
request
.
method
==
"
POST
"
:
if
self
.
request
.
method
==
"
POST
"
:
return
[
"
admin/AKSolverInterface/ak_json_export.html
"
]
return
[
"
admin/AKSolverInterface/ak_json_export.html
"
]
else
:
return
[
"
admin/AKSolverInterface/ak_json_export_control.html
"
]
return
[
"
admin/AKSolverInterface/ak_json_export_control.html
"
]
def
get_form_kwargs
(
self
):
def
get_form_kwargs
(
self
):
...
@@ -45,7 +44,10 @@ class AKJSONExportView(EventSlugMixin, AdminViewMixin, FormView):
...
@@ -45,7 +44,10 @@ class AKJSONExportView(EventSlugMixin, AdminViewMixin, FormView):
if
aks_without_slot
.
exists
():
if
aks_without_slot
.
exists
():
messages
.
warning
(
messages
.
warning
(
self
.
request
,
self
.
request
,
_
(
"
The following AKs have no slot assigned to them and are therefore not exported: {aks_list}
"
).
format
(
_
(
"
The following AKs have no slot assigned to them
"
"
and are therefore not exported: {aks_list}
"
).
format
(
aks_list
=
"
,
"
.
join
(
aks_without_slot
.
values_list
(
"
name
"
,
flat
=
True
))
aks_list
=
"
,
"
.
join
(
aks_without_slot
.
values_list
(
"
name
"
,
flat
=
True
))
)
)
)
)
...
...
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