Skip to content

Commit 3bbeccc

Browse files
authored
Fix: Preserve list notes when resolving redirects (internetarchive#11122)
* Fix: Preserve list notes when resolving redirects When list items are redirects, the notes were being lost during redirect resolution in get_seeds() method. This fix preserves the original notes by creating an AnnotatedSeed with both the resolved document and the original notes. Fixes internetarchive#9600
1 parent 0c83515 commit 3bbeccc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

openlibrary/core/lists/model.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,16 @@ def get_seeds(self, sort=False, resolve_redirects=False) -> list['Seed']:
319319
seed = Seed.from_db(self, s)
320320
max_checks = 10
321321
while resolve_redirects and seed.type == 'redirect' and max_checks:
322-
seed = Seed(self, web.ctx.site.get(seed.document.location))
322+
# Preserve notes when resolving redirects
323+
original_notes = seed.notes
324+
resolved_document = web.ctx.site.get(seed.document.location)
325+
if original_notes:
326+
# Create AnnotatedSeed with both resolved document and original notes
327+
seed = Seed(
328+
self, {'thing': resolved_document, 'notes': original_notes}
329+
)
330+
else:
331+
seed = Seed(self, resolved_document)
323332
max_checks -= 1
324333
seeds.append(seed)
325334

0 commit comments

Comments
 (0)