Skip to content

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

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

feat(accounts): add default notification configuration to settings#19005
michael-smt wants to merge 3 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

nijel commented Apr 14, 2026

Copy link
Copy Markdown
Member

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

argos-ci Bot commented Apr 14, 2026

Copy link
Copy Markdown

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

Awaiting the start of a new Argos build…

@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

nijel commented May 14, 2026

Copy link
Copy Markdown
Member

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

nijel commented May 22, 2026

Copy link
Copy Markdown
Member

@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 3 times, most recently 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 thread weblate/accounts/models.py Outdated
Comment thread weblate/settings_docker.py Outdated
Comment thread weblate/utils/environment.py Outdated
Comment thread docs/admin/install/docker.rst Outdated
Comment thread weblate/accounts/models.py Outdated
@nijel nijel modified the milestones: 2026.6, 2026.7 May 29, 2026
@michael-smt michael-smt force-pushed the feat/setting-default-notifications branch from abdd0df to ff4b2df Compare June 5, 2026 12:11
@michael-smt michael-smt marked this pull request as draft June 5, 2026 12:27
@michael-smt michael-smt force-pushed the feat/setting-default-notifications branch 3 times, most recently from 8f4d2f3 to 87d4bcd Compare June 5, 2026 15:13
Comment thread weblate/utils/environment.py Outdated
except ValueError as error:
msg = f"{name}: not an integer: {error}"
raise ImproperlyConfigured(msg) from error

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would have liked to extend the validation here with something like this:

        if frequency not in NotificationFrequency.values:
            msg = f"{name}: invalid notification frequency {frequency}"
            raise ImproperlyConfigured(msg)
        if scope not in NotificationScope.values:
            msg = f"{name}: invalid notification scope {scope}"
            raise ImproperlyConfigured(msg)
        if handler not in [n.__name__ for n in NOTIFICATIONS]:
            msg = f"{name}: unknown handler {handler}"
            raise ImproperlyConfigured(msg)

But can't use these classes here because django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

Maybe there is a better place for the validation?

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.

I think AppConfig.ready() could be the place. That way it would cover the Python code settings, not just the environment in Docker. The validation in this file should be focused on the environment values parsing.

@michael-smt michael-smt Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks a lot for the hint and your patience. I tried to implement that now.

Validation of the notification handlers via NOTIFICATIONS (the list that gets built from the decorators) is not possible due to AppRegistryNotReady... I wanted to do something like

                if handler not in [n.__name__ for n in NOTIFICATIONS]:
                    errors.append(
                        weblate_check(
                            f"{name} contains a unknown notification handler {handler}",
                        )
                    )
@nijel nijel removed this from the 2026.7 milestone Jun 24, 2026
@michael-smt michael-smt force-pushed the feat/setting-default-notifications branch from 87d4bcd to 10b49d8 Compare June 28, 2026 12:50
@michael-smt michael-smt force-pushed the feat/setting-default-notifications branch from 10b49d8 to 06a979b Compare June 28, 2026 15:45
@michael-smt michael-smt force-pushed the feat/setting-default-notifications branch from 06a979b to 16dcaee Compare June 28, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants