summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-12-07 12:35:48 -0600
committerDan McGee <dan@archlinux.org>2010-12-07 12:35:48 -0600
commit62eb9b8031d66ac3b47c6a993b2acbdf81b42f9c (patch)
treedf3bb243038e705a386f082f2e47ca64a0b8b840
parentd37b15327690f0f436fc25ac856d20df73447c7d (diff)
Always allow a developer to disown a package
Don't check the valid repos when disowning; this should address the biggest part of FS#20687 where a package going from [community] to [extra] can't lose it's old maintainer due to permission issues. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--packages/views.py39
1 files changed, 22 insertions, 17 deletions
diff --git a/packages/views.py b/packages/views.py
index 283f9cec..77fa3a07 100644
--- a/packages/views.py
+++ b/packages/views.py
@@ -37,38 +37,43 @@ def opensearch(request):
@permission_required('main.change_package')
def update(request):
ids = request.POST.getlist('pkgid')
- mode = None
- if request.POST.has_key('adopt'):
- mode = 'adopt'
- if request.POST.has_key('disown'):
- mode = 'disown'
+ count = 0
- if mode:
+ if request.POST.has_key('adopt'):
repos = request.user.userprofile.allowed_repos.all()
pkgs = Package.objects.filter(id__in=ids, repo__in=repos)
disallowed_pkgs = Package.objects.filter(id__in=ids).exclude(
repo__in=repos)
- count = 0
+
+ if disallowed_pkgs:
+ messages.warning(request,
+ "You do not have permission to adopt: %s." % (
+ ' '.join([p.pkgname for p in disallowed_pkgs])
+ ))
+
for pkg in pkgs:
- maints = pkg.maintainers
- if mode == 'adopt' and request.user not in maints:
+ if request.user not in pkg.maintainers:
prel = PackageRelation(pkgbase=pkg.pkgbase,
user=request.user,
type=PackageRelation.MAINTAINER)
count += 1
prel.save()
- elif mode == 'disown' and request.user in maints:
+
+ messages.info(request, "%d base packages adopted." % count)
+
+ elif request.POST.has_key('disown'):
+ # allow disowning regardless of allowed repos, helps things like
+ # [community] -> [extra] moves
+ for pkg in Package.objects.filter(id__in=ids):
+ if request.user in pkg.maintainers:
rels = PackageRelation.objects.filter(pkgbase=pkg.pkgbase,
- user=request.user)
+ user=request.user,
+ type=PackageRelation.MAINTAINER)
count += rels.count()
rels.delete()
- messages.info(request, "%d base packages %sed." % (count, mode))
- if disallowed_pkgs:
- messages.warning(request,
- "You do not have permission to %s: %s" % (
- mode, ' '.join([p.pkgname for p in disallowed_pkgs])
- ))
+ messages.info(request, "%d base packages disowned." % count)
+
else:
messages.error(request, "Are you trying to adopt or disown?")
return redirect('/packages/')