summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-12 17:08:29 +0100
committerDan McGee <dan@archlinux.org>2011-01-18 21:26:38 +0100
commit9cdc536fffc9e77903892c2b14e9462a6ec94ee5 (patch)
tree9dd56ad147f38867f63c24a3c79bc28e38fc5cd0
parentecb24ab66a9d0a03ad021d23d4fa543f8163ef3e (diff)
downloadarchweb-9cdc536fffc9e77903892c2b14e9462a6ec94ee5.tar.gz
archweb-9cdc536fffc9e77903892c2b14e9462a6ec94ee5.tar.xz
Add arch-specific group overview pages
This is easy enough to refactor and support with our current infrastructure and group-fetching functions. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--packages/utils.py10
-rw-r--r--packages/views.py14
-rw-r--r--templates/packages/group_details.html2
-rw-r--r--templates/packages/groups.html4
-rw-r--r--urls.py1
5 files changed, 21 insertions, 10 deletions
diff --git a/packages/utils.py b/packages/utils.py
index 93d0de7..aaec0ec 100644
--- a/packages/utils.py
+++ b/packages/utils.py
@@ -8,7 +8,7 @@ from main.utils import cache_function
from .models import PackageGroup
@cache_function(300)
-def get_group_info():
+def get_group_info(include_arches=None):
raw_groups = PackageGroup.objects.values_list(
'name', 'pkg__arch__name').order_by('name').annotate(
cnt=Count('pkg'), last_update=Max('pkg__last_update'))
@@ -38,10 +38,12 @@ def get_group_info():
new_g['arch'] = arch
arch_groups[grp['name']] = new_g
- # now transform it back into a sorted list
+ # now transform it back into a sorted list, including only the specified
+ # architectures if we got a list
groups = []
- for val in group_mapping.itervalues():
- groups.extend(val.itervalues())
+ for key, val in group_mapping.iteritems():
+ if not include_arches or key in include_arches:
+ groups.extend(val.itervalues())
return sorted(groups, key=itemgetter('name', 'arch'))
class Difference(object):
diff --git a/packages/views.py b/packages/views.py
index 4e68314..e00e6f9 100644
--- a/packages/views.py
+++ b/packages/views.py
@@ -88,9 +88,17 @@ def details(request, name='', repo='', arch=''):
return redirect("/packages/?arch=%s&repo=%s&q=%s" % (
arch.lower(), repo.title(), name))
-def groups(request):
- grps = get_group_info()
- return direct_to_template(request, 'packages/groups.html', {'groups': grps})
+def groups(request, arch=None):
+ arches = []
+ if arch:
+ get_object_or_404(Arch, name=arch, agnostic=False)
+ arches.append(arch)
+ grps = get_group_info(arches)
+ context = {
+ 'groups': grps,
+ 'arch': arch,
+ }
+ return direct_to_template(request, 'packages/groups.html', context)
def group_details(request, arch, name):
arch = get_object_or_404(Arch, name=arch)
diff --git a/templates/packages/group_details.html b/templates/packages/group_details.html
index df9c5e9..9cfa7b7 100644
--- a/templates/packages/group_details.html
+++ b/templates/packages/group_details.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-{% block title %}Arch Linux - {{ groupname }} - Group Details{% endblock %}
+{% block title %}Arch Linux - {{ groupname }} - {{ arch.name }} - Group Details{% endblock %}
{% block navbarclass %}anb-packages{% endblock %}
{% block content %}
diff --git a/templates/packages/groups.html b/templates/packages/groups.html
index 8a96b7e..87316a3 100644
--- a/templates/packages/groups.html
+++ b/templates/packages/groups.html
@@ -1,10 +1,10 @@
{% extends "base.html" %}
-{% block title %}Arch Linux - Package Groups{% endblock %}
+{% block title %}Arch Linux - Package Groups{% if arch %} - {{ arch }}{% endif %}{% endblock %}
{% block navbarclass %}anb-packages{% endblock %}
{% block content %}
<div class="box">
- <h2>Package Groups Overview</h2>
+ <h2>Package Groups Overview{% if arch %} - {{ arch }}{% endif %}</h2>
<table class="results">
<thead>
<tr>
diff --git a/urls.py b/urls.py
index 75f2ae7..b0f58b9 100644
--- a/urls.py
+++ b/urls.py
@@ -18,6 +18,7 @@ admin.autodiscover()
urlpatterns = patterns('packages.views',
(r'^groups/$', 'groups'),
+ (r'^groups/(?P<arch>[A-z0-9]+)/$', 'groups'),
(r'^groups/(?P<arch>[A-z0-9]+)/(?P<name>[A-z0-9\-+.]+)/$',
'group_details'),