summaryrefslogtreecommitdiff
path: root/packages/views.py
diff options
context:
space:
mode:
authorNicolás Reynolds <fauno@kiwwwi.com.ar>2010-12-31 15:42:55 -0300
committerNicolás Reynolds <fauno@kiwwwi.com.ar>2010-12-31 15:42:55 -0300
commitc9178286885d60741eb0e696c3e345e3b0dfb9e2 (patch)
tree7738211d84337e897acfd2263be0b33352becae0 /packages/views.py
parentebcd492d39cd0525b768a48558e50041aa0961e3 (diff)
parent84897adcdc698678f2ee8d2292cfe4271c6335e4 (diff)
Merge git://projects.archlinux.org/archweb
Conflicts: templates/public/index.html urls.py
Diffstat (limited to 'packages/views.py')
-rw-r--r--packages/views.py43
1 files changed, 24 insertions, 19 deletions
diff --git a/packages/views.py b/packages/views.py
index 40e8a08e..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/')
@@ -199,7 +204,7 @@ def search(request, page=None):
if packages.count() == 1:
return redirect(packages[0])
- allowed_sort = ["arch", "repo", "pkgname", "last_update"]
+ allowed_sort = ["arch", "repo", "pkgname", "last_update", "flag_date"]
allowed_sort += ["-" + s for s in allowed_sort]
sort = request.GET.get('sort', None)
# TODO: sorting by multiple fields makes using a DB index much harder
@@ -208,7 +213,7 @@ def search(request, page=None):
request.GET['sort'], 'repo', 'arch', 'pkgname')
page_dict['sort'] = sort
else:
- packages = packages.order_by('repo', 'arch', '-last_update', 'pkgname')
+ packages = packages.order_by('pkgname')
return list_detail.object_list(request, packages,
template_name="packages/search.html",