PARAF-457: Displayed who refused a session and his comment in the state help tooltip - #46
PARAF-457: Displayed who refused a session and his comment in the state help tooltip#46chris-adam wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThe PR adds ChangesSession state tooltip
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (7)
CHANGES.rstsrc/imio/esign/browser/table.pysrc/imio/esign/browser/templates/macros.ptsrc/imio/esign/browser/views.pysrc/imio/esign/tests/test_browser_views.pysrc/imio/esign/tests/test_utils.pysrc/imio/esign/utils.py
| 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} | ||
| ) |
There was a problem hiding this comment.
🎯 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/esignRepository: 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/testsRepository: 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/esignRepository: 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
doneRepository: 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
doneRepository: 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")
PYRepository: 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.
Coverage Report for CI Build 31598216702Coverage increased (+0.06%) to 86.012%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Je ne suis pas encore complètement convaincu que l'UI pour afficher le refus soit la meilleure
Summary by CodeRabbit
New Features
Bug Fixes
Documentation