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
7816e987
Commit
7816e987
authored
5 years ago
by
Erwan Rouchet
Committed by
Bastien Abadie
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Prevent AttributeError when indexing hidden elements without zones
parent
b0d26503
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/project/elastic.py
+4
-1
4 additions, 1 deletion
arkindex/project/elastic.py
arkindex/project/tests/test_elastic.py
+24
-1
24 additions, 1 deletion
arkindex/project/tests/test_elastic.py
with
28 additions
and
2 deletions
arkindex/project/elastic.py
+
4
−
1
View file @
7816e987
...
...
@@ -109,7 +109,10 @@ class ESElement(Document):
def
from_model
(
cls
,
instance
):
from
arkindex.documents.models
import
Element
,
Transcription
hidden_children
=
Element
.
objects
.
get_descending
(
instance
.
id
).
filter
(
type__hidden
=
True
)
hidden_children
=
Element
\
.
objects
\
.
get_descending
(
instance
.
id
)
\
.
filter
(
type__hidden
=
True
,
zone__isnull
=
False
)
transcriptions
=
chain
(
instance
.
transcriptions
.
all
(),
*
[
...
...
This diff is collapsed.
Click to expand it.
arkindex/project/tests/test_elastic.py
+
24
−
1
View file @
7816e987
from
unittest.mock
import
patch
from
arkindex_common.enums
import
MetaType
from
arkindex_common.enums
import
MetaType
,
TranscriptionType
from
arkindex.project.tests
import
FixtureAPITestCase
from
arkindex.project.polygon
import
Polygon
from
arkindex.project.elastic
import
ESElement
from
arkindex.documents.models
import
DataSource
from
arkindex.documents.dates
import
DateType
,
InterpretedDate
...
...
@@ -43,3 +45,24 @@ class TestESDocuments(FixtureAPITestCase):
element
.
metadatas
.
create
(
type
=
MetaType
.
Reference
,
name
=
'
ref.
'
,
value
=
'
123ABC
'
)
es_document
=
ESElement
.
from_model
(
element
)
self
.
assertCountEqual
(
es_document
.
references
,
[
'
123abc
'
])
def
test_hidden_no_zone
(
self
):
"""
Ensure hidden elements without zones are ignored when indexing an element
'
s hidden children
"""
page
=
self
.
corpus
.
elements
.
get
(
name
=
'
Volume 1, page 1r
'
)
self
.
assertTrue
(
page
.
transcriptions
.
exists
())
surface
=
self
.
corpus
.
elements
.
create
(
type
=
self
.
corpus
.
types
.
get
(
slug
=
'
surface
'
),
name
=
'
/dev/null
'
,
zone
=
None
,
)
surface
.
add_parent
(
page
)
surface
.
transcriptions
.
create
(
type
=
TranscriptionType
.
Word
,
text
=
'
invisible transcription
'
,
zone
=
page
.
zone
.
image
.
zones
.
create
(
polygon
=
Polygon
.
from_coords
(
0
,
0
,
1
,
1
)),
source
=
DataSource
.
objects
.
get
(
slug
=
'
test
'
),
)
texts
=
[
tr
[
'
text
'
]
for
tr
in
ESElement
.
from_model
(
page
).
to_dict
()[
'
transcriptions
'
]]
self
.
assertNotIn
(
'
invisible transcription
'
,
texts
)
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