Added action RecreateSession#119
Conversation
📝 WalkthroughWalkthroughThis PR adds a new "RecreateSession" action for e-sign sessions in mail approvals. It introduces new view classes for session recreation and removal, updates session display logic to show multiple badges, normalizes text formatting, and includes corresponding test coverage and localization updates. ChangesSession Recreation & Multi-Session Management
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
75f594a to
72d4d66
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@imio/dms/mail/browser/views.py`:
- Around line 581-582: Replace the blind append with logic that replaces the
recreated session id in approval.annot["session_ids"] instead of adding a
duplicate: locate the previous session id for this approval (the old id created
by the prior session—use the variable available in the recreate flow or derive
it from approval.annot["session_ids"]), replace that entry with new_id, and only
append new_id if no suitable old id is found; update code around
approval.annot["session_ids"] and new_id so the list length remains stable when
a single session is recreated.
In `@imio/dms/mail/tests/test_columns.py`:
- Around line 162-177: The assertions in test_columns.py hard-code session IDs
("0" and "1") while the tests create sessions using dynamic IDs (self.sid0,
self.sid1); update the expected HTML strings in the two asserts that call
self.column.renderCell(self.brain_b) and self.column.renderCell(self.brain_a) to
use format placeholders for the session id(s) and pass the appropriate variables
(use collection_uid and self.sid0 / self.sid1) so the anchor titles, link
fragment esign_session_id and visible badge text use the dynamic session IDs
instead of fixed numbers; locate the expectations near the calls to renderCell
for self.brain_b and self.brain_a to apply the change.
In `@imio/dms/mail/tests/test_views.py`:
- Around line 658-659: The test currently asserts recreated session titles by
positional indices (annot['sessions'][0] / [1]) which depends on global
numbering; change it to locate each session by its id using the existing old_id
and new_id variables and assert the title for that found session. Specifically,
iterate/search annot['sessions'] for the entry whose 'id' equals old_id and
assert its 'title' equals the expected string, and do the same for new_id, so
the checks rely on ids instead of fixed list positions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4d703205-4f2e-4f28-ae62-0eebfdf53eaa
📒 Files selected for processing (12)
CHANGES.rstimio/dms/mail/adapters.pyimio/dms/mail/browser/configure.zcmlimio/dms/mail/browser/views.pyimio/dms/mail/columns.pyimio/dms/mail/locales/en/LC_MESSAGES/imio.dms.mail.poimio/dms/mail/locales/fr/LC_MESSAGES/imio.dms.mail.poimio/dms/mail/locales/generated.potimio/dms/mail/locales/imio.dms.mail.potimio/dms/mail/tests/test_adapters.pyimio/dms/mail/tests/test_columns.pyimio/dms/mail/tests/test_views.py
| if new_id not in approval.annot["session_ids"]: | ||
| approval.annot["session_ids"].append(new_id) |
There was a problem hiding this comment.
Replace the recreated session id instead of appending it.
This keeps the old session id in approval.annot["session_ids"] and adds new_id, so the approval annotation drifts from the global eSign annotation after a recreate. Downstream, imio/dms/mail/columns.py Line 250 uses len(self.table._approval.session_ids) as the multi-session gate, so a mail recreated from a single session will still be treated as multi-session. Remove or replace the previous id here instead of blindly appending the new one.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@imio/dms/mail/browser/views.py` around lines 581 - 582, Replace the blind
append with logic that replaces the recreated session id in
approval.annot["session_ids"] instead of adding a duplicate: locate the previous
session id for this approval (the old id created by the prior session—use the
variable available in the recreate flow or derive it from
approval.annot["session_ids"]), replace that entry with new_id, and only append
new_id if no suitable old id is found; update code around
approval.annot["session_ids"] and new_id so the list length remains stable when
a single session is recreated.
There was a problem hiding this comment.
Yes, that's the point. We want to keep track of the old session as well. The global esign annotation is already managed my the view RecreateSessionView
There was a problem hiding this comment.
@chris-adam, understood — keeping the old session ID alongside the new one in approval.annot["session_ids"] is intentional for audit/history purposes, and the global eSign annotation lifecycle is already fully handled by the parent RecreateSessionView. I'll note this for future reviews.
✏️ Learnings added
Learnt from: chris-adam
Repo: IMIO/imio.dms.mail PR: 119
File: imio/dms/mail/browser/views.py:581-582
Timestamp: 2026-05-06T13:46:44.662Z
Learning: In `imio/dms/mail/browser/views.py`, `ImioRecreateSessionView.__call__` intentionally appends `new_id` to `approval.annot["session_ids"]` without removing the old session id. This is by design: the approval annotation keeps a full history of all session ids (old and new) for a given mail. The global eSign annotation (sessions dict, uids, etc.) is managed separately by the parent `RecreateSessionView.__call__`. Downstream code in `columns.py` that gates on `len(session_ids)` should therefore expect multiple ids per mail after a recreate.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
🧠 Learnings used
Learnt from: chris-adam
Repo: IMIO/imio.dms.mail PR: 106
File: imio/dms/mail/setuphandlers.py:535-537
Timestamp: 2026-03-24T10:40:48.436Z
Learning: In this repository’s `imio.dms.mail` package, `collective.quickupload` is pinned to version `1.11.1` via `versions-base.cfg`. At that pinned version, `IQuickUploadControlPanel` (from `collective.quickupload.browser.quickupload_settings`) includes the `set_sim_upload_limit` method, so review checks should not raise compatibility/API-existence concerns that would otherwise apply to newer major versions (e.g., collective.quickupload 2.x).
Summary by CodeRabbit
New Features
Bug Fixes
Tests