From 3eea31d8f2d5a4213b00eedaabfc75770aeb418f Mon Sep 17 00:00:00 2001 From: eliott Date: Wed, 9 Apr 2008 19:28:24 -0700 Subject: Changed to arches and repos in the db. Added them to the django admin interface as well. --- packages/views.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'packages/views.py') diff --git a/packages/views.py b/packages/views.py index 867bf0fb..fc19e444 100644 --- a/packages/views.py +++ b/packages/views.py @@ -8,6 +8,7 @@ from datetime import datetime from archweb_dev.main.utils import validate, render_response from archweb_dev.main.models import Package, PackageFile, PackageDepend +from archweb_dev.main.models import Arch, Repo from django.core.exceptions import ObjectDoesNotExist @@ -37,7 +38,7 @@ def update(request): def details(request, pkgid=0, name='', repo=''): if pkgid == 0: p = Package.objects.filter(pkgname=name) - if repo: p = p.filter(repo=Package.REPOS[repo]) + if repo: p = p.filter(repo__name__iexact=repo) # 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', @@ -63,8 +64,8 @@ def search(request, query=''): flagged_only = request.GET.get('flagged_only', 'n') # build the form lists - repos = Package.REPOS - arches = Package.ARCHES + repos = Repo.objects.all() + arches = Arch.objects.all() # copy GET data over and add the lists c = request.GET.copy() c['repos'], c['arches'] = repos, arches @@ -89,10 +90,10 @@ def search(request, query=''): results = res1 | res2 else: results = Package.objects.all() - if repo != 'all' and repo in Package.REPOS: - results = results.filter(repo=Package.REPOS[repo]) - if arch != 'all' and arch in Package.ARCHES: - results = results.filter(arch=Package.ARCHES[arch]) + if repo != 'all' and repo in [x.name for x in repos]: + results = results.filter(repo__name__iexact=repo) + if arch != 'all' and arch in [x.name for x in arches]: + results = results.filter(arch__name__iexact=arch) if maint != 'all': results = results.filter(maintainer=maint) if flagged_only != 'n': -- cgit v1.2.3-54-g00ecf