Skip to content

PARAF-457: Displayed who refused a session and his comment in the state help tooltip - #46

Open
chris-adam wants to merge 1 commit into
mainfrom
PARAF-457/display_refused_reason
Open

PARAF-457: Displayed who refused a session and his comment in the state help tooltip#46
chris-adam wants to merge 1 commit into
mainfrom
PARAF-457/display_refused_reason

Conversation

@chris-adam

@chris-adam chris-adam commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Je ne suis pas encore complètement convaincu que l'UI pour afficher le refus soit la meilleure

image

Summary by CodeRabbit

  • New Features

    • Session state tooltips now provide clearer details about who refused a session and include their optional comment.
    • Signer identification falls back to email when a full name is unavailable.
  • Bug Fixes

    • Improved handling of empty, unknown, draft, and invalid session states in displayed state information.
  • Documentation

    • Updated the unreleased changelog with the enhanced refusal details.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds get_state_title to include refusal details in translated session state titles. Browser tables, templates, and viewlets use the new utility. Tests cover refusal data and fallback behavior. The changelog documents the tooltip update.

Changes

Session state tooltip

Layer / File(s) Summary
State title utility and coverage
src/imio/esign/utils.py, src/imio/esign/tests/test_utils.py
The new get_state_title utility translates the session state and adds the refusing signer and optional comment. Tests cover empty, unknown, draft, refusal, invalid feedback, and email fallback cases.
Tooltip consumer integration
src/imio/esign/browser/table.py, src/imio/esign/browser/templates/macros.pt, src/imio/esign/browser/views.py, src/imio/esign/tests/test_browser_views.py, CHANGES.rst
Session state tooltips now use the full session title in the table, template, and viewlet. The changelog records the new refusal details.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • IMIO/imio.esign#9: Both changes update session-state tooltip rendering in the same browser components.
  • IMIO/imio.esign#38: Both changes modify session-state tooltip rendering in browser/table.py.

Suggested reviewers: sgeulette

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: displaying the refusing signer and comment in the session state tooltip.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch PARAF-457/display_refused_reason

Comment @coderabbitai help to get the list of available commands.

@chris-adam
chris-adam requested a review from gbastien August 12, 2026 12:49

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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 `@src/imio/esign/utils.py`:
- Around line 677-684: Update both refusal-detail branches in utils.py around
the title-building logic to use translate with the raw msgids, context=request,
domain="imio.esign", and the existing fullname/reason mappings instead of the
portal-language _ helper; add catalog entries for both messages. In
test_utils.py lines 473-509, cover both refusal branches using a non-English
request language and assert the translated results.
🪄 Autofix

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: 7c4f4f59-8cfb-4625-8db7-d5f0047276f0

📥 Commits

Reviewing files that changed from the base of the PR and between 64c4a53 and 37bfeb6.

📒 Files selected for processing (7)
  • CHANGES.rst
  • src/imio/esign/browser/table.py
  • src/imio/esign/browser/templates/macros.pt
  • src/imio/esign/browser/views.py
  • src/imio/esign/tests/test_browser_views.py
  • src/imio/esign/tests/test_utils.py
  • src/imio/esign/utils.py

Comment thread src/imio/esign/utils.py
Comment on lines +677 to +684
title += u"\n\n" + _(
u'${fullname} refused the session with comment: "${reason}"',
mapping={"fullname": fullname, "reason": reason},
)
elif fullname:
title += u"\n\n" + _(
u"${fullname} refused the session without comment", mapping={"fullname": fullname}
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 4 'def get_state_title|refused the session|translate\(' src/imio/esign/utils.py
fd -e po . | xargs -r rg -n -F 'refused the session'

Repository: IMIO/imio.esign

Length of output: 1262


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- translation imports and helper definitions ---'
sed -n '1,90p' src/imio/esign/utils.py
rg -n -C 5 'def translate|from .* import .*translate|import .*translate|gettext|domain=' src
printf '%s\n' '--- catalogs and relevant message IDs ---'
fd -i -e po -e pot . | sort
while IFS= read -r file; do
  rg -n -C 3 'refused|session|fullname|reason' "$file" || true
done < <(fd -i -e po -e pot .)
printf '%s\n' '--- locale-related test setup and translation tests ---'
rg -n -C 5 'setLanguage|LANGUAGE|locale|translate|get_state_title|I18N|translation' src/imio/esign/tests src/imio/esign

Repository: IMIO/imio.esign

Length of output: 3911


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- exact call graph for get_state_title ---'
ast-grep outline src/imio/esign/utils.py
ast-grep run --pattern $'def get_state_title($$$):
  $$$' --lang python src/imio/esign/utils.py --debug-query=pattern || true
sed -n '640,690p' src/imio/esign/utils.py
printf '%s\n' '--- all message-factory and translation call sites ---'
rg -n -C 4 'MessageFactory|messageFactory|_\(|translate\(' src/imio/esign
printf '%s\n' '--- test class setup and existing locale tests ---'
sed -n '1,130p' src/imio/esign/tests/test_utils.py
sed -n '430,525p' src/imio/esign/tests/test_utils.py
rg -n -C 8 'setLanguage|set_language|preferred_languages|LANGUAGE|translation|translate' src/imio/esign/tests

Repository: IMIO/imio.esign

Length of output: 50371


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- package files related to translations ---'
git ls-files | rg -i '(^|/)(locales?|i18n|translations?)(/|$)|\.(po|pot|mo)$' || true
printf '%s\n' '--- translation registrations and catalog declarations ---'
rg -n -C 6 'imio\.esign|ITranslationDomain|TranslationDomain|locales|i18n|configure\.zCML|language' setup.py setup.cfg pyproject.toml buildout.cfg src 2>/dev/null | head -500 || true
printf '%s\n' '--- focused tests and fixture setup ---'
sed -n '1,120p' src/imio/esign/tests/test_utils.py
sed -n '450,525p' src/imio/esign/tests/test_utils.py
printf '%s\n' '--- current-language helper usage ---'
rg -n -C 3 'get_current_language|set.*language|Language|preferred_languages|portal_language' src/imio/esign

Repository: IMIO/imio.esign

Length of output: 17287


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- exact package initializer ---'
cat -n src/imio/esign/__init__.py
printf '%s\n' '--- translation-related tracked files ---'
git ls-files | rg -i '(^|/)(locales?|i18n|translations?)(/|$)|\.(po|pot|mo)$' || true
printf '%s\n' '--- test base class and request language configuration ---'
rg -n -C 8 'class .*Test|setUp|request|language|locale' src/imio/esign/tests/test_utils.py | head -400
printf '%s\n' '--- setup metadata ---'
for f in setup.py setup.cfg pyproject.toml configure.zcml src/imio/esign/configure.zcml; do
  if [ -f "$f" ]; then
    echo "### $f"
    rg -n -C 5 'i18n|locale|domain|package|include' "$f" || true
  fi
done

Repository: IMIO/imio.esign

Length of output: 12278


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- imports in translation-sensitive modules ---'
sed -n '1,35p' src/imio/esign/browser/table.py
sed -n '1,25p' src/imio/esign/browser/views.py
printf '%s\n' '--- all tracked files with translation catalogs or French strings ---'
git ls-files | while IFS= read -r f; do
  case "$f" in
    *.po|*.pot|*.mo|*locales*|*locale*|*i18n*) printf '%s\n' "$f";;
  esac
