Fixing get projects watched by user calculation

remotes/origin/logger
Alejandro Alonso 2016-01-12 10:04:25 +01:00
parent f7137864de
commit 305cb5cd61
1 changed files with 4 additions and 3 deletions

View File

@ -377,12 +377,13 @@ def get_projects_watched(user_or_id):
"""
if isinstance(user_or_id, get_user_model()):
user_id = user_or_id.id
user = user_or_id
else:
user_id = user_or_id
user = get_user_model().objects.get(id=user_or_id)
project_class = apps.get_model("projects", "Project")
return project_class.objects.filter(notify_policies__user__id=user_id).exclude(notify_policies__notify_level=NotifyLevel.none)
project_ids = user.notify_policies.exclude(notify_level=NotifyLevel.none).values_list("project__id", flat=True)
return project_class.objects.filter(id__in=project_ids)
def add_watcher(obj, user):
"""Add a watcher to an object.