Filter maintainer list on packages page by allowed repos

We do this elsewhere on the master keys page, so do the same thing here.

Noticed-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2014-12-02 14:53:38 -06:00
parent e12f88f1d6
commit dca00e7aab

View File

@ -6,6 +6,7 @@
from django.http import HttpResponse from django.http import HttpResponse
from django.views.generic import ListView from django.views.generic import ListView
from devel.models import UserProfile
from main.models import Package, Arch, Repo from main.models import Package, Arch, Repo
from main.utils import empty_response, make_choice from main.utils import empty_response, make_choice
from ..models import PackageRelation from ..models import PackageRelation
@ -36,14 +37,16 @@ def __init__(self, *args, **kwargs):
self.fields['arch'].choices = make_choice( self.fields['arch'].choices = make_choice(
[arch.name for arch in Arch.objects.all()]) [arch.name for arch in Arch.objects.all()])
self.fields['q'].widget.attrs.update({"size": "30"}) self.fields['q'].widget.attrs.update({"size": "30"})
maints = User.objects.filter(is_active=True).order_by(
profile_ids = UserProfile.allowed_repos.through.objects.values('userprofile_id')
people = User.objects.filter(
is_active=True, userprofile__id__in=profile_ids).order_by(
'first_name', 'last_name') 'first_name', 'last_name')
self.fields['maintainer'].choices = \ people = [('', 'All'), ('orphan', 'Orphan')] + \
[('', 'All'), ('orphan', 'Orphan')] + \ [(p.username, p.get_full_name()) for p in people]
[(m.username, m.get_full_name()) for m in maints]
self.fields['packager'].choices = \ self.fields['maintainer'].choices = people
[('', 'All'), ('unknown', 'Unknown')] + \ self.fields['packager'].choices = people
[(m.username, m.get_full_name()) for m in maints]
def exact_matches(self): def exact_matches(self):
# only do exact match search if 'q' is sole parameter # only do exact match search if 'q' is sole parameter