Looks at the version and adds machine_comment required for showing "View MARC" link.
(v: HasGetKeyRevision)
| 535 | |
| 536 | @public |
| 537 | def process_version(v: HasGetKeyRevision) -> HasGetKeyRevision: |
| 538 | """Looks at the version and adds machine_comment required for showing "View MARC" link.""" |
| 539 | comments = [ |
| 540 | "found a matching marc record", |
| 541 | "add publisher and source", |
| 542 | ] |
| 543 | |
| 544 | if v.key.startswith("/books/") and not v.get("machine_comment"): |
| 545 | thing = v.get("thing") or web.ctx.site.get(v.key, v.revision) |
| 546 | if (thing.source_records and v.revision == 1) or ( |
| 547 | v.comment and v.comment.lower() in comments # type: ignore [attr-defined] |
| 548 | ): |
| 549 | marc = thing.source_records[-1] |
| 550 | if marc.startswith("marc:"): |
| 551 | v.machine_comment = marc[len("marc:") :] # type: ignore [attr-defined] |
| 552 | else: |
| 553 | v.machine_comment = marc # type: ignore [attr-defined] |
| 554 | return v |
| 555 | |
| 556 | |
| 557 | @public |