Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
9216d0b3
Commit
9216d0b3
authored
6 years ago
by
Erwan Rouchet
Browse files
Options
Downloads
Patches
Plain Diff
Add display_name property
parent
d2718758
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!19
Page display name
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/documents/models.py
+23
-0
23 additions, 0 deletions
src/documents/models.py
with
23 additions
and
0 deletions
src/documents/models.py
+
23
−
0
View file @
9216d0b3
...
...
@@ -109,6 +109,29 @@ class Page(Document):
direction
=
EnumField
(
PageDirection
,
max_length
=
10
,
null
=
True
,
blank
=
True
)
objects
=
DocumentManager
()
@property
def
display_name
(
self
):
"""
Generate a pretty display name for a page.
If the folio parsing had failed, will return the raw folio.
"""
if
self
.
page_type
is
None
and
self
.
nb
is
None
and
self
.
direction
is
None
:
if
self
.
folio
.
strip
()
==
""
:
return
"
Unknown folio
"
return
self
.
folio
text
=
self
.
page_type
.
name
if
self
.
page_type
is
not
None
else
'
Page
'
if
self
.
nb
is
not
None
:
text
+=
'
no. {0:d}
'
.
format
(
self
.
nb
)
else
:
text
+=
'
, unnumbered
'
if
self
.
direction
is
not
None
:
text
+=
'
, {}
'
.
format
(
self
.
direction
.
value
)
return
text
.
capitalize
()
def
save
(
self
,
*
args
,
**
kwargs
):
# TODO: move this in Document through introspection
self
.
type
=
DocumentType
.
Page
...
...
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