Fixing get_users_to_notify

remotes/origin/logger
Alejandro Alonso 2015-11-02 11:58:46 +01:00
parent 624f27e095
commit 3cb15f0e3e
2 changed files with 3 additions and 3 deletions

View File

@ -151,7 +151,7 @@ def get_users_to_notify(obj, *, discard_users=None) -> list:
def _check_level(project:object, user:object, levels:tuple) -> bool: def _check_level(project:object, user:object, levels:tuple) -> bool:
policy = get_notify_policy(project, user) policy = get_notify_policy(project, user)
return policy.notify_level in [int(x) for x in levels] return policy.notify_level in levels
_can_notify_hard = partial(_check_level, project, _can_notify_hard = partial(_check_level, project,
levels=[NotifyLevel.all]) levels=[NotifyLevel.all])
@ -160,8 +160,8 @@ def get_users_to_notify(obj, *, discard_users=None) -> list:
candidates = set() candidates = set()
candidates.update(filter(_can_notify_hard, project.members.all())) candidates.update(filter(_can_notify_hard, project.members.all()))
candidates.update(filter(_can_notify_hard, obj.project.get_watchers()))
candidates.update(filter(_can_notify_light, obj.get_watchers())) candidates.update(filter(_can_notify_light, obj.get_watchers()))
candidates.update(filter(_can_notify_light, obj.project.get_watchers()))
candidates.update(filter(_can_notify_light, obj.get_participants())) candidates.update(filter(_can_notify_light, obj.get_participants()))
# Remove the changer from candidates # Remove the changer from candidates

View File

@ -352,7 +352,7 @@ def test_watching_users_to_notify_on_issue_modification_6():
watching_user_policy.notify_level = NotifyLevel.involved watching_user_policy.notify_level = NotifyLevel.involved
watching_user_policy.save() watching_user_policy.save()
users = services.get_users_to_notify(issue) users = services.get_users_to_notify(issue)
assert users == {watching_user, issue.owner} assert users == {issue.owner}
def test_send_notifications_using_services_method_for_user_stories(settings, mail): def test_send_notifications_using_services_method_for_user_stories(settings, mail):