summaryrefslogtreecommitdiff
path: root/packages
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
parentebcd492d39cd0525b768a48558e50041aa0961e3 (diff)
parent84897adcdc698678f2ee8d2292cfe4271c6335e4 (diff)
Merge git://projects.archlinux.org/archweb
Conflicts: templates/public/index.html urls.py
Diffstat (limited to 'packages')
-rw-r--r--packages/urls.py37
-rw-r--r--packages/views.py43
2 files changed, 61 insertions, 19 deletions
diff --git a/packages/urls.py b/packages/urls.py
new file mode 100644
index 00000000..da24ee03
--- /dev/null
+++ b/packages/urls.py
@@ -0,0 +1,37 @@
+from django.conf.urls.defaults import include, patterns
+
+package_patterns = patterns('packages.views',
+ (r'^$', 'details'),
+ (r'^files/$', 'files'),
+ (r'^maintainer/$', 'getmaintainer'),
+ (r'^flag/$', 'flag'),
+ (r'^unflag/$', 'unflag'),
+ (r'^download/$', 'download'),
+)
+
+urlpatterns = patterns('packages.views',
+ (r'^flaghelp/$', 'flaghelp'),
+ (r'^signoffs/$', 'signoffs'),
+ (r'^signoff_package/(?P<arch>[A-z0-9]+)/(?P<pkgname>[A-z0-9\-+.]+)/$',
+ 'signoff_package'),
+ (r'^update/$', 'update'),
+
+ # Preference is for the non-search url below, but search is kept
+ # because other projects link to it
+ (r'^search/$', 'search'),
+ (r'^search/(?P<page>\d+)/$', 'search'),
+ (r'^$', 'search'),
+ (r'^(?P<page>\d+)/$', 'search'),
+
+ (r'^differences/$', 'arch_differences'),
+
+ (r'^(?P<name>[A-z0-9\-+.]+)/$',
+ 'details'),
+ (r'^(?P<repo>[A-z0-9\-]+)/(?P<name>[A-z0-9\-+.]+)/$',
+ 'details'),
+ # canonical package url. subviews defined above
+ (r'^(?P<repo>[A-z0-9\-]+)/(?P<arch>[A-z0-9]+)/(?P<name>[A-z0-9\-+.]+)/',
+ include(package_patterns)),
+)
+
+# vim: set ts=4 sw=4 et:
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",