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
ca48841c
Commit
ca48841c
authored
6 years ago
by
Erwan Rouchet
Browse files
Options
Downloads
Patches
Plain Diff
Update SearchResultSerializer
parent
da4160ac
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!18
Transcription search
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/documents/serializers.py
+16
-40
16 additions, 40 deletions
src/documents/serializers.py
with
16 additions
and
40 deletions
src/documents/serializers.py
+
16
−
40
View file @
ca48841c
...
...
@@ -34,28 +34,6 @@ class TranscriptionSerializer(serializers.ModelSerializer):
)
class
SearchResultSerializer
(
serializers
.
ModelSerializer
):
"""
Link between objects & their search indexation
"""
zones
=
ZoneSerializer
(
many
=
True
)
parents
=
serializers
.
SerializerMethodField
()
class
Meta
:
model
=
Transcription
fields
=
(
'
id
'
,
'
text
'
,
'
line
'
,
'
score
'
,
'
zones
'
,
'
parents
'
,
)
def
get_parents
(
self
,
obj
):
return
DocumentLightSerializer
(
Document
.
objects
.
get_ascending
(
obj
.
id
),
many
=
True
).
data
class
DocumentLightSerializer
(
serializers
.
ModelSerializer
):
"""
Serialises a Document
...
...
@@ -90,39 +68,37 @@ class PageLightSerializer(serializers.ModelSerializer):
)
class
Page
Serializer
(
serializers
.
ModelSerializer
):
class
Document
Serializer
(
serializers
.
ModelSerializer
):
"""
Serialises a
Page, for search results
Fully
Serialises a
document
"""
indexes
=
SearchResultSerializer
(
many
=
True
)
page_type
=
EnumField
()
direction
=
EnumField
()
images
=
ImageSerializer
(
many
=
True
)
type
=
EnumField
()
class
Meta
:
model
=
Page
model
=
Document
fields
=
(
'
id
'
,
'
page_type
'
,
'
nb
'
,
'
direction
'
,
'
images
'
,
'
indexes
'
,
'
type
'
,
'
name
'
,
)
class
Documen
tSerializer
(
serializers
.
ModelSerializer
):
class
SearchResul
tSerializer
(
serializers
.
ModelSerializer
):
"""
Fully Serialises a document
Link between objects & their search indexation
"""
type
=
EnumField
()
zones
=
ZoneSerializer
(
many
=
True
)
parents
=
DocumentLightSerializer
(
source
=
'
parent_docs
'
,
many
=
True
)
class
Meta
:
model
=
Document
model
=
Transcription
fields
=
(
'
id
'
,
'
type
'
,
'
name
'
,
'
text
'
,
'
line
'
,
'
score
'
,
'
zones
'
,
'
parents
'
,
)
...
...
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