Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(notification): turn on digest notification on new strings by default #11641

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions weblate/accounts/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from weblate.accounts.notifications import (
FREQ_INSTANT,
FREQ_WEEKLY,
SCOPE_ADMIN,
SCOPE_ALL,
SCOPE_WATCHED,
Expand All @@ -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"),
Expand Down
7 changes: 7 additions & 0 deletions weblate/accounts/tests/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
)
Expand Down
16 changes: 8 additions & 8 deletions weblate/accounts/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]] = {}
Expand All @@ -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
Expand Down Expand Up @@ -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()}))
Expand Down Expand Up @@ -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))
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions weblate/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
Loading