diff --git a/taiga/users/services.py b/taiga/users/services.py index 4542d22b..aea50ca4 100644 --- a/taiga/users/services.py +++ b/taiga/users/services.py @@ -224,7 +224,9 @@ def _build_watched_sql_for_projects(for_user): ON projects_project.id = type_watchers.project_id LEFT JOIN likes_likes ON (projects_project.id = likes_likes.object_id AND {project_content_type_id} = likes_likes.content_type_id) - WHERE notifications_notifypolicy.user_id = {for_user_id} + WHERE + notifications_notifypolicy.user_id = {for_user_id} + AND notifications_notifypolicy.notify_level != {ignore_notify_level} """ sql = sql.format( for_user_id=for_user.id, diff --git a/tests/integration/test_users.py b/tests/integration/test_users.py index 1a5959e0..d9990d45 100644 --- a/tests/integration/test_users.py +++ b/tests/integration/test_users.py @@ -13,6 +13,8 @@ from taiga.users.serializers import LikedObjectSerializer, VotedObjectSerializer from taiga.auth.tokens import get_token_for_user from taiga.permissions.permissions import MEMBERS_PERMISSIONS, ANON_PERMISSIONS, USER_PERMISSIONS from taiga.users.services import get_watched_list, get_voted_list, get_liked_list +from taiga.projects.notifications.choices import NotifyLevel +from taiga.projects.notifications.models import NotifyPolicy from easy_thumbnails.files import generate_all_aliases, get_thumbnailer @@ -470,6 +472,22 @@ def test_get_watched_list_valid_info_for_project(): assert project_watch_info["assigned_to_photo"] == None +def test_get_watched_list_for_project_with_ignored_notify_level(): + #If the notify policy level is ignore the project shouldn't be in the watched results + fav_user = f.UserFactory() + viewer_user = f.UserFactory() + + project = f.ProjectFactory(is_private=False, name="Testing project", tags=['test', 'tag']) + role = f.RoleFactory(project=project, permissions=["view_project", "view_us", "view_tasks", "view_issues"]) + membership = f.MembershipFactory(project=project, role=role, user=fav_user) + notify_policy = NotifyPolicy.objects.get(user=fav_user, project=project) + notify_policy.notify_level=NotifyLevel.ignore + notify_policy.save() + + watched_list = get_watched_list(fav_user, viewer_user) + assert len(watched_list) == 0 + + def test_get_liked_list_valid_info(): fan_user = f.UserFactory() viewer_user = f.UserFactory() diff --git a/tests/integration/test_watch_projects.py b/tests/integration/test_watch_projects.py index 724c5106..fd1c9560 100644 --- a/tests/integration/test_watch_projects.py +++ b/tests/integration/test_watch_projects.py @@ -69,7 +69,7 @@ def test_watch_project_with_invalid_notify_level(client): assert response.data["_error_message"] == "Invalid value for notify level" -def test_unwacth_project(client): +def test_unwatch_project(client): user = f.UserFactory.create() project = f.create_project(owner=user) f.MembershipFactory.create(project=project, user=user, is_owner=True)