Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
beat
beat.web
Commits
9fde021a
Commit
9fde021a
authored
4 years ago
by
Samuel GAIST
Browse files
Options
Downloads
Patches
Plain Diff
[toolchains][serializers] Pre-commit cleanup
parent
96dfc0ed
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!327
Refactor update creation api
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/web/toolchains/serializers.py
+16
-9
16 additions, 9 deletions
beat/web/toolchains/serializers.py
with
16 additions
and
9 deletions
beat/web/toolchains/serializers.py
+
16
−
9
View file @
9fde021a
...
@@ -36,7 +36,7 @@ from .models import Toolchain
...
@@ -36,7 +36,7 @@ from .models import Toolchain
import
beat.core.toolchain
import
beat.core.toolchain
#----------------------------------------------------------
#
----------------------------------------------------------
class
ToolchainCreationSerializer
(
ContributionCreationSerializer
):
class
ToolchainCreationSerializer
(
ContributionCreationSerializer
):
...
@@ -45,7 +45,7 @@ class ToolchainCreationSerializer(ContributionCreationSerializer):
...
@@ -45,7 +45,7 @@ class ToolchainCreationSerializer(ContributionCreationSerializer):
beat_core_class
=
beat
.
core
.
toolchain
beat_core_class
=
beat
.
core
.
toolchain
#----------------------------------------------------------
#
----------------------------------------------------------
class
ToolchainSerializer
(
ContributionSerializer
):
class
ToolchainSerializer
(
ContributionSerializer
):
...
@@ -58,25 +58,32 @@ class ToolchainSerializer(ContributionSerializer):
...
@@ -58,25 +58,32 @@ class ToolchainSerializer(ContributionSerializer):
model
=
Toolchain
model
=
Toolchain
def
get_referencing_experiments
(
self
,
obj
):
def
get_referencing_experiments
(
self
,
obj
):
user
=
self
.
context
.
get
(
'
user
'
)
user
=
self
.
context
.
get
(
"
user
"
)
experiments
=
obj
.
experiments
.
for_user
(
user
,
True
).
order_by
(
'
-creation_date
'
)
experiments
=
obj
.
experiments
.
for_user
(
user
,
True
).
order_by
(
"
-creation_date
"
)
serializer
=
ExperimentSerializer
(
experiments
,
many
=
True
)
serializer
=
ExperimentSerializer
(
experiments
,
many
=
True
)
referencing_experiments
=
serializer
.
data
referencing_experiments
=
serializer
.
data
# Put the pending experiments first
# Put the pending experiments first
ordered_result
=
filter
(
lambda
x
:
x
[
'
creation_date
'
]
is
None
,
referencing_experiments
)
ordered_result
=
filter
(
ordered_result
+=
filter
(
lambda
x
:
x
[
'
creation_date
'
]
is
not
None
,
referencing_experiments
)
lambda
x
:
x
[
"
creation_date
"
]
is
None
,
referencing_experiments
)
ordered_result
+=
filter
(
lambda
x
:
x
[
"
creation_date
"
]
is
not
None
,
referencing_experiments
)
return
ordered_result
return
ordered_result
def
get_new_experiment_url
(
self
,
obj
):
def
get_new_experiment_url
(
self
,
obj
):
return
obj
.
get_new_experiment_url
()
return
obj
.
get_new_experiment_url
()
#----------------------------------------------------------
# ----------------------------------------------------------
class
FullToolchainSerializer
(
ToolchainSerializer
):
class
FullToolchainSerializer
(
ToolchainSerializer
):
class
Meta
(
ToolchainSerializer
.
Meta
):
class
Meta
(
ToolchainSerializer
.
Meta
):
default_fields
=
ToolchainSerializer
.
Meta
.
default_fields
+
ToolchainSerializer
.
Meta
.
extra_fields
default_fields
=
(
ToolchainSerializer
.
Meta
.
default_fields
+
ToolchainSerializer
.
Meta
.
extra_fields
)
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