Repository: WeblateOrg/weblate

Issue:
No way to set default notification setting for watched projects
### Describe the issue

Thanks for this great project. On the notifications part there is some room for improvements as when you come from transifex, you get a lot of useful notifications which encourage user to finish the translation of a language when stuff changes. Would it be possible to set some defaults for the "New translation component was created" and "New string is available for translation" settings. As IMO for these settings an instant notification should be sent out. Probably some more would be nice too.

### I already tried

- [X] I've read and searched [the documentation](https://docs.weblate.org/).
- [X] I've searched for similar issues in this repository.

### Steps to reproduce the behavior

1. Got to /accounts/profile/#notifications__1
2. Check the component and translation notifications

### Expected behavior

Some default settings to adjust, either in the GUI or by configuration variable.

### Screenshots

_No response_

### Exception traceback

_No response_

### How do you run Weblate?

Docker container

### Weblate versions

_No response_

### Weblate deploy checks

_No response_

### Additional context

Kind of related to #5155.


Discussion:
This issue has been put aside. It is currently unclear if it will ever be implemented as it seems to cover too narrow of a use case or doesn't seem to fit into Weblate.

Please try to clarify the use case or consider proposing something more generic to make it useful to more users.
"New string is available for translation" can be pretty noisy when triggered for each string, so you want that one to be digest.

Anyway: Where these additional defaults should be set and by who? 

Weblate already has built-in defaults:

https://github.com/WeblateOrg/weblate/blob/47b99981341f925c937153b87613bbf99373526a/weblate/accounts/data.py#L12-L22

Admin presets are covered by https://github.com/WeblateOrg/weblate/issues/5155
Thanks for the answer, as I'm using docker, it is probaly not really possible to set these defaults.

I was playing around a bit more with weblate and when I commit new strings or updated strings, weblate receives them correctly from the Github webhook. But no notifications are going out, should I open a new ticket for that?
https://github.com/WeblateOrg/weblate/pull/10659 should address notifications for new strings. 
Thanks, and what about updated strings? Is this something you want to address too?
Yes, we should cover that as well.
Do you not want to add #10651 to the 5.4 milestone instead of this one? As per your [comment](https://github.com/WeblateOrg/weblate/issues/10533#issuecomment-1847193042) this is already possible, just didn't figure out how in docker.
#10651 is already added to that milestone. I'd like to change the defaults in this issue to give users more notifications. I am not sure if we want to make this admin configurable, though.

Resolving patch:
diff --git a/weblate/accounts/data.py b/weblate/accounts/data.py
--- a/weblate/accounts/data.py
+++ b/weblate/accounts/data.py
@@ -4,6 +4,7 @@
 
 from weblate.accounts.notifications import (
     FREQ_INSTANT,
+    FREQ_WEEKLY,
     SCOPE_ADMIN,
     SCOPE_ALL,
     SCOPE_WATCHED,
@@ -14,6 +15,7 @@
     (SCOPE_WATCHED, FREQ_INSTANT, "LastAuthorCommentNotificaton"),
     (SCOPE_WATCHED, FREQ_INSTANT, "MentionCommentNotificaton"),
     (SCOPE_WATCHED, FREQ_INSTANT, "NewAnnouncementNotificaton"),
+    (SCOPE_WATCHED, FREQ_WEEKLY, "NewStringNotificaton"),
     (SCOPE_ADMIN, FREQ_INSTANT, "MergeFailureNotification"),
     (SCOPE_ADMIN, FREQ_INSTANT, "ParseErrorNotification"),
     (SCOPE_ADMIN, FREQ_INSTANT, "NewTranslationNotificaton"),


Test patch:
diff --git a/weblate/accounts/tests/test_notifications.py b/weblate/accounts/tests/test_notifications.py
--- a/weblate/accounts/tests/test_notifications.py
+++ b/weblate/accounts/tests/test_notifications.py
@@ -73,6 +73,12 @@ def setUp(self) -> None:
             "LastAuthorCommentNotificaton",
         )
         for notification in notifications:
+            # Remove any conflicting notifications
+            Subscription.objects.filter(
+                user=self.user,
+                scope=SCOPE_WATCHED,
+                notification=notification,
+            ).delete()
             Subscription.objects.create(
                 user=self.user,
                 scope=SCOPE_WATCHED,
@@ -430,6 +436,7 @@ def test_reminder(
         notification="ToDoStringsNotification",
         subj="4 unfinished strings in Test/Test",
     ) -> None:
+        self.user.subscription_set.filter(frequency=frequency).delete()
         self.user.subscription_set.create(
             scope=SCOPE_WATCHED, notification=notification, frequency=frequency
         )
diff --git a/weblate/accounts/tests/test_views.py b/weblate/accounts/tests/test_views.py
--- a/weblate/accounts/tests/test_views.py
+++ b/weblate/accounts/tests/test_views.py
@@ -436,7 +436,7 @@ def test_userdata(self) -> None:
     def test_subscription(self) -> None:
         # Get profile page
         response = self.client.get(reverse("profile"))
-        self.assertEqual(self.user.subscription_set.count(), 9)
+        self.assertEqual(self.user.subscription_set.count(), 10)
 
         # Extract current form data
         data: dict[str, str | list[str]] = {}
@@ -454,20 +454,20 @@ def test_subscription(self) -> None:
         # Save unchanged data
         response = self.client.post(reverse("profile"), data, follow=True)
         self.assertContains(response, "Your profile has been updated.")
-        self.assertEqual(self.user.subscription_set.count(), 9)
+        self.assertEqual(self.user.subscription_set.count(), 10)
 
         # Remove some subscriptions
         data["notifications__1-notify-LastAuthorCommentNotificaton"] = "0"
         data["notifications__1-notify-MentionCommentNotificaton"] = "0"
         response = self.client.post(reverse("profile"), data, follow=True)
         self.assertContains(response, "Your profile has been updated.")
-        self.assertEqual(self.user.subscription_set.count(), 7)
+        self.assertEqual(self.user.subscription_set.count(), 8)
 
         # Add some subscriptions
         data["notifications__2-notify-ChangedStringNotificaton"] = "1"
         response = self.client.post(reverse("profile"), data, follow=True)
         self.assertContains(response, "Your profile has been updated.")
-        self.assertEqual(self.user.subscription_set.count(), 8)
+        self.assertEqual(self.user.subscription_set.count(), 9)
 
     def test_subscription_customize(self) -> None:
         # Initial view
@@ -497,7 +497,7 @@ def test_subscription_customize(self) -> None:
 
     def test_watch(self) -> None:
         self.assertEqual(self.user.profile.watched.count(), 0)
-        self.assertEqual(self.user.subscription_set.count(), 9)
+        self.assertEqual(self.user.subscription_set.count(), 10)
 
         # Watch project
         self.client.post(reverse("watch", kwargs={"path": self.project.get_url_path()}))
@@ -529,11 +529,11 @@ def test_watch(self) -> None:
         self.assertEqual(
             self.user.subscription_set.filter(component=self.component).count(), 0
         )
-        self.assertEqual(self.user.subscription_set.count(), 9)
+        self.assertEqual(self.user.subscription_set.count(), 10)
 
     def test_watch_component(self) -> None:
         self.assertEqual(self.user.profile.watched.count(), 0)
-        self.assertEqual(self.user.subscription_set.count(), 9)
+        self.assertEqual(self.user.subscription_set.count(), 10)
 
         # Watch component
         self.client.post(reverse("watch", kwargs=self.kw_component))
@@ -544,7 +544,7 @@ def test_watch_component(self) -> None:
         )
         # Only default notifications should be enabled
         self.assertEqual(
-            self.user.subscription_set.filter(component=self.component).count(), 3
+            self.user.subscription_set.filter(component=self.component).count(), 4
         )
 
     def test_unsubscribe(self) -> None:
diff --git a/weblate/api/tests.py b/weblate/api/tests.py
--- a/weblate/api/tests.py
+++ b/weblate/api/tests.py
@@ -253,7 +253,7 @@ def test_list_notifications(self) -> None:
             superuser=True,
             code=200,
         )
-        self.assertEqual(response.data["count"], 9)
+        self.assertEqual(response.data["count"], 10)
 
     def test_post_notifications(self) -> None:
         self.do_request(
@@ -274,7 +274,7 @@ def test_post_notifications(self) -> None:
                 "frequency": 1,
             },
         )
-        self.assertEqual(Subscription.objects.count(), 10)
+        self.assertEqual(Subscription.objects.count(), 11)
 
     def test_get_notifications(self) -> None:
         user = User.objects.filter(is_active=True)[0]
@@ -344,7 +344,7 @@ def test_delete_notifications(self) -> None:
             superuser=True,
             code=204,
         )
-        self.assertEqual(Subscription.objects.count(), 8)
+        self.assertEqual(Subscription.objects.count(), 9)
 
     def test_statistics(self) -> None:
         user = User.objects.filter(is_active=True)[0]