done
rg -n -i -C 2 'refused|refusé|session without|session avec|signer refused' . \
  -g '!*.pyc' -g '!*.js' -g '!*.css' -g '!*.html' | head -300 || true
printf '%s\n' '--- setup and package configuration files ---'
git ls-files | rg '(^|/)(setup\.py|setup\.cfg|pyproject\.toml|configure\.zcml|metadata\.json|buildout\.cfg)$' | while IFS= read -r f; do
  echo "### $f"
  rg -n -C 4 'i18n|locale|domain|package|include' "$f" || true
done

Repository: IMIO/imio.esign

Length of output: 25243


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- refusal-detail catalog entries ---'
for f in src/imio/esign/locales/imio.esign.pot src/imio/esign/locales/fr/LC_MESSAGES/imio.esign.po src/imio/esign/locales/en/LC_MESSAGES/imio.esign.po; do
  echo "### $f"
  rg -n -C 4 'refused the session|without comment|with comment|cancelled because' "$f" || true
done
printf '%s\n' '--- test base language behavior ---'
fd -i 'base.py' src/imio/esign/tests --exec sh -c 'echo "### $1"; cat -n "$1"' sh {}
printf '%s\n' '--- locale update behavior ---'
cat -n src/imio/esign/locales/update.sh
printf '%s\n' '--- static behavioral verifier ---'
python3 - <<'PY'
from pathlib import Path
import re

source = Path("src/imio/esign/utils.py").read_text(encoding="utf-8")
init = Path("src/imio/esign/__init__.py").read_text(encoding="utf-8")
messages = [
    '${fullname} refused the session with comment: "${reason}"',
    '${fullname} refused the session without comment',
]
print("utils imports _tr as _:", "from imio.esign import _tr as _" in source)
print("utils imports zope.i18n.translate:", "from zope.i18n import translate" in source)
print("_tr uses portal current language:", "api.portal.get_current_language()" in init)
for msg in messages:
    print("\nMSGID:", msg)
    for path in Path("src/imio/esign/locales").rglob("*.po"):
        text = path.read_text(encoding="utf-8")
        present = re.search(r'^msgid "' + re.escape(msg) + r'"$', text, re.MULTILINE)
        print(path, "present" if present else "absent")
PY

Repository: IMIO/imio.esign

Length of output: 3776


Translate both refusal-detail messages with the request context.

_ is _tr, which uses the portal language instead of request. Both refusal msgids are absent from the catalogs, so the suffix remains English in the French UI. Pass both raw msgids to translate(..., context=request, domain="imio.esign", mapping=...), add their catalog entries, and test both refusal branches with a non-English request language.

📍 Affects 2 files
  • src/imio/esign/utils.py#L677-L684 (this comment)
  • src/imio/esign/tests/test_utils.py#L473-L509
🤖 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 `@src/imio/esign/utils.py` around lines 677 - 684, Update both refusal-detail
branches in utils.py around the title-building logic to use translate with the
raw msgids, context=request, domain="imio.esign", and the existing
fullname/reason mappings instead of the portal-language _ helper; add catalog
entries for both messages. In test_utils.py lines 473-509, cover both refusal
branches using a non-English request language and assert the translated results.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 31598216702

Coverage increased (+0.06%) to 86.012%

Details

  • Coverage increased (+0.06%) from the base build.
  • Patch coverage: 1 uncovered change across 1 file (17 of 18 lines covered, 94.44%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
src/imio/esign/browser/views.py 3 2 66.67%
Total (3 files) 18 17 94.44%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1344
Covered Lines: 1156
Line Coverage: 86.01%
Coverage Strength: 0.86 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants