diff options
author | Dusty Phillips <buchuki@gmail.com> | 2008-07-05 20:28:29 -0400 |
---|---|---|
committer | Dusty Phillips <buchuki@gmail.com> | 2008-07-05 20:55:58 -0400 |
commit | 91b3ddd47f15851cd1686adbf9181fc46b9730a3 (patch) | |
tree | 6106296094b5b2552700ea8c07e84f015ed45f4c /packages | |
parent | b8221328c8de2dd2c673d4b0fd9a89d6d164d1d4 (diff) |
#10213 make package urls be pretty cool, if not awesome
Diffstat (limited to 'packages')
-rw-r--r-- | packages/views.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/packages/views.py b/packages/views.py index 0fa781c4..d971d7c3 100644 --- a/packages/views.py +++ b/packages/views.py @@ -35,19 +35,25 @@ def update(request): pkg.save() return render_response(request, 'status_page.html', {'message':message}) -def details(request, pkgid=0, name='', repo=''): - if pkgid == 0: +def details(request, pkgid=0, name='', repo='', arch=''): + if pkgid != 0: + pkg = get_object_or_404(Package, id=pkgid) + elif all([name, repo, arch]): + pkg= get_object_or_404(Package, + pkgname=name, repo__name__iexact=repo, arch__name=arch) + else: p = Package.objects.filter(pkgname=name) if repo: p = p.filter(repo__name__iexact=repo) + lenp = p.count() # if more then one result, send to the search view - if len(p) > 1: return search(request, name) - if len(p) < 1: return render_response(request, 'error_page.html', + if lenp > 1: return search(request, name) + if lenp < 1: return render_response(request, 'error_page.html', {'errmsg': 'No matching packages.'}) - pkgid = p[0].id + pkg = p[0] - pkg = get_object_or_404(Package, id=pkgid) return render_response(request, 'packages/details.html', {'pkg': pkg}) + # @TODO: replace search form with a newform def search(request, query=''): if request.GET.has_key('q'): |