summaryrefslogtreecommitdiff
path: root/packages/views.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-02-16 20:20:54 -0600
committerDan McGee <dan@archlinux.org>2010-02-16 20:20:54 -0600
commit029359fdd55bca0f325a9c59ec3d815d87a3125f (patch)
tree17a228f57d503ebd87928b0ec1f1a40381a09019 /packages/views.py
parentc568e401ae83be7763d6589bd18a136fee1fd378 (diff)
Clean up adopt/disown logic
We can pull the common queryset out into a local variable, as well as using the mass-update function provided on a queryset instead of resorting to iteration. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages/views.py')
-rw-r--r--packages/views.py13
1 files changed, 4 insertions, 9 deletions
diff --git a/packages/views.py b/packages/views.py
index 58d61487..56c4f7d1 100644
--- a/packages/views.py
+++ b/packages/views.py
@@ -42,16 +42,11 @@ def update(request):
maint = None
if mode:
- pkgs = Package.objects.filter(
- id__in=ids,
- repo__in=request.user.userprofile_user.all(
- )[0].allowed_repos.all())
+ repos = request.user.userprofile_user.all()[0].allowed_repos.all()
+ pkgs = Package.objects.filter(id__in=ids, repo__in=repos)
disallowed_pkgs = Package.objects.filter(id__in=ids).exclude(
- repo__in=request.user.userprofile_user.all(
- )[0].allowed_repos.all())
- for pkg in pkgs:
- pkg.maintainer = maint
- pkg.save()
+ repo__in=repos)
+ pkgs.update(maintainer=maint)
request.user.message_set.create(message="%d packages %sed" % (
len(pkgs), mode))