Skip to content
Snippets Groups Projects

Refactor update creation api

Merged Samuel GAIST requested to merge refactor_update_creation_api into master
All threads resolved!
1 file
+ 20
0
Compare changes
  • Side-by-side
  • Inline
+ 20
0
@@ -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(),
)
)
Loading