From 9803ba9e8d4ab380d76567c283fcf8012526452f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 07 2017 10:40:49 +0000 Subject: Apply EXCLUDE_GROUP_INDEX to the watchlist as well The watchlist contains all the project the user is watching as well as all the project they have access to. So we need to apply EXCLUDE_GROUP_INDEX to this list as well as otherwise we would end up in the same situation where we would list all the projects there is on that pagure instance for some users. --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index c5fac38..50c9fa1 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -3328,7 +3328,7 @@ def is_watching(session, user, reponame, repouser=None, namespace=None): return False -def user_watch_list(session, user): +def user_watch_list(session, user, exclude_groups): ''' Returns list of all the projects which the user is watching ''' user_obj = search_user(session, username=user) @@ -3359,7 +3359,8 @@ def user_watch_list(session, user): if watched: watched_list = [watch.project for watch in watched.all()] - user_projects = search_projects(session, username=user_obj.user) + user_projects = search_projects( + session, username=user_obj.user, exclude_groups=exclude_groups) watch = set(watched_list + user_projects) for project in user_projects: diff --git a/pagure/ui/app.py b/pagure/ui/app.py index a7b0920..f7cfdcf 100644 --- a/pagure/ui/app.py +++ b/pagure/ui/app.py @@ -115,7 +115,9 @@ def index_auth(): watch_list = pagure.lib.user_watch_list( SESSION, - user=flask.g.fas_user.username) + user=flask.g.fas_user.username, + exclude_groups=APP.config.get('EXCLUDE_GROUP_INDEX'), + ) return flask.render_template( 'index_auth.html',