Skip to content

Commit

Permalink
[#1521][m]: First pass at search-within-groups: Simple title-matching…
Browse files Browse the repository at this point in the history
… search implementation.
  • Loading branch information
teajaymars committed Jan 20, 2012
1 parent 55396e3 commit e9e68d6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
5 changes: 4 additions & 1 deletion ckan/controllers/group.py
Expand Up @@ -74,6 +74,7 @@ def read(self, id):
'user': c.user or c.author,
'schema': self._form_to_db_schema()}
data_dict = {'id': id}
q = c.q = request.params.get('q') # unicode format (decoded from utf8)
try:
c.group_dict = get_action('group_show')(context, data_dict)
c.group = context['group']
Expand Down Expand Up @@ -108,7 +109,9 @@ def read(self, id):

result = []
for pkg_rev in c.page.items:
result.append(package_dictize(pkg_rev, context))
pkg_dict = package_dictize(pkg_rev, context)
if (not q) or (q in pkg_dict['title']):
result.append(pkg_dict)
c.page.items = result

return render('group/read.html')
Expand Down
9 changes: 8 additions & 1 deletion ckan/public/css/style.css
Expand Up @@ -598,6 +598,13 @@ form.simple-form input[type=password] {
margin: 2em 0;
}

.group-search-box {
float: right;
}
.group-search-box input[type="search"] {
width: 300px;
}


/* ============== */
/* = User Index = */
Expand Down Expand Up @@ -674,7 +681,7 @@ body.package.search #menusearch {
.dataset-search {
margin-bottom: 35px;
}
.dataset-search input.search {
input.search {
width: 100%;
font-size: 1.2em;
margin: 0px;
Expand Down
11 changes: 9 additions & 2 deletions ckan/templates/group/read.html
Expand Up @@ -28,8 +28,15 @@ <h3 py:if="c.group['state'] != 'active'">State: ${c.group['state']}</h3>
${c.group_description_formatted}
</div>
<div class="group-dataset-list">
<h3>Datasets:</h3>
<p i18n:msg="item_count">There are ${c.page.item_count} datasets in this group.</p>
<div class="group-search-box">
<form method="GET" class="group-search" id="group-search">
<input type="search" name="q" class="search" placeholder="Search this group..." />
<input type="submit" value="Search" class="pretty-button primary button"/>
</form>
</div>
<h3>Datasets</h3>
<p py:if="not c.q" i18n:msg="item_count">There are ${c.page.item_count} datasets in this group.</p>
<p py:if="c.q">You searched for "${c.q}". Matched ${len(c.page.items)} out of ${c.page.item_count} datasets.</p>
${c.page.pager()}
${package_list_from_dict(c.page.items)}
${c.page.pager()}
Expand Down

0 comments on commit e9e68d6

Please sign in to comment.