Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mediatek
Base de données Mediatek
Commits
ae0d1a08
Verified
Commit
ae0d1a08
authored
Oct 26, 2021
by
ynerant
Browse files
Fix borrowable autocompletion
parent
1e6e033c
Pipeline
#9514
failed with stages
in 1 minute and 13 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
media/models.py
View file @
ae0d1a08
...
...
@@ -44,7 +44,17 @@ class Borrowable(PolymorphicModel):
)
def
__str__
(
self
):
return
self
.
title
obj
=
self
if
obj
.
__class__
==
Borrowable
:
# Get true object instance, useful for autocompletion
obj
=
Borrowable
.
objects
.
get
(
pk
=
obj
.
pk
)
title
=
obj
.
title
if
hasattr
(
obj
,
'subtitle'
):
subtitle
=
obj
.
subtitle
if
subtitle
:
title
=
f
"
{
title
}
:
{
subtitle
}
"
return
title
class
Meta
:
verbose_name
=
_
(
'borrowable'
)
...
...
@@ -99,12 +109,6 @@ class Book(Medium):
null
=
True
,
)
def
__str__
(
self
):
if
self
.
subtitle
:
return
"{} : {}"
.
format
(
self
.
title
,
self
.
subtitle
)
else
:
return
self
.
title
class
Meta
:
verbose_name
=
_
(
"book"
)
verbose_name_plural
=
_
(
"books"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment