Skip to content

feat(accounts): add default notification configuration to settings#19005

Open
michael-smt wants to merge 4 commits into
WeblateOrg:mainfrom
michael-smt:feat/setting-default-notifications
Open

feat(accounts): add default notification configuration to settings#19005
michael-smt wants to merge 4 commits into
WeblateOrg:mainfrom
michael-smt:feat/setting-default-notifications

Conversation

@michael-smt
Copy link
Copy Markdown
Contributor

Allows configuring the default notification configuration for newly created users in settings.

Implements some of #5155

@michael-smt
Copy link
Copy Markdown
Contributor Author

The configuration syntax is probably not ideal, and it might be a bit too much documentation 😉

@nijel
Copy link
Copy Markdown
Member

nijel commented Apr 14, 2026

I'm not really sure about this. This used to be an implementation detail, and we should probably think about this more before exposing it as configuration.

@argos-ci
Copy link
Copy Markdown

argos-ci Bot commented Apr 14, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 9 changed May 24, 2026, 7:38 AM

@michael-smt
Copy link
Copy Markdown
Contributor Author

I'm also not so sure about this 🙂 But I thought better something than nothing...

Maybe we could keep it undocumented, that would allow coming up with a better way to expose it as configuration later...

@michael-smt michael-smt force-pushed the feat/setting-default-notifications branch 2 times, most recently from eb801c8 to 0e956ec Compare April 15, 2026 12:03
@nijel nijel added this to the 2026.6 milestone May 14, 2026
@nijel
Copy link
Copy Markdown
Member

nijel commented May 14, 2026

I wasn't able to come to a better conclusion here, so let's make this happen for the next milestone.

The only thing I don't like here is manually written documentation for possible values, which is super easy to become outdated.

There are definitely better and more complex approaches to this, but we know we're going to change the notifications subsystem heavily in the not-so-distant future (at least to support web notifications), so let's not spend much time on something that will have to change anyway.

@nijel
Copy link
Copy Markdown
Member

nijel commented May 22, 2026

@michael-smt Can you rebase this on current main? If you have time to add documentation generation (see update-docs in docs/Makefile), that would be great.

@michael-smt
Copy link
Copy Markdown
Contributor Author

Yes, will do. Thanks for the pointer with the docs generation.

@michael-smt michael-smt force-pushed the feat/setting-default-notifications branch 2 times, most recently from f3ca2b5 to a7dda2e Compare May 22, 2026 14:52
@michael-smt michael-smt force-pushed the feat/setting-default-notifications branch from a6e0dea to eea1aa3 Compare May 22, 2026 19:19
Comment thread weblate/accounts/management/commands/list_notification_config.py Outdated
Comment thread weblate/accounts/management/commands/list_notification_config.py Outdated
Co-authored-by: Michal Čihař <michal@cihar.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new DEFAULT_NOTIFICATIONS setting (and Docker env var support) to configure which notification subscriptions are created for newly registered users, addressing part of #5155 (admin presets for notifications).

Changes:

  • Introduces DEFAULT_NOTIFICATIONS as a first-class setting (defaulted via WeblateAccountsConf) and uses it when auto-creating user subscriptions.
  • Adds Docker env var support (WEBLATE_DEFAULT_NOTIFICATIONS) plus an env parsing helper and tests.
  • Adds documentation + an autogenerated snippet and a management command to list available scopes/frequencies/handlers.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
weblate/utils/tests/test_environment.py Adds unit tests for the new env tuple parsing helper.
weblate/utils/environment.py Adds get_env_tuples_or_none helper for tuple-list env parsing.
weblate/settings_docker.py Allows overriding DEFAULT_NOTIFICATIONS via WEBLATE_DEFAULT_NOTIFICATIONS.
weblate/accounts/tests/test_notifications.py Updates tests to reference the new default-notifications source.
weblate/accounts/models.py Moves default notification presets into WeblateAccountsConf and applies settings.DEFAULT_NOTIFICATIONS on user creation.
weblate/accounts/management/commands/list_notification_config.py Adds doc-generator command to list notification scopes/frequencies/handlers.
weblate/accounts/data.py Removes old module containing defaults + creation helper (logic moved into models/settings).
docs/snippets/notifications-config.rst Adds autogenerated snippet content for notification scopes/frequencies/handlers.
docs/Makefile Updates update-docs target to regenerate the notifications snippet.
docs/changes.rst Mentions the new DEFAULT_NOTIFICATIONS setting in changelog.
docs/admin/management.rst Documents the new list_notification_config command.
docs/admin/install/docker.rst Documents WEBLATE_DEFAULT_NOTIFICATIONS env var with example.
docs/admin/config.rst Documents the new DEFAULT_NOTIFICATIONS setting and includes the generated snippet.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1469 to +1476
def create_default_notifications(user: User) -> None:
if settings.DEFAULT_NOTIFICATIONS:
for scope, frequency, notification in settings.DEFAULT_NOTIFICATIONS:
user.subscription_set.get_or_create(
scope=scope,
notification=notification,
defaults={"frequency": frequency},
)
Comment on lines +1486 to +1489
default_notifications = get_env_tuples_or_none("WEBLATE_DEFAULT_NOTIFICATIONS")
if default_notifications is not None:
DEFAULT_NOTIFICATIONS = default_notifications
del default_notifications
"""
parsed_list = get_env_list_or_none(name)
if parsed_list is not None:
if parsed_list == [""]:
Comment on lines +1064 to +1069
**Example:**

.. code-block:: yaml

environment:
WEBLATE_DEFAULT_NOTIFICATIONS: 0:1:MentionCommentNotificaton,10:1:LastAuthorCommentNotificaton

MAXIMAL_PASSWORD_LENGTH = defaults.DEFAULT_MAXIMAL_PASSWORD_LENGTH

DEFAULT_NOTIFICATIONS: ClassVar[
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The default value should go to the defaults module and it can be then reused as default value in the Docker settings.

@nijel nijel modified the milestones: 2026.6, 2026.7 May 29, 2026
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.

3 participants