* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/, gpackages/apps/generic/, gpackages/templates/
@ 2012-06-30 0:22 99% Slava Bacherikov
0 siblings, 0 replies; 1+ results
From: Slava Bacherikov @ 2012-06-30 0:22 UTC (permalink / raw
To: gentoo-commits
commit: 8d2ac5e1b45a8c97dbd54b392480017fce2c0ff5
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Fri Jun 29 21:55:48 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Fri Jun 29 21:55:48 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=8d2ac5e1
Add distinct for m2m.
---
gpackages/apps/generic/views.py | 15 ++++++++++++++-
gpackages/apps/packages/urls.py | 3 +--
gpackages/apps/packages/views.py | 12 +++++++-----
gpackages/templates/license_groups.html | 4 ++--
4 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/gpackages/apps/generic/views.py b/gpackages/apps/generic/views.py
index 4afe2ec..6beb59e 100644
--- a/gpackages/apps/generic/views.py
+++ b/gpackages/apps/generic/views.py
@@ -57,9 +57,15 @@ def dynamic_order(args_list, allowed_list, reverse = None):
class MultipleFilterListViewMixin(object):
allowed_filter = {}
allowed_order = {}
+ m2m_filter = ()
base_queryset = None # should be queryset
+ def __init__(self, *args, **kwargs):
+ super(MultipleFilterListViewMixin, self).__init__(*args, **kwargs)
+ l = (x for x in self.allowed_filter.itervalues())
+ self.m2m_set = frozenset(l)
+
def get_queryset(self):
qs = dynamic_filter(exclude_blank(self.request.GET),
self.allowed_filter)
@@ -78,7 +84,14 @@ class MultipleFilterListViewMixin(object):
if self.kwargs.get('order') not in self.allowed_order:
raise Http404('no such order')
- return self.base_queryset.filter(**qs).order_by(order)
+ queryset = self.base_queryset.filter(**qs).order_by(order)
+
+ for q in qs.iterkeys():
+ if q in self.m2m_set:
+ queryset = queryset.distinct()
+ break
+
+ return queryset
@classmethod
def get_url_part(cls):
diff --git a/gpackages/apps/packages/urls.py b/gpackages/apps/packages/urls.py
index ca15890..045a5ea 100644
--- a/gpackages/apps/packages/urls.py
+++ b/gpackages/apps/packages/urls.py
@@ -15,6 +15,5 @@ urlpatterns = patterns('',
# In Future I will write my onw URL Resolver !!!
#url(r'^package/(?:(?P<pk>\d+)|(?P<category>[^/]+)/(?P<name>[^/]+))/$', PackageDetailView.as_view(), name = 'package'),
url(r'^package/(?P<pk>\d+)/$', PackageDetailView.as_view(), name = 'package'),
- url(r'^package/(?P<category>[^/]+)/(?P<name>[^/:]+)/$', PackageDetailView.as_view(), name = 'package'),
- url(r'^package/(?P<category>[^/]+)/(?P<name>[^/:]+)::(?P<repository>[^/]+)/$', PackageDetailView.as_view(), name = 'package'),
+ url(r'^package/(?P<category>[^/]+)/(?P<name>[^/:]+)(?:::(?P<repository>[^/]+))?/$', PackageDetailView.as_view(), name = 'package'),
)
diff --git a/gpackages/apps/packages/views.py b/gpackages/apps/packages/views.py
index da330af..5d70510 100644
--- a/gpackages/apps/packages/views.py
+++ b/gpackages/apps/packages/views.py
@@ -7,6 +7,8 @@ from models import CategoryModel, HerdsModel, MaintainerModel, \
from django.shortcuts import get_object_or_404
+arches = ['alpha', 'amd64', 'arm', 'hppa', 'ia64', 'ppc', 'ppc64', 'sparc', 'x86']
+
class CategoriesListView(ContextListView):
extra_context = {'page_name': 'Categories',}
template_name = 'categories.html'
@@ -39,7 +41,6 @@ class LicenseGroupsView(ContextListView):
context_object_name = 'license_groups'
class EbuildsListView(ContextListView):
- arches = ['alpha', 'amd64', 'arm', 'hppa', 'ia64', 'ppc', 'ppc64', 'sparc', 'x86']
paginate_by = 40
extra_context = {'page_name': 'Ebuilds', 'arches' : arches}
template_name = 'ebuilds.html'
@@ -47,22 +48,24 @@ class EbuildsListView(ContextListView):
queryset = EbuildModel.objects.all(). \
select_related('package',
'package__virtual_package',
- 'package__virtual_package__category').prefetch_keywords(arches)
+ 'package__virtual_package__category'). \
+ prefetch_keywords(arches)
class PackagesListsView(MultipleFilterListViewMixin, ContextListView):
allowed_filter = { 'category':'virtual_package__category__category',
'repo':'repository__name',
'herd':'herds__name',
'maintainer': 'maintainers__pk',
- 'license': 'licenses__name'
+ 'license': 'ebuildmodel__licenses__name'
}
+ m2m_filter = ['herd', 'maintainer', 'ebuildmodel' ]
+
allowed_order = { 'create': 'created_datetime',
'update': 'updated_datetime',
'rand':'?', # it slow
None: '-updated_datetime'
}
- arches = ['alpha', 'amd64', 'arm', 'hppa', 'ia64', 'ppc', 'ppc64', 'sparc', 'x86']
paginate_by = 40
extra_context = {'page_name': 'Packages', 'arches': arches}
template_name = 'packages.html'
@@ -82,7 +85,6 @@ class PackagesListsView(MultipleFilterListViewMixin, ContextListView):
prefetch_keywords(arches)
class PackageDetailView(ContextView, DetailView):
- arches = ['alpha', 'amd64', 'arm', 'hppa', 'ia64', 'ppc', 'ppc64', 'sparc', 'x86']
template_name = 'package.html'
extra_context = {'page_name': 'Package', 'arches': arches}
context_object_name = 'package'
diff --git a/gpackages/templates/license_groups.html b/gpackages/templates/license_groups.html
index 00bc0a0..985c670 100644
--- a/gpackages/templates/license_groups.html
+++ b/gpackages/templates/license_groups.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
+{% load url from future %}
{% block content %}
<table class='table table-striped table-hover'>
@@ -17,7 +17,7 @@
{% for license_group in license_groups %}
<tr>
<td class="nowrap"><a href="#">{{ license_group.name }}</a></td>
- <td>{% for license in license_group.licenses.all %}<a href="#">{{ license }}</a>{% if not forloop.last %},{% endif %} {% endfor %}</td>
+ <td>{% for license in license_group.licenses.all %}<a href="{% url 'packages' license=license.name %}">{{ license.name }}</a>{% if not forloop.last %},{% endif %} {% endfor %}</td>
</tr>
{% endfor %}
</tbody>
^ permalink raw reply related [relevance 99%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2012-06-30 0:22 99% [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/, gpackages/apps/generic/, gpackages/templates/ Slava Bacherikov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox