summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDusty Phillips <buchuki@gmail.com>2008-10-07 23:28:37 +0200
committerDusty Phillips <buchuki@gmail.com>2008-10-07 23:28:37 +0200
commit51d947827419e5d61842cbd895a914076defb9c9 (patch)
treec6a6bc8d774775b831da3fc1896072f0cd032b10
parentc8549029ec0b103c932c62f1919f6ba263b0c7ef (diff)
downloadarchweb-51d947827419e5d61842cbd895a914076defb9c9.tar.gz
archweb-51d947827419e5d61842cbd895a914076defb9c9.tar.xz
trying to flesh out the page
-rw-r--r--packages/templatetags/package_extras.py6
-rw-r--r--packages/views.py24
-rw-r--r--templates/devel/index.html6
-rw-r--r--templates/packages/search.html17
4 files changed, 38 insertions, 15 deletions
diff --git a/packages/templatetags/package_extras.py b/packages/templatetags/package_extras.py
index 5644583..b6868ec 100644
--- a/packages/templatetags/package_extras.py
+++ b/packages/templatetags/package_extras.py
@@ -1,3 +1,4 @@
+import cgi, urllib
from django import template
register = template.Library()
@@ -6,7 +7,8 @@ class BuildQueryStringNode(template.Node):
def __init__(self, sortfield):
self.sortfield = sortfield
def render(self, context):
- qs = context['querystring'].copy()
+ #qs = context['querystring'].copy()
+ qs = dict(cgi.parse_qsl(context['current_query'][1:]))
if qs.has_key('sort') and qs['sort'] == self.sortfield:
if self.sortfield.startswith('-'):
qs['sort'] = self.sortfield[1:]
@@ -14,7 +16,7 @@ class BuildQueryStringNode(template.Node):
qs['sort'] = '-' + self.sortfield
else:
qs['sort'] = self.sortfield
- return '?' + qs.urlencode()
+ return '?' + urllib.urlencode(qs)
@register.tag(name='buildsortqs')
def do_buildsortqs(parser, token):
diff --git a/packages/views.py b/packages/views.py
index fdc3f05..d6f23b1 100644
--- a/packages/views.py
+++ b/packages/views.py
@@ -57,20 +57,25 @@ class PackageSearchForm(forms.Form):
q = forms.CharField(required=False)
maintainer = forms.ChoiceField(required=False)
last_update = forms.DateField(required=False, widget=AdminDateWidget())
+ flagged = forms.ChoiceField(
+ choices=[('', 'All')] + make_choice(['Flagged', 'Not Flagged']),
+ required=False)
limit = forms.ChoiceField(
- choices=make_choice([50, 100, 250]) + [('', 'All')],
+ choices=make_choice([50, 100, 250]) + [('all', 'All')],
required=False,
initial=50)
def clean_limit(self):
limit = self.cleaned_data['limit']
- if limit:
+ if limit == 'all':
+ limit = None
+ elif limit:
try:
limit = int(limit)
except:
raise forms.ValidationError("Should be an integer")
else:
- limit = None
+ limit = 50
return limit
@@ -104,6 +109,10 @@ def search(request, page=None):
arch__name=form.cleaned_data['arch'])
if form.cleaned_data['maintainer'] == 'orphan':
packages=packages.filter(maintainer__id = 0)
+ if form.cleaned_data['flagged'] == 'Flagged':
+ packages=packages.filter(needupdate=True)
+ elif form.cleaned_data['flagged'] == 'Not Flagged':
+ packages = packages.filter(needupdate=False)
elif form.cleaned_data['maintainer']:
packages = packages.filter(
maintainer__username=form.cleaned_data['maintainer'])
@@ -122,6 +131,15 @@ def search(request, page=None):
page_dict = {'search_form': form,
'current_query': current_query
}
+ if len(packages) == 1:
+ return HttpResponseRedirect(packages[0].get_absolute_url())
+
+ sort = request.GET.get('sort', '')
+ if sort in request.GET:
+ packages = packages.order_by(sort, 'repo', 'arch', 'pkgname')
+ else:
+ packages = packages.order_by('repo', 'arch', '-last_update', 'pkgname')
+
return list_detail.object_list(request, packages,
template_name="packages/search.html",
page=page,
diff --git a/templates/devel/index.html b/templates/devel/index.html
index 8879496..887e3a9 100644
--- a/templates/devel/index.html
+++ b/templates/devel/index.html
@@ -34,7 +34,7 @@
<tr class="{% cycle pkgr2,pkgr1 %}">
<td><strong>{{ arch.name }}</strong></td>
<td><a href="/packages/?arch={{ arch.name }}"><strong>{{ arch.packages.count }}</strong> packages</a></td>
- <td><a href="/packages/?arch={{ arch.name }}&flagged_only=y"><strong>{{ arch.packages.flagged.count }}</strong> packages</a></td>
+ <td><a href="/packages/?arch={{ arch.name }}&flagged=Flagged"><strong>{{ arch.packages.flagged.count }}</strong> packages</a></td>
</tr>
{% endfor %}
</table>
@@ -52,7 +52,7 @@
<tr class="{% cycle pkgr2,pkgr1 %}">
<td><strong>{{ repo.name }}</strong></td>
<td><a href="/packages/?repo={{ repo.name }}"><strong>{{ repo.packages.count }}</strong> packages</a></td>
- <td><a href="/packages/?repo={{ repo.name }}&flagged_only=y"><strong>{{ repo.packages.flagged.count }}</strong> packages</a></td>
+ <td><a href="/packages/?repo={{ repo.name }}&flagged=Flagged"><strong>{{ repo.packages.flagged.count }}</strong> packages</a></td>
</tr>
{% endfor %}
</table>
@@ -71,7 +71,7 @@
<tr class="{% cycle pkgr2,pkgr1 %}">
<td><strong>{{ maint.get_full_name }}</strong></td>
<td><a href="/packages/?maint={{ maint.id }}"><strong>{{ maint.maintained_packages.count }}</strong> packages</a></td>
- <td><a href="/packages/?maint={{ maint.id }}&flagged_only=y"><strong>{{ maint.maintained_packages.flagged.count }}</strong> packages</a></td>
+ <td><a href="/packages/?maint={{ maint.id }}&flagged=Flagged"><strong>{{ maint.maintained_packages.flagged.count }}</strong> packages</a></td>
</tr>
{% endfor %}
</table>
diff --git a/templates/packages/search.html b/templates/packages/search.html
index bf07558..a54a9a0 100644
--- a/templates/packages/search.html
+++ b/templates/packages/search.html
@@ -18,6 +18,7 @@
<td><span class="smalltext">Keywords</span></td>
<td><span class="smalltext">Maintainer</span></td>
<td><span class="smalltext">Last Update</span></td>
+ <td><span class="smalltext">Flagged</span></td>
<td><span class="smalltext">Per Page</span></td>
</tr>
<tr>
@@ -26,6 +27,7 @@
{% td_input search_form.q %}
{% td_input search_form.maintainer%}
{% td_input search_form.last_update %}
+ {% td_input search_form.flagged %}
{% td_input search_form.limit %}
<td><input type="submit" value="Search" />
</tr>
@@ -40,13 +42,14 @@
<tr>
<form method="post" action="/packages/update/">
<th>&nbsp;</th>
- <th>Arch</th>
- <th>Repo</th>
- <th>Name</th>
+ <th><a href="{% buildsortqs "arch" %}">Arch</a></th>
+ <th><a href="{% buildsortqs "repo" %}">Repo</a></th>
+ <th><a href="{% buildsortqs "pkgname" %}">Name</a></th>
<th>Version</th>
<th>Description</th>
- <th>Maintainer</th>
- <th>Last Updated</th>
+ <th><a href="{% buildsortqs "maintainer" %}">Maintainer</a></th>
+ <th><a href="{% buildsortqs "-last_update" %}">Last Updated</a></th>
+
</tr>
{% for pkg in package_list %}
<tr class="{% cycle pkgr2,pkgr1 %}">
@@ -84,8 +87,8 @@
<a href="/packages/search/{{page_obj.next_page_number}}/{{current_query}}">
Next &gt;&gt;&gt;
</a>
- {% else %} &gt;&gt;&gt;
- Next
+ {% else %}
+ Next &gt;&gt;&gt;
{% endif %}
</td>
<br />