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
fce0c3b0
Commit
fce0c3b0
authored
4 years ago
by
Samuel GAIST
Browse files
Options
Downloads
Patches
Plain Diff
[common][utils] Move annotation method here
parent
feb50ae4
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/common/utils.py
+20
-0
20 additions, 0 deletions
beat/web/common/utils.py
with
20 additions
and
0 deletions
beat/web/common/utils.py
+
20
−
0
View file @
fce0c3b0
...
...
@@ -31,6 +31,8 @@ Reusable help functions
from
django.core.exceptions
import
ValidationError
from
django.utils.encoding
import
force_text
from
django.utils
import
six
from
django.db.models
import
CharField
,
Value
as
V
from
django.db.models.functions
import
Concat
from
docutils
import
utils
from
docutils.nodes
import
Element
...
...
@@ -145,3 +147,21 @@ def py3_cmp(a, b):
https://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons
"""
return
(
a
>
b
)
-
(
a
<
b
)
def
annotate_full_name
(
db_class
):
"""
Annotate a query with the asset full name so that it can be more easily
filtered.
"""
return
db_class
.
objects
.
annotate
(
full_name
=
Concat
(
"
author__username
"
,
V
(
"
/
"
),
"
name
"
,
V
(
"
/
"
),
"
version
"
,
output_field
=
CharField
(),
)
)
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