Coverage for baibu/notifications/kinds.py: 100%
8 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-10-06 13:07 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-10-06 13:07 +0000
1"""Notification texts, translated when shown.
3A notification stores its kind and parameters, not finished text, so it is
4displayed in the reader's language. Feature apps register their kinds here;
5a notification of an unknown kind shows its stored ``title`` and ``body``.
6"""
8from dataclasses import dataclass
10from django.utils.translation import gettext_lazy as _
13@dataclass(frozen=True)
14class Kind:
15 title: str
16 body: str = ""
19KINDS: dict[str, Kind] = {
20 "submission_accepted": Kind(
21 title=_("Your contribution was accepted"),
22 body=_("Thank you. A reviewer checked your writing and accepted it."),
23 ),
24 "submission_rejected": Kind(
25 title=_("Your contribution was not accepted"),
26 body=_("A reviewer checked your writing and could not accept it this time."),
27 ),
28 "chat_report_reviewed": Kind(
29 title=_("Your report was reviewed"),
30 body=_("Thank you for reporting a reply. Someone on our team has looked at it."),
31 ),
32}
35def register(name: str, *, title, body="") -> None:
36 KINDS[name] = Kind(title=title, body=body)