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
1773a790
Commit
1773a790
authored
1 month ago
by
Felix Blanke
Browse files
Options
Downloads
Patches
Plain Diff
Also filter dummy participants
parent
cad077a3
No related branches found
No related tags found
1 merge request
!285
[Tmp] JSON export filtering
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
AKSolverInterface/serializers.py
+14
-11
14 additions, 11 deletions
AKSolverInterface/serializers.py
with
14 additions
and
11 deletions
AKSolverInterface/serializers.py
+
14
−
11
View file @
1773a790
...
...
@@ -261,20 +261,11 @@ class ExportParticipantAndDummiesSerializer(serializers.BaseSerializer):
if
apps
.
is_installed
(
"
AKPreference
"
):
# local import to decouple
# pylint: disable=import-outside-toplevel
from
AKPreference.models
import
AKPreference
,
EventParticipant
from
AKPreference.models
import
EventParticipant
from
AKPreference.serializers
import
ExportParticipantSerializer
participants
=
_apply_filter_cb_to_queryset
(
self
.
filter_participants_cb
,
event
.
participants
)
real_participants
=
ExportParticipantSerializer
(
participants
,
many
=
True
).
data
if
self
.
slots_qs
is
not
None
:
slot_pks
=
set
(
self
.
slots_qs
.
values_list
(
"
id
"
,
flat
=
True
))
def
_filter_to_slots_qs
(
preference
:
dict
):
return
preference
[
"
ak_id
"
]
in
slot_pks
for
participant
in
real_participants
:
participant
[
"
preferences
"
]
=
list
(
filter
(
_filter_to_slots_qs
,
participant
[
"
preferences
"
])
)
if
EventParticipant
.
objects
.
exists
():
next_participant_pk
=
EventParticipant
.
objects
.
latest
(
"
pk
"
).
pk
+
1
...
...
@@ -297,7 +288,19 @@ class ExportParticipantAndDummiesSerializer(serializers.BaseSerializer):
]
}
dummies
.
append
(
new_participant_data
)
return
real_participants
+
dummies
all_participants
=
real_participants
+
dummies
if
self
.
slots_qs
is
not
None
:
slot_pks
=
set
(
self
.
slots_qs
.
values_list
(
"
id
"
,
flat
=
True
))
def
_filter_to_slots_qs
(
preference
:
dict
):
return
preference
[
"
ak_id
"
]
in
slot_pks
for
participant
in
all_participants
:
participant
[
"
preferences
"
]
=
list
(
filter
(
_filter_to_slots_qs
,
participant
[
"
preferences
"
])
)
return
all_participants
class
ExportEventInfoSerializer
(
serializers
.
ModelSerializer
):
...
...
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