Skip to content

Commit 2d381db

Browse files
committed
Fix error when requesting nearest content for resource on different level than the current location
Fixes #1288
1 parent 0e4be5d commit 2d381db

File tree

5 files changed

+5
-27
lines changed

5 files changed

+5
-27
lines changed

Tekst-API/tekst/routers/browse.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,7 @@ async def get_nearest_content_location(
344344
location_doc = await LocationDocument.get(location_id)
345345
if not location_doc:
346346
raise errors.E_404_LOCATION_NOT_FOUND
347-
if (
348-
location_doc.level != resource_doc.level
349-
or location_doc.text_id != resource_doc.text_id
350-
):
347+
if location_doc.text_id != resource_doc.text_id:
351348
raise errors.E_400_INVALID_REQUEST_DATA
352349

353350
target_loc = await search_nearest_content_location(

Tekst-API/tekst/search/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,8 @@ async def search_nearest_content_location(
676676
}
677677
}
678678
},
679-
{"term": {"level": resource.level}},
680-
]
679+
],
680+
"filter": [{"term": {"level": location.level}}],
681681
}
682682
}
683683
sort = {"position": {"order": "desc" if direction == "before" else "asc"}}

Tekst-API/tests/test_api_browse.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,22 +179,6 @@ async def test_get_nearest_content_position(
179179
)
180180
assert_status(404, resp)
181181

182-
# fail to get nearest content location with location
183-
# from different level then resource
184-
location_wrong_level = await LocationDocument.find_one(
185-
LocationDocument.level != resource.level,
186-
LocationDocument.text_id == resource.text_id,
187-
)
188-
resp = await test_client.get(
189-
"/browse/nearest-content-location",
190-
params={
191-
"res": res_id,
192-
"loc": str(location_wrong_level.id),
193-
"dir": "after",
194-
},
195-
)
196-
assert_status(400, resp)
197-
198182
# fail to get nearest content location with location
199183
# from different text then resource
200184
location_wrong_text = await LocationDocument.find_one(

Tekst-Web/src/components/browse/ContentContainerHeaderWidget.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defineProps<{
2121
:color="highlight && !toggled ? 'var(--error-color)' : undefined"
2222
:focusable="false"
2323
:title="!full ? title : undefined"
24-
:style="{ 'justify-content': full ? 'flex-start': undefined }"
24+
:style="{ 'justify-content': full ? 'flex-start' : undefined }"
2525
>
2626
<template #icon>
2727
<n-icon :component="iconComponent" />

Tekst-Web/src/components/resource/JumpToContentWidget.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ async function handleClick() {
4848

4949
<template>
5050
<content-container-header-widget
51-
v-if="
52-
resource.level === browse.level &&
53-
(resource.config.general.searchableAdv || resource.config.general.searchableQuick)
54-
"
51+
v-if="resource.config.general.searchableAdv || resource.config.general.searchableQuick"
5552
:full="full"
5653
:title="
5754
direction === 'before' ? $t('contents.tipBtnPrevChange') : $t('contents.tipBtnNextChange')

0 commit comments

Comments
 (0)