diff options
author | Dan McGee <dan@archlinux.org> | 2010-02-16 20:20:54 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-02-16 20:20:54 -0600 |
commit | 029359fdd55bca0f325a9c59ec3d815d87a3125f (patch) | |
tree | 17a228f57d503ebd87928b0ec1f1a40381a09019 | |
parent | c568e401ae83be7763d6589bd18a136fee1fd378 (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>
-rw-r--r-- | packages/views.py | 13 |
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)) |