summaryrefslogtreecommitdiffstats
path: root/public
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-07-31 07:09:28 +0200
committerDan McGee <dan@archlinux.org>2012-07-31 07:09:28 +0200
commit0cc369e985dd6376f0367e4b57e980ce14231796 (patch)
tree0ab0829d0d3a8465815178fdf5136e358f538891 /public
parent56a147d5b92935bf8326230bc5445ab0e0a114e9 (diff)
downloadarchweb-0cc369e985dd6376f0367e4b57e980ce14231796.tar.gz
archweb-0cc369e985dd6376f0367e4b57e980ce14231796.tar.xz
Update several bits and pieces for staging packages
This will prevent [staging] packages from cluttering normal user's view on the website, but allow us to still import everything from this repository for developer use. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'public')
-rw-r--r--public/utils.py12
-rw-r--r--public/views.py5
2 files changed, 13 insertions, 4 deletions
diff --git a/public/utils.py b/public/utils.py
index a40c9b5..bf74881 100644
--- a/public/utils.py
+++ b/public/utils.py
@@ -1,6 +1,6 @@
from operator import attrgetter
-from main.models import Arch, Package
+from main.models import Arch, Repo, Package
from main.utils import cache_function, groupby_preserve_order, PackageStandin
class RecentUpdate(object):
@@ -50,7 +50,13 @@ class RecentUpdate(object):
yield PackageStandin(package)
@cache_function(62)
-def get_recent_updates(number=15):
+def get_recent_updates(number=15, testing=True, staging=False):
+ repos = Repo.objects.all()
+ if not testing:
+ repos = repos.exclude(testing=True)
+ if not staging:
+ repos = repos.exclude(staging=True)
+
# This is a bit of magic. We are going to show 15 on the front page, but we
# want to try and eliminate cross-architecture wasted space. Pull enough
# packages that we can later do some screening and trim out the fat.
@@ -59,7 +65,7 @@ def get_recent_updates(number=15):
fetch = number * 6
for arch in Arch.objects.all():
pkgs += list(Package.objects.normal().filter(
- arch=arch).order_by('-last_update')[:fetch])
+ arch=arch, repo__in=repos).order_by('-last_update')[:fetch])
pkgs.sort(key=attrgetter('last_update'), reverse=True)
same_pkgbase_key = lambda x: (x.repo.name, x.pkgbase)
diff --git a/public/views.py b/public/views.py
index 3f68545..c8854b7 100644
--- a/public/views.py
+++ b/public/views.py
@@ -16,7 +16,10 @@ from .utils import get_recent_updates
@cache_control(max_age=300)
def index(request):
- pkgs = get_recent_updates()
+ if request.user.is_authenticated():
+ pkgs = get_recent_updates(testing=True, staging=True)
+ else:
+ pkgs = get_recent_updates()
context = {
'news_updates': News.objects.order_by('-postdate', '-id')[:15],
'pkg_updates': pkgs,