Skip to content
Snippets Groups Projects
Commit a82c6093 authored by Felix Blanke's avatar Felix Blanke
Browse files

Address linter findings

parent 43457e5d
No related branches found
No related tags found
1 merge request!285[Tmp] JSON export filtering
...@@ -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)
......
...@@ -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,
) )
......
...@@ -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))
) )
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment