special-gallery: scope image prev/next/back to special galleries; add tests
This commit is contained in:
@@ -115,11 +115,22 @@ def render_image(request, path_text, full_path, special=None):
|
||||
next_url = None
|
||||
if prev_path is not None:
|
||||
rel = prev_path.relative_to(settings.GALLERY_ROOT)
|
||||
prev_url = gallery_url(rel, False, query_state)
|
||||
# When viewing from a special gallery, route prev/next through the
|
||||
# special gallery URL so subsequent navigation preserves the special
|
||||
# gallery context. Otherwise use the normal gallery URL for the file.
|
||||
if special is not None:
|
||||
rel_text = str(rel).replace("\\", "/")
|
||||
prev_url = append_query(f"/gallery/{special}/{rel_text}/", query_state)
|
||||
else:
|
||||
prev_url = gallery_url(rel, False, query_state)
|
||||
|
||||
if next_path is not None:
|
||||
rel = next_path.relative_to(settings.GALLERY_ROOT)
|
||||
next_url = gallery_url(rel, False, query_state)
|
||||
if special is not None:
|
||||
rel_text = str(rel).replace("\\", "/")
|
||||
next_url = append_query(f"/gallery/{special}/{rel_text}/", query_state)
|
||||
else:
|
||||
next_url = gallery_url(rel, False, query_state)
|
||||
|
||||
# Back (directory) and Home (root) links and thumbnails
|
||||
dir_rel = None
|
||||
|
||||
Reference in New Issue
Block a user