summaryrefslogtreecommitdiff
path: root/packages/utils.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-02-23 12:09:29 -0600
committerDan McGee <dan@archlinux.org>2011-02-23 12:15:45 -0600
commit3181e970ce9dcc4fd996499ee536e4c2454e89dd (patch)
tree5466564b96c46c81d21140567170a4d6433f6e07 /packages/utils.py
parentf6c41b273c8962718b303c6050c2fd8bcea533a8 (diff)
Add stale package relations status screen
For now it is read only. Display a few tables of various ways of detecting stale package relations. These include inactive users, pkgbase values that no longer exist, and users that are listed as maintainers that don't have the proper permissions for that package anymore. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages/utils.py')
-rw-r--r--packages/utils.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/packages/utils.py b/packages/utils.py
index aaec0ec4..8d9f13ab 100644
--- a/packages/utils.py
+++ b/packages/utils.py
@@ -5,7 +5,7 @@ from operator import itemgetter
from main.models import Package
from main.utils import cache_function
-from .models import PackageGroup
+from .models import PackageGroup, PackageRelation
@cache_function(300)
def get_group_info(include_arches=None):
@@ -128,4 +128,26 @@ SELECT p.id, q.id
differences.sort(key=lambda a: (a.repo.name, a.pkgname))
return differences
+def get_wrong_permissions():
+ sql = """
+SELECT DISTINCT id
+ FROM (
+ SELECT pr.id, p.repo_id, pr.user_id
+ FROM packages p
+ JOIN packages_packagerelation pr ON p.pkgbase = pr.pkgbase
+ WHERE pr.type = %s
+ ) pkgs
+ WHERE pkgs.repo_id NOT IN (
+ SELECT repo_id FROM user_profiles_allowed_repos ar
+ INNER JOIN user_profiles up ON ar.userprofile_id = up.id
+ WHERE up.user_id = pkgs.user_id
+ )
+"""
+ cursor = connection.cursor()
+ cursor.execute(sql, [PackageRelation.MAINTAINER])
+ to_fetch = [row[0] for row in cursor.fetchall()]
+ relations = PackageRelation.objects.select_related('user').filter(
+ id__in=to_fetch)
+ return relations
+
# vim: set ts=4 sw=4 et: