summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authoreliott <eliott@cactuswax.net>2008-03-22 19:51:01 -0700
committereliott <eliott@cactuswax.net>2008-03-22 19:51:01 -0700
commit7640082d14af2827ab22caa6dce3575f5112d7cf (patch)
tree6fb40e5c0dc734f5646166708b1e39ab5c30859d /packages
parent37361f664f5092d5f4cc7bb2a20e1e86cbbf558d (diff)
downloadarchweb-7640082d14af2827ab22caa6dce3575f5112d7cf.tar.gz
archweb-7640082d14af2827ab22caa6dce3575f5112d7cf.zip
Refactored the model to remove arch and repo tables.
Refactored the model to remove the arch and repo tables. Those data points are now encapsulated in the package table as an ENUM field. Changes to models and templates as needed.
Diffstat (limited to 'packages')
-rw-r--r--packages/views.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/packages/views.py b/packages/views.py
index fef5efc9..0b19235c 100644
--- a/packages/views.py
+++ b/packages/views.py
@@ -7,8 +7,7 @@ from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from datetime import datetime
from archweb_dev.main.utils import validate, render_response
-from archweb_dev.main.models import Arch, Repo
-from archweb_dev.main.models import Package, PackageFile, PackageDepends
+from archweb_dev.main.models import Package, PackageFile, PackageDepend
from django.core.exceptions import ObjectDoesNotExist
@@ -38,7 +37,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__name__exact=repo)
+ if repo: p = p.filter(repo=Package.REPOS[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,11 +62,11 @@ def search(request, query=''):
maint = request.GET.get('maint', 'all')
# build the form lists
- repos = Repo.objects.order_by('name')
- archs = Arch.objects.order_by('name')
+ repos = Package.REPOS
+ arches = Package.ARCHES
# copy GET data over and add the lists
c = request.GET.copy()
- c['repos'], c['archs'] = repos, archs
+ c['repos'], c['arches'] = repos, arches
c['limit'], c['skip'] = limit, skip
c['lastupdate'] = lastupdate
c['sort'] = sort
@@ -89,10 +88,18 @@ def search(request, query=''):
results = res1 | res2
else:
results = Package.objects.all()
- if repo != 'all': results = results.filter(repo__name__exact=repo)
- if arch != 'all': results = results.filter(arch__name__exact=arch)
- if maint != 'all': results = results.filter(maintainer=maint)
- if lastupdate: results = results.filter(last_update__gte=datetime(int(lastupdate[0:4]),int(lastupdate[5:7]),int(lastupdate[8:10])))
+ 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 maint != 'all':
+ results = results.filter(maintainer=maint)
+ if lastupdate:
+ results = results.filter(
+ last_update__gte=datetime(
+ int(lastupdate[0:4]),
+ int(lastupdate[5:7]),
+ int(lastupdate[8:10])))
# sort results
if sort == '